本文整理汇总了PHP中Michelf\MarkdownExtra::stripLinkDefinitions方法的典型用法代码示例。如果您正苦于以下问题:PHP MarkdownExtra::stripLinkDefinitions方法的具体用法?PHP MarkdownExtra::stripLinkDefinitions怎么用?PHP MarkdownExtra::stripLinkDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Michelf\MarkdownExtra
的用法示例。
在下文中一共展示了MarkdownExtra::stripLinkDefinitions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stripLinkDefinitions
/**
* Strip plugin definition from text,
* stores the plugin-ID and params in hash references.
*/
protected function stripLinkDefinitions($text)
{
$less_than_tab = $this->tab_width - 1;
// First, catch the multi line YAML params
//
// [id]: plugin-name
// ------
// foo: bar
// hoge: fuga
// ------
$text = preg_replace_callback('{
(?:\\A|\\n)
[ ]{0,' . $less_than_tab . '}\\[([^\\n]+?)\\][ ]?: # id = $1
[ ]*
\\n? # maybe *one* newline
[ ]*
(?:
(\\S+?) # plugin-name = $2
)
[ ]*
\\n # *one* newline
(-{3,}) # delimiter line = $3
[ ]*
\\n
([\\w\\W]*) # YAML structure = $4
\\n
\\3
[ ]*
(\\n|\\z)
}x', array($this, '_stripPluginYamlDefinitions_callback'), $text);
// Second, strip link definitions
$text = parent::stripLinkDefinitions($text);
// Last, strip normal plugin definitions
// Link defs are in the form: ^[id]: plugin-name params, params, params ...
// must have one more params
$text = preg_replace_callback('{
^[ ]{0,' . $less_than_tab . '}\\[(.+)\\][ ]?: # id = $1
[ ]*
\\n? # maybe *one* newline
[ ]*
(?:
(\\S+?) # plugin-name = $2
)
[ ]*
\\n? # maybe one newline
[ ]*
(?:
(?<=\\s) # lookbehind for whitespace
(.*?) # params = $3
[ ]*
) # params is required
(?:\\n+|\\Z)
}xm', array(&$this, '_stripPluginDefinitions_callback'), $text);
return $text;
}