".Keep($text).""; $text = preg_replace("/^[^\\S\n]*\n/", "\n", substr($lead,1).$text); $text = preg_replace("/\n[^\\S\n]*$/", "\n", $text); return "
".Keep($text)."
"; } Markup('[=','_begin',"/(\n[^\\S\n]*)?\\[([=@])(.*?)\\2\\]/se", "PreserveText('$2', PSS('$3'), '$1')"); Markup('restore','<_end',"/$KeepToken(\\d.*?)$KeepToken/e", '$GLOBALS[\'KPV\'][\'$1\']'); Markup('<:', '>restore', "/<:[^>]*>/", ""); ## remove carriage returns before preserving text Markup('\\r','<[=','/\\r/',''); # $[phrase] substitutions Markup('$[phrase]', '>[=', '/\\$\\[(?>([^\\]]+))\\]/e', "XL(PSS('$1'))"); # {$var} substitutions Markup('{$fmt}','>$[phrase]', '/{\\$((Group|Name|Title)(spaced)?|LastModified(By|Host)?|FullName)}/e', "FmtPageName('$$1',\$pagename)"); Markup('{$var}','>{$fmt}', '/{\\$(Version(Num)?|Auth(or|Id)|UrlPage|Default(Name|Group)|SiteGroup)}/e', "\$GLOBALS['$1']"); Markup('if', 'fulltext', "/\\(:(if[^\n]*?):\\)(.*?)(?=\\(:if[^\n]*?:\\)|$)/sei", "CondText(\$pagename,PSS('$1'),PSS('$2'))"); ## (:include:) Markup('include', '>if', '/\\(:include\\s+(\\S.*?):\\)/ei', "PRR().IncludeText(\$pagename, '$1')"); ## GroupHeader/GroupFooter handling Markup('nogroupheader', '>include', '/\\(:nogroupheader:\\)/ei', "PZZ(\$GLOBALS['GroupHeaderFmt']='')"); Markup('nogroupfooter', '>include', '/\\(:nogroupfooter:\\)/ei', "PZZ(\$GLOBALS['GroupFooterFmt']='')"); Markup('groupheader', '>nogroupheader', '/\\(:groupheader:\\)/ei', "PRR().FmtPageName(\$GLOBALS['GroupHeaderFmt'],\$pagename)"); Markup('groupfooter','>nogroupfooter', '/\\(:groupfooter:\\)/ei', "PRR().FmtPageName(\$GLOBALS['GroupFooterFmt'],\$pagename)"); ## (:nl:) Markup('nl0','(?:\\(:nl:\\))+)([^\n])/i","$1\n$2"); Markup('nl1','>nl0',"/\\(:nl:\\)/i",''); ## \\$ (end of line joins) Markup('\\$','>nl1',"/\\\\(?>(\\\\*))\n/e", "str_repeat('
',strlen('$1'))"); ## (:noheader:),(:nofooter:),(:notitle:)... Markup('noheader', 'directives', '/\\(:noheader:\\)/ei', "SetTmplDisplay('PageHeaderFmt',0)"); Markup('nofooter', 'directives', '/\\(:nofooter:\\)/ei', "SetTmplDisplay('PageFooterFmt',0)"); Markup('notitle', 'directives', '/\\(:notitle:\\)/ei', "SetTmplDisplay('PageTitleFmt',0)"); Markup('noleft', 'directives', '/\\(:noleft:\\)/ei', "SetTmplDisplay('PageLeftFmt',0)"); Markup('noright', 'directives', '/\\(:noright:\\)/ei', "SetTmplDisplay('PageRightFmt',0)"); ## (:spacewikiwords:) Markup('spacewikiwords', 'directives', '/\\(:(no)?spacewikiwords:\\)/ei', "PZZ(\$GLOBALS['SpaceWikiWords']=('$1'!='no'))"); ## (:linkwikiwords:) Markup('linkwikiwords', 'directives', '/\\(:(no)?linkwikiwords:\\)/ei', "PZZ(\$GLOBALS['LinkWikiWords']=('$1'!='no'))"); ## (:messages:) Markup('messages', 'directives', '/^\\(:messages:\\)/ei', "'<:block>'.Keep( FmtPageName(implode('',(array)\$GLOBALS['MessagesFmt']), \$pagename))"); ## (:comment:) Markup('comment', 'directives', '/\\(:comment .*?:\\)/i', ''); ## character entities Markup('&','directives','/&(?>([A-Za-z0-9]+|#\\d+|#[xX][A-Fa-f0-9]+));/', '&$1;'); ## (:title:) Markup('title','>&', '/\\(:title\\s(.*?):\\)/ei', "PZZ(\$GLOBALS['PCache'][\$pagename]['title']=PSS('$1'))"); ## (:keywords:) Markup('keywords', '>&', "/\\(:keywords?\\s+([^'\n]+?):\\)/ei", "PZZ(\$GLOBALS['HTMLHeaderFmt'][] = \"\")"); Markup('description', '>&', "/\\(:description\\s+(.+?):\\)/ei", "PZZ(\$GLOBALS['HTMLHeaderFmt'][] = \"\")"); #### inline markups #### ## ''emphasis'' Markup("''",'inline',"/''(.*?)''/",'$1'); ## '''strong''' Markup("'''","<''","/'''(.*?)'''/",'$1'); ## '''''strong emphasis''''' Markup("'''''","<'''","/'''''(.*?)'''''/",'$1'); ## @@code@@ Markup('@@','inline','/@@(.*?)@@/','$1'); ## '+big+', '-small-' Markup("'+",'inline',"/'\\+(.*?)\\+'/",'$1'); Markup("'-",'inline',"/'\\-(.*?)\\-'/",'$1'); ## '^superscript^', '_subscript_' Markup("'^",'inline',"/'\\^(.*?)\\^'/",'$1'); Markup("'_",'inline',"/'_(.*?)_'/",'$1'); ## [+big+], [-small-] Markup('[+','inline','/\\[(([-+])+)(.*?)\\1\\]/e', "''. PSS('$3')"); ## {+ins+}, {-del-} Markup('{+','inline','/\\{\\+(.*?)\\+\\}/','$1'); Markup('{-','inline','/\\{-(.*?)-\\}/','$1'); ## [[<<]] (break) Markup('[[<<]]','inline','/\\[\\[<<\\]\\]/',"
"); ###### Links ###### ## [[free links]] Markup('[[','links',"/(?>\\[\\[\\s*)(\\S.*?)\\]\\]($SuffixPattern)/e", "Keep(MakeLink(\$pagename,PSS('$1'),NULL,'$2'),'L')"); ## [[!Category]] SDV($CategoryGroup,'Category'); SDV($LinkCategoryFmt,"\$LinkText"); Markup('[[!','<[[','/\\[\\[!(.*?)\\]\\]/e', "Keep(MakeLink(\$pagename,PSS('$CategoryGroup/$1'),NULL,'',\$GLOBALS['LinkCategoryFmt']),'L')"); ## [[target | text]] Markup('[[|','<[[', "/(?>\\[\\[([^|\\]]+)\\|\\s*)(.*?)\\s*\\]\\]($SuffixPattern)/e", "Keep(MakeLink(\$pagename,PSS('$1'),PSS('$2'),'$3'),'L')"); ## [[text -> target ]] Markup('[[->','>[[|', "/(?>\\[\\[([^\\]]+?)\\s*-+>\\s*)(\\S.+?)\\]\\]($SuffixPattern)/e", "Keep(MakeLink(\$pagename,PSS('$2'),PSS('$1'),'$3'),'L')"); ## [[#anchor]] Markup('[[#','<[[','/(?>\\[\\[#([A-Za-z][-.:\\w]*))\\]\\]/e', "Keep(\"\",'L')"); ## [[target |#]] reference links Markup('[[|#', '<[[|', "/(?>\\[\\[([^|\\]]+))\\|#\\]\\]/e", "Keep(MakeLink(\$pagename,PSS('$1'),'['.++\$MarkupFrame[0]['ref'].']'),'L')"); ## bare urllinks Markup('urllink','>[[', "/\\b(?>(\\L))[^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars]/e", "Keep(MakeLink(\$pagename,'$0','$0'),'L')"); ## mailto: links Markup('mailto','(\\L))([^\\s$UrlExcludeChars]+$ImgExtPattern)(\"([^\"]*)\")?/e", "Keep(\$GLOBALS['LinkFunctions']['$1'](\$pagename,'$1','$2','$4','$1$2', \$GLOBALS['ImgTagFmt']),'L')"); ## bare wikilinks Markup('wikilink','>urllink',"/\\b($GroupPattern([\\/.]))?($WikiWordPattern)/e", "Keep(WikiLink(\$pagename,'$0'),'L')"); ## escaped `WikiWords Markup('`wikiword', '(\\s+|%%|%[A-Za-z][-,=:#\\w\\s'\"]*%)*)$KeepToken(\\d+L)$KeepToken)(\\s*\\|\\s?)?(.*)$/e", "PSS((strpos(\$GLOBALS['KPV']['$3'],'
$1' . ('$4' ? '
' : '') .'$5
')"); #### Block markups #### ## process any <:...> markup Markup('^<:','>block','/^(?=\\s*\\S)(<:([^>]+)>)?/e',"Block('$2')"); # unblocked lines w/block markup become anonymous <:block> Markup('^!<:', '<^<:', '/^(?!<:)(?=.*<\\/?(form|div|table|p|ul|ol|dl|h[1-6]|blockquote|pre|hr|textarea)\\b)/', '<:block>'); ## bullet lists Markup('^*','block','/^(\\*+)\\s?/','<:ul,$1>'); ## numbered lists Markup('^#','block','/^(#+)\\s?/','<:ol,$1>'); ## indented (->) /hanging indent (-<) text Markup('^->','block','/^(?>(-+))>\\s?/','<:indent,$1>'); Markup('^-<','block','/^(?>(-+))<\\s?/','<:outdent,$1>'); ## definition lists Markup('^::','block','/^(:+)([^:]+):/','<:dl,$1>
$2
'); ## preformatted text Markup('^ ','block','/^(\\s)/','<:pre,1>$1'); ## blank lines Markup('blank', '<^ ', '/^\\s+$/', ''); ## Q: and A: Markup('^Q:', 'block', '/^Q:(.*)$/', "<:block>

$1

"); Markup('^A:', 'block', '/^A:/', Keep('')); ## tables ## ||cell||, ||!header cell||, ||!caption!|| Markup('^||||', 'block', '/^\\|\\|.*\\|\\|.*$/e', "FormatTableRow(PSS('$0'))"); ## ||table attributes Markup('^||','>^||||','/^\\|\\|(.*)$/e', "PZZ(\$GLOBALS['BlockMarkups']['table'][0] = PQA(PSS(''))) .'<:block>'"); ## headings Markup('^!', 'block', '/^(!{1,6})\\s?(.*)$/e', "'<:block>$2'"); ## horiz rule Markup('^----','>^->','/^----+/','<:block>
'); #### (:table:) markup (AdvancedTables) function Cells($name,$attr) { global $MarkupFrame; $attr = preg_replace('/([a-zA-Z]=)([^\'"]\\S*)/',"\$1'\$2'",$attr); $tattr = @$MarkupFrame[0]['tattr']; $name = strtolower($name); $out = array('<:block>'); if (strncmp($name, 'cell', 4) != 0 || @$MarkupFrame[0]['closeall']['div']) { $out[] = @$MarkupFrame[0]['closeall']['div']; unset($MarkupFrame[0]['closeall']['div']); $out[] = @$MarkupFrame[0]['closeall']['table']; unset($MarkupFrame[0]['closeall']['table']); } if ($name == 'div') { $MarkupFrame[0]['closeall']['div'] = ""; $out[] = "
"; } if ($name == 'table') $MarkupFrame[0]['tattr'] = $attr; if (strncmp($name, 'cell', 4) == 0) { if (strpos($attr, "valign=")===false) $attr .= " valign='top'"; if (!@$MarkupFrame[0]['closeall']['table']) { $MarkupFrame[0]['closeall']['table'] = "
"; $out[] = "
"; } else if ($name == 'cellnr') $out[] = "
"; else $out[] = ""; } return implode('', $out); } Markup('table', '>', '><<', '<^>>', '/^>><</', '(:divend:)'); #### special stuff #### ## (:markup:) for displaying markup examples function MarkupMarkup($pagename, $lead, $text) { return "$lead<:block>" . Keep("
" .
      wordwrap($text, 70) .  "
") . "\n$text\n(:divend:)
\n"; } Markup('markup', '<[=', "/(^|\\(:nl:\\))\\(:markup:\\)[^\\S\n]*\\[([=@])(.*?)\\2\\]/seim", "MarkupMarkup(\$pagename, '$1', PSS('$3'))"); Markup('markupend', '>markup', "/(^|\\(:nl:\\))\\(:markup:\\)[^\\S\n]*\n(.*?)\\(:markupend:\\)/seim", "MarkupMarkup(\$pagename, '$1', PSS('$2'))"); $HTMLStylesFmt['markup'] = " table.markup { border: 2px dotted #ccf; width:90%; } td.markup1, td.markup2 { padding-left:10px; padding-right:10px; } td.markup1 { border-bottom: 1px solid #ccf; } div.faq { margin-left:2em; } div.faq p.question { margin: 1em 0 0.75em -2em; font-weight:bold; } div.faq hr { margin-left: -2em; } ";