right aligned text # {=sticky note comments=} # !run-in heads!and text # tidy :: used merely to indent # :: for multiple
per
# teaser markups T[:*#] Name and (:para Name#id:) # lazy web links (an alternative to the one from Pm) # automatic smart quotes in text and link text # page tool-tip format Version 2.0.16 (beta release nearly stable) Copyright 2004, 2005 John Rankin (john.rankin@affinity.co.nz) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. lazy web links Copyright 2004 Patrick R. Michaud (pmichaud@pobox.com) */ $HTMLStylesFmt['extend'] = " a.createlink { color: red; } #wikitext { line-height: 1.4em; } #wikitext sub, #wikitext sup { line-height: 0; } div.footnote { width: 160px; border-bottom: 1px solid blue; margin-bottom: 0.5em; } p.footnote { text-indent: -1em; margin-right: 3em; margin-left: 3em; margin-top: 0px; margin-bottom: 0.5em; font-size: smaller; } p.qanda:first-letter { float: left; font-family: Old English, Georgia, serif; font-size: 290%; line-height: 0.85em; margin-right: 0.3em; margin-bottom:-0.25em; } p.drop:first-letter { float: left; font-family: Old English, Georgia, serif; font-size: 290%; line-height: 0.85em; margin-right: 0.1em; margin-bottom:-0.25em; } del { color: red; } ins { background-color: yellow; } span.stickynote { font-size: smaller; float: right; padding: 8px; margin-left: 10px; margin-bottom: 10px; width: 160px; border-top: 1px dotted; border-bottom: 1px dotted; text-align: center; color: navy; background-color: #dcdcdc; } dfn { font-style: normal; } abbr { font-style: italic; } abbr, dfn.definition { border-bottom: 1px dotted; } h5.runin { display: run-in; font-size: 100%; border: none; } div.figure { border: thin silver solid; padding: 0.3em; } div.figure p { text-align: center; font-style: italic; font-size: smaller; padding-top: 0.2em; margin: 0; } dd { margin-bottom: 0.5em } b.selfreference { color: #e66e31; border-bottom: 1px dotted; } "; ## require 2 lower and upper case characters for a WikiWord $WikiWordPattern = '[[:upper:]][[:alnum:]]*(?:[[:upper:]][[:lower:]0-9][[:lower:]0-9]|[[:lower:]0-9][[:lower:]0-9][[:upper:]]|[[:lower:]0-9][[:upper:]]+[[:lower:]0-9])[[:alnum:]]*'; #### escape character (backtick) #### ## prevent WikiWords with Wiki`Word and `WikiWord markups Markup("`A",'>links','/([[:alnum:].\/])?`([[:upper:]])/','$1$2'); ## '`.' (invisible stop) Markup("`.",'>links',"/`\./",''); ## '`-' (en dash) Markup("`-",'inline',"/`-/",'–'); ## '` ' (nonbreaking space) Markup("`s",'inline',"/`\s/",' '); ## '`:' (middot) Markup("`:",'inline',"/`:/",'·'); ## simple fractions Markup("1/4",'inline',"/`1\/?4/",'¼'); Markup("1/2",'inline',"/`1\/?2/",'½'); Markup("3/4",'inline',"/`3\/?4/",'¾'); ## em dash, en dash, plus or minus, and minus Markup("--",'inline',"/--([^-&])/",'—$1'); Markup("d-d",'>links',"/(\\d)-(\\d)/",'$1–$2'); Markup("+-",'<-d',"/\+\/?-/",'±'); Markup("-d",'>d-d',"/([^[:alpha:]])-(\\d)/",'$1−$2'); ## left and right arrows Markup("<-",'",'links',"/<<(.*?)>>/",'«$1»'); Markup("lsa",'>aquo',"/<(.*?)\|/",'‹$1|'); Markup("rsa",'>aquo',"/\|(.*?)>/",'|$1›'); ## long vowels (macrons) $LongVowels = array ( 'A' => 'Ā', 'a' => 'ā', 'E' => 'Ē', 'e' => 'ē', 'I' => 'Ī', 'i' => 'ī', 'O' => 'Ō', 'o' => 'ō', 'U' => 'Ū', 'u' => 'ū' ); Markup("mac",'>&',"/(?:&|{)([AaEeIiOoUu])(?:m;|})/e","Macron('$1')"); function Macron($vowel) { global $LongVowels; return $LongVowels[$vowel]; } #### inline markups #### ## '/cite/' Markup("'/",'inline',"/'\/(.*?)\/'/",'$1'); ## ';small caps;' Markup("';",'inline',"/';(.*?);'/", '$1'); ## [^footnote text^] and a style to tidy line spacing Markup("[^",'>links','/\[\^(.*?)\^\]/e',"Footnote('$1')"); Markup("^[^",'block','/^\[\^#\^\]$/e',"'<:block>'.Footnote('#')"); function Footnote($foottext) { static $fncount, $fntext; if ($foottext == "#") { $fncount = 0; $r = "
 
$fntext"; $fntext = ''; } else { $fncount++; $r = "$fncount"; $foottext = stripslashes($foottext); $fntext .= "

$fncount $foottext

"; } return $r; } ## Q: and A: markup Markup('q&a','

$1$2

'); ## dropcaps markup Markup('A;','block','/^([[:upper:]]);(.*)$/','<:block>

$1$2

'); ## {abbr|abbreviations}, {:term:definitions} & right aligned text if ($action=="print" || $action=="publish") { Markup("{|}",'>links',"/\{(.*?)\|(.*?\}?)\}/",'$1 ($2)'); Markup("{:}",'','block','/^=>(.*)$/','<:block>'); $hide = 2; } else { Markup("{|}",'>links',"/\{(.*?)\|(.*?\}?)\}/",'$1'); Markup("{:}",''.PSS('$1').''"); Markup('^=>','block','/^=>(.*)$/', '<:block>

$1

'); } function DfnTitle($title,$text) { $title = str_replace('"','"',$title); $title = (strstr($title,"'")) ? '"'.$title.'"' : "'$title'"; return (preg_match('/^[[:alnum:]].*$/',$text)) ? "$title class='definition'" : $title; } ## centred text Markup('^=|','block','/^=\|(.*)$/', '<:block>

$1

'); ## {+insertions+}, {-deletions-} and {=sticky notes=} SDV($hide, isset($HTTP_GET_VARS['hide']) ? $HTTP_GET_VARS['hide'] : 0); $pgnum = isset($HTTP_GET_VARS['p']) ? "&p=".$HTTP_GET_VARS['p'] : ''; if ($hide) { Markup("{+",'inline',"/{\+(.*?)\+}/",'$1'); Markup("{-",'inline',"/{\-(.*?)\-}/",''); Markup("{=",'inline',"/{=(.*?)=}/",''); if ($hide==1) Markup('revisions','<${fmt}','/\(:revisions:\)/', '[[{$Name}?hide=0'.$pgnum.' | Show revisions]]'); else Markup('revisions','directives','/\(:revisions:\)/',''); } else { Markup("{=",'inline',"/{=(.*?)=}/",'$1'); Markup('revisions','<${fmt}','/\\(:revisions:\)/', '[[{$Name}?hide=1'.$pgnum.' | Hide revisions]]'); } ## run-in heads Markup('^!!','<^!','/^!([^!]+)!(.*?)$/', '<:block>
$1.

$2

'); ## figure captions Markup('fig','

'.PSS('$1').'

'. (('$3'=='') ? PSS('$2') : PSS('$3')).'

'"); ## tidy :: used merely to indent Markup('^::2: :','<^: :2->','/^(:+)(:[^:]+)$/','$1 $2'); Markup('^: :2->',' per
Markup('::','
',PSS('$2'))"); ## teaser markups T[:*#] Name and (:para Name#id:) Markup('para','directives',"/\(:para\s+(.+?)(?:#([^:\s]+))?:\)/e", "TeaseParagraph(\$pagename,'$1','$2')"); Markup('tfl','directives',"/^T([:*#]+)\s*(\[\[.+?\]\])/e", "TeaserFL(\$pagename,'$1','$2')"); Markup('tww','directives', "/^T([:*#]+)\s*((?:$GroupPattern([\/.]))?$WikiWordPattern)/e", "Teaser(\$pagename,'$1','$2')"); SDV($ParaBadAnchorFmt,"'''\$Anchor''' \$[not found in] \$PageName\n"); function TeaserFL($pagename,$markup,$linkword) { return "$markup$linkword: " . TeaseParagraph($pagename,FLRef($linkword),''); } function FLRef($linkword) { $l = preg_replace('/\\s*\\|[^\\]]+/','',$linkword); $l = preg_replace('/[^\\]]+-+>\\s*/','',$l); return $l; } function Teaser($pagename,$markup,$linkword) { return "$markup$linkword: " . TeaseParagraph($pagename,$linkword,''); } function TeaseParagraph($pagename,$teasername,$teaseranch) { global $ParaBadAnchorFmt; $tname = MakePageName($pagename,$teasername); if ($tname==$pagename) return ''; $tpage=RetrieveAuthPage($tname,'read',false,''); $ttext=$tpage['text']; $tgroup = FmtPageName('$Group',$tname); if ($teaseranch=='') $tpara = CleanParagraph($pagename,$tgroup, substr($ttext,0,strpos($ttext."\n","\n"))); elseif (preg_match("/\\[\\[#+$teaseranch\\]\\]\\n?([^\\n]+)/",$ttext,$m)) $tpara = CleanParagraph($pagename,$tgroup,$m[1]); else $tpara = str_replace('$Anchor',$teaseranch, FmtPageName($ParaBadAnchorFmt,$tname)); return $tpara; } function CleanParagraph($pagename,$group,$para) { global $GroupPattern,$WikiWordPattern; $pgroup = FmtPageName('$Group',$pagename); $p = preg_replace("/^[#*!]+\s*/","",$para); $p = preg_replace("/^:.*?:/","",$p); $p = preg_replace("/`\\..*?$/","...",$p); $p = preg_replace("/\\[@(.*?)@\\]/","@@[=$1=]@@",$p); $p = preg_replace("/\\[=(.*?)=\\]/e",'Keep(PSS("$1"))',$p); $p = preg_replace("/\\[\\[#.*?\\]\\]/","",$p); $p = preg_replace("/\\b(($GroupPattern([\\/.]))?$WikiWordPattern)/e", 'QualifyWLink($pgroup,$group,"$1")',$p); $p = preg_replace("/\\[\\[(.*?)\\]\\]/e", "'[['.QualifyFLink('$pgroup','$group','$1').']]'",$p); return FmtPageName(preg_replace("/{(\\$.*?)}/",'$1',$p),$pagename); } function QualifyWLink($pgroup,$group,$link) { $g = ($pgroup==$group) ? '' : "$group/"; return (preg_match("/[.\\/]/",$link)) ? $link : "$g$link"; } function QualifyFLink($pgroup,$group,$link) { $g = ($pgroup==$group) ? '' : "$group/"; $l = FLRef($link); return (preg_match("/[.\\/]/",$l)) ? $link : str_replace("$l","$g$l",$link); } ## lazy web links (an alternative to the one from Pm) Markup('lazyweb','@wikilink',"/\\b($GroupPattern([\\/.]))?($WikiWordPattern)/e", "Keep(WikiLinkSpaced(\$pagename,'$0'),'L')"); $SpaceWikiWords = 1; $AsSpacedFunction = 'SpaceWikiWords'; $SpaceWikiWordsFunction = 'SpaceWikiWords'; $RecentChangesFmt = array( 'Main.AllRecentChanges' => '* [[$Group.$Title]] . . . $CurrentTime by $AuthorLink', '$Group.RecentChanges' => '* [[$Group/$Title]] . . . $CurrentTime by $AuthorLink'); $DefaultPageTextFmt = 'Describe [[$Group/$Title]] here.'; $FPLByGroupIFmt = "
\$Title
"; $StopList = array( 'A', 'An', 'And', 'But', 'By', 'For', 'From', 'In', 'Is', 'It', 'Of', 'On', 'Or', 'The', 'To', ); $UnspacedList = array( 'Mac ', 'Mc ', 'Pm Wiki', 'Side Bar' ); function SpaceWikiWords($text) { global $StopList,$UnspacedList; # $text = AsSpaced($text); $text = preg_replace('/([[:lower:]])([[:upper:]\\d])/','$1 $2',$text); $text = preg_replace('/([[:upper:]\\d])([[:upper:]][[:lower:]\\d])/', '$1 $2',$text); foreach((array)$StopList as $s) $text = preg_replace("/(\\s$s\\s)/e","strtolower('$1')",$text); foreach((array)$UnspacedList as $u) $text = str_replace($u,str_replace(' ','',$u),$text); return $text; } function WikiLinkSpaced($pagename,$word) { global $LinkWikiWords,$SpaceWikiWords,$SpaceWikiWordsFunction; $word = ($SpaceWikiWords) ? $SpaceWikiWordsFunction($word) : $word; $text = preg_replace('!.*/!','',$word); if (!$LinkWikiWords) return $text; return MakeLink($pagename,$word,$text); } ## smart quotes Markup('',')/",' $1'); Markup('squo','>style',"/(<.*?>['\"]*)|(.?['\"]+)/e", "BypassHTML(PSS('$1'),PSS('$2'))"); Markup('sq|','>inline',"/(\\[\\[[^|\\]]+\\|)(.*?)(\\]\\])/e", "'$1'.SmartenLinkText(PSS('$2')).'$3'"); Markup('sq->','>inline',"/(\\[\\[)([^\\]]+?)(-+>.*?\\]\\])/e", "'$1'.SmartenLinkText(PSS('$2')).'$3'"); function SmartenLinkText($txt) { global $LinkPattern,$UrlExcludeChars,$ImgExtPattern; if (!preg_match("/($LinkPattern)([^$UrlExcludeChars]+$ImgExtPattern)/",$txt)) $txt = preg_replace("/(<.*?>['\"]*)|(.?['\"]+)/e", "BypassHTML(PSS('$1'),PSS('$2'))",$txt); return $txt; } function BypassHTML($hstring,$qstring) { if ($qstring=='') { $qstring = preg_replace("/.*>/",'',$hstring); $hstr = preg_replace("/>.*/",'>',$hstring); if ($qstring=='') return $hstr; else { if (strstr($hstr," '...', "/\\[\\[([^|\\]]+)\\|\\s*(.*?)\\]\\]($SuffixPattern)/e" => "MakeLink(\$pagename,PSS('$1'),PSS('$2'),'$3','\$LinkText')", "/\\[\\[([^\\]]+?)\\s*-+>\\s*(.*?)\\]\\]($SuffixPattern)/e" => "MakeLink(\$pagename,PSS('$2'),PSS('$1'),'$3','\$LinkText')", '/\\[\\[#([A-Za-z][-.:\\w]*)\\]\\]/' => "", "/\\[\\[(.*?)\\]\\]($SuffixPattern)/e" => "MakeLink(\$pagename,PSS('$1'),NULL,'$2','\$LinkText')", '/[\\[\\{](.*?)\\|(.*?)[\\]\\}]/' => '$1', "/`(($GroupPattern([\\/.]))?($WikiWordPattern))/" => '$1' ); $oLinkPageFunction = $LinkFunctions['<:page>']; $LinkFunctions['<:page>'] = 'LinkPageTitle'; $LinkPageSelfFmt = "\$LinkText"; $LinkPageExistsTitleFmt = "\$LinkText"; function LinkPageTitle($pagename,$imap,$path,$title,$txt,$fmt=NULL) { global $oLinkPageFunction,$LinkPageExistsTitleFmt,$UrlExcludeChars; if ($fmt!='') return $oLinkPageFunction($pagename,$imap,$path,$title,$txt,$fmt); if (preg_match("/^([^#?]+)(?:#([^\\s$UrlExcludeChars]*))?$/",$path,$match)) { $tgtname = MakePageName($pagename,$match[1]); $anch=@$match[2]; if (PageExists($tgtname) && $tgtname!=$pagename) { $title = TitleParagraph($tgtname,$anch); if ($title) { $title = (strstr($title,"'")) ? '"'.$title.'"' : "'$title'"; $fmt = str_replace('$ToolTip',$title,$LinkPageExistsTitleFmt); } } } return $oLinkPageFunction($pagename,$imap,$path,$title,$txt,$fmt); } function TitleParagraph($pagename,$anch) { global $LinkCleanser, $WikiStylePattern, $ParaBadAnchorFmt; $refpage = ReadPage($pagename); $para = ''; $title = ($anch=='') ? preg_match("/^(?:!+|:.*?:)\\s*(?:\\[\\[#.*?\\]\\])?([^\\n]+)/", $refpage['text'],$match) : preg_match("/\\[\\[#+$anch\\]\\]\\n?([^\\n]+)/", $refpage['text'],$match); if ($title) { $para = preg_replace("/!.*?$/",'',$match[1]); $para = preg_replace("/(''+|@@)(.*?)\\1/",'$2',$para); $para = preg_replace("/'([-_^;+\\/])(.*?)\\1'/",'$2',$para); $para = preg_replace("/\\[([@=]|[-+]+)(.*?)\\1\\]/",'$2',$para); $para = preg_replace("/$WikiStylePattern/",'',$para); foreach ($LinkCleanser as $p => $c) $para = preg_replace($p,$c,$para); $para = str_replace('"','"',str_replace('`','',$para)); } elseif ($anch!='') $para = str_replace("'''","'", str_replace('$Anchor',$anch,FmtPageName($ParaBadAnchorFmt,$pagename))); return $para; } ## ||table attributes Markup('^||','>^||||','/^\\|\\|(.*)$/e', "PZZ(\$GLOBALS['BlockMarkups']['table'][0] = PSS(''))"); function QuoteAttrs($attr) { return preg_replace('/([a-zA-Z])\\s*=\\s*([^\'"]\\S*)/',"\$1='\$2'",$attr); } /* # superseded items ## category markup SDV($CategoryGroup,'Category'); Markup('[[!','<[[','/\[\[!(.*?)\]\]/',"[[$CategoryGroup/$1]]"); */ ?>