PmWikiZhCnUtf8 / CustomMarkup |
SearchWiki PmWikiZhCnUtf8.最近改变 编辑页面 页面修正 |
$DoubleBrackets["[[Pm]]"] = "[[PatrickMichaud Pm]]";will replace all occurrences of "[[Pm]]" in the markup with "[[PatrickMichaud Pm]]". This takes place before LinkPatterns are processed, so the text after substitution will be treated as if the user had entered it directly. Also, the values from $DoubleBrackets are processed using FmtPageName, so things like '$Group', '$Titlespaced', '$PageUrl', etc. are replaced with their appropriate values for the page being processed. The entries in $InlineReplacements are associative arrays; the keys are regular expressions to be matched, and the values are the replacement strings (via PHP's preg_replace function).
#### superscripts via ^^text^^, subscripts via __text__ $InlineReplacements['/\\^\\^(.*?)\\^\\^/'] = "<sup>\$1</sup>"; $InlineReplacements['/__(.*?)__/'] = "<sub>\$1</sub>"; #### a simple smiley to gif conversion $InlineReplacements['/:-)/'] = '<img src="http://www.example.com/smileys/happy.gif" alt=":-)">';Note that the $InlineReplacement keys must include regular expression delimiters (normally slashes). Also note that the smiley example could not have been done using $DoubleBrackets because the src="http://..." would've been picked up and modified by the $LinkPatterns. The $DoubleBrackets array will also perform a regular expression search/replace (via preg_replace) for any keys that begin with a slash. Finally, $LinkPatterns works a bit like $DoubleBrackets and $InlineReplacements, but is more complex because of the variety of replacements to be performed and the fact that order is very significant. The first index of $LinkPatterns entries specifies the sequence in which to process the patterns, the second index specifies the regular expression pattern to match, and the value of the entry specifies either the replacement string or the name of a function to be called to provide the replacement string. Thus:
$LinkPatterns[200]["\\bmailto:($UrlPathPattern)"] = "<a href='$0'>$1</a>";says to replace the markup text like "mailto:[email protected]" with "<a href='mailto:[email protected]'>[email protected]</a>", and to do this after $LinkPatterns numbered less than 200 but before $LinkPatterns numbered higher than 200. The statement
$LinkPatterns[120]["\\bAttach:($UploadNamePattern)"] = 'FmtAttachLink';says to replace Attach: markup by calling the FmtAttachLink function. The standard sequence of replacements in a PmWiki distribution are currently:
100 ThisWiki:, ThisGroup:, ThisPage: links (from thiswiki.php) 120 Attach: links (from upload.php) 200 mailto: links 300 http:, ftp:, gopher:, etc. links 400 InterMap links 500 Group/{{free links}} and Group.{{free links}} 600 {{free links}} 700 Group/WikiWords and Group.WikiWords 800 WikiWordsNote that unlike $InlineReplacements, the regexps in $LinkPatterns cannot include the regular expression delimiters. Anyway, hopefully this sheds a little light the role that these arrays play in PmWiki's markup to HTML conversion for those who are wanting to add their own customized markups. Of course, if anyone has any questions, feel free to write me or the listserv. << CustomFreeLinks | PmWikiZhCnUtf8.DocumentationIndex | Upgrades >>