Blame
Date:
Sat Aug 13 04:00:24 2022 UTC
Message:
Daily backup
001
2021-12-17
jrmu
<?php if (!defined('PmWiki')) exit();
002
2021-12-17
jrmu
/* Copyright 2004-2020 Patrick R. Michaud (pmichaud@pobox.com)
003
2021-12-17
jrmu
This file is part of PmWiki; you can redistribute it and/or modify
004
2021-12-17
jrmu
it under the terms of the GNU General Public License as published
005
2021-12-17
jrmu
by the Free Software Foundation; either version 2 of the License, or
006
2021-12-17
jrmu
(at your option) any later version. See pmwiki.php for full details.
007
2021-12-17
jrmu
008
2021-12-17
jrmu
This script defines PmWiki's standard markup. It is automatically
009
2021-12-17
jrmu
included from stdconfig.php unless $EnableStdMarkup==0.
010
2021-12-17
jrmu
011
2021-12-17
jrmu
Each call to Markup() below adds a new rule to PmWiki's translation
012
2021-12-17
jrmu
engine (unless a rule with the same name has already been defined).
013
2021-12-17
jrmu
The form of the call is Markup($id,$where,$pat,$rep);
014
2021-12-17
jrmu
$id is a unique name for the rule, $where is the position of the rule
015
2021-12-17
jrmu
relative to another rule, $pat is the pattern to look for, and
016
2021-12-17
jrmu
$rep is the string to replace it with.
017
2021-12-17
jrmu
018
2021-12-17
jrmu
Script maintained by Petko YOTOV www.pmwiki.org/petko
019
2021-12-17
jrmu
*/
020
2021-12-17
jrmu
021
2021-12-17
jrmu
## first we preserve text in [=...=] and [@...@]
022
2021-12-17
jrmu
function PreserveText($sigil, $text, $lead) {
023
2021-12-17
jrmu
if ($sigil=='=') return $lead.Keep($text);
024
2021-12-17
jrmu
if (strpos($text, "\n")===false)
025
2021-12-17
jrmu
return "$lead<code class='escaped'>".Keep($text)."</code>";
026
2021-12-17
jrmu
$text = preg_replace("/\n[^\\S\n]+$/", "\n", $text);
027
2021-12-17
jrmu
if ($lead == "" || $lead == "\n")
028
2021-12-17
jrmu
return "$lead<pre class='escaped'>".Keep($text)."</pre>";
029
2021-12-17
jrmu
return "$lead<:pre,1>".Keep($text);
030
2021-12-17
jrmu
}
031
2021-12-17
jrmu
032
2021-12-17
jrmu
Markup('[=','_begin',"/(\n[^\\S\n]*)?\\[([=@])(.*?)\\2\\]/s",
033
2021-12-17
jrmu
"MarkupPreserveText");
034
2021-12-17
jrmu
function MarkupPreserveText($m) {return PreserveText($m[2], $m[3], $m[1]);}
035
2021-12-17
jrmu
036
2021-12-17
jrmu
Markup('restore','<_end',"/$KeepToken(\\d.*?)$KeepToken/", 'cb_expandkpv');
037
2021-12-17
jrmu
Markup('<:', '>restore', '/<:[^>]*>/', '');
038
2021-12-17
jrmu
Markup('<vspace>', '<restore',
039
2021-12-17
jrmu
'/<vspace>/',
040
2021-12-17
jrmu
"<div class='vspace'></div>");
041
2021-12-17
jrmu
Markup('<vspace><p>', '<<vspace>',
042
2021-12-17
jrmu
"/<vspace><p\\b(([^>]*)(\\s)class=(['\"])([^>]*?)\\4)?/",
043
2021-12-17
jrmu
"<p$2 class='vspace$3$5'");
044
2021-12-17
jrmu
045
2021-12-17
jrmu
## remove carriage returns before preserving text
046
2021-12-17
jrmu
Markup('\\r','<[=','/\\r/','');
047
2021-12-17
jrmu
048
2021-12-17
jrmu
# $[phrase] substitutions
049
2021-12-17
jrmu
Markup('$[phrase]', '>[=',
050
2021-12-17
jrmu
'/\\$\\[(?>([^\\]]+))\\]/', "cb_expandxlang");
051
2021-12-17
jrmu
052
2021-12-17
jrmu
# {$var} substitutions
053
2021-12-17
jrmu
Markup('{$var}', '>$[phrase]',
054
2021-12-17
jrmu
'/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?\\w[-\\w]*)\\}/',
055
2021-12-17
jrmu
"MarkupPageVar");
056
2021-12-17
jrmu
function MarkupPageVar($m){
057
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
058
2021-12-17
jrmu
return PRR(PVSE(PageVar($pagename, $m[2], $m[1])));
059
2021-12-17
jrmu
}
060
2021-12-17
jrmu
061
2021-12-17
jrmu
# invisible (:textvar:...:) definition
062
2021-12-17
jrmu
Markup('textvar:', '<split',
063
2021-12-17
jrmu
'/\\(: *\\w[-\\w]* *:(?!\\)).*?:\\)/s', '');
064
2021-12-17
jrmu
065
2021-12-17
jrmu
## handle relative text vars in includes
066
2021-12-17
jrmu
if (IsEnabled($EnableRelativePageVars, 1))
067
2021-12-17
jrmu
SDV($QualifyPatterns["/\\{([-\\w\\x80-\\xfe]*)(\\$:?\\w+\\})/"],
068
2021-12-17
jrmu
'cb_qualifypat');
069
2021-12-17
jrmu
070
2021-12-17
jrmu
function cb_qualifypat($m) {
071
2021-12-17
jrmu
extract($GLOBALS["tmp_qualify"]);
072
2021-12-17
jrmu
return '{' . ($m[1] ? MakePageName($pagename, $m[1]) : $pagename) . $m[2];
073
2021-12-17
jrmu
}
074
2021-12-17
jrmu
075
2021-12-17
jrmu
## character entities
076
2021-12-17
jrmu
Markup('&','<if','/&amp;(?>([A-Za-z0-9]+|#\\d+|#[xX][A-Fa-f0-9]+));/',
077
2021-12-17
jrmu
'&$1;');
078
2021-12-17
jrmu
Markup('&amp;amp;', '<&', '/&amp;amp;/', Keep('&amp;'));
079
2021-12-17
jrmu
080
2021-12-17
jrmu
081
2021-12-17
jrmu
## (:if:)/(:elseif:)/(:else:)
082
2021-12-17
jrmu
SDV($CondTextPattern,
083
2021-12-17
jrmu
"/ \\(:if (\d*) (?:end)? \\b[^\n]*?:\\)
084
2021-12-17
jrmu
.*?
085
2021-12-17
jrmu
(?: \\(: (?:if\\1|if\\1end) \\s* :\\)
086
2021-12-17
jrmu
| (?=\\(:(?:if\\1|if\\1end)\\b[^\n]*?:\\) | $)
087
2021-12-17
jrmu
)
088
2021-12-17
jrmu
/six");
089
2021-12-17
jrmu
// SDV($CondTextReplacement, "CondText2(\$pagename, \$m[0], \$m[1])");
090
2021-12-17
jrmu
SDV($CondTextReplacement, "MarkupCondText2");
091
2021-12-17
jrmu
Markup('if', 'fulltext', $CondTextPattern, $CondTextReplacement);
092
2021-12-17
jrmu
093
2021-12-17
jrmu
function MarkupCondText2($m) {
094
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
095
2021-12-17
jrmu
return CondText2($pagename, $m[0], $m[1]);
096
2021-12-17
jrmu
}
097
2021-12-17
jrmu
function CondText2($pagename, $text, $code = '') {
098
2021-12-17
jrmu
global $Conditions, $CondTextPattern, $CondTextReplacement;
099
2021-12-17
jrmu
$if = "if$code";
100
2021-12-17
jrmu
$repl = str_replace('$pagename', "'$pagename'", $CondTextReplacement);
101
2021-12-17
jrmu
102
2021-12-17
jrmu
$parts = preg_split("/\\(:(?:{$if}end|$if|else *$if|else$code)\\b\\s*(.*?)\\s*:\\)/",
103
2021-12-17
jrmu
$text, -1, PREG_SPLIT_DELIM_CAPTURE);
104
2021-12-17
jrmu
$x = array_shift($parts);
105
2021-12-17
jrmu
while ($parts) {
106
2021-12-17
jrmu
list($condspec, $condtext) = array_splice($parts, 0, 2);
107
2021-12-17
jrmu
if (!preg_match("/^\\s*(!?)\\s*(\\S*)\\s*(.*?)\\s*$/", $condspec, $match)) continue;
108
2021-12-17
jrmu
list($x, $not, $condname, $condparm) = $match;
109
2021-12-17
jrmu
110
2021-12-17
jrmu
if (!isset($Conditions[$condname]))
111
2021-12-17
jrmu
return preg_replace_callback($CondTextPattern, $repl, $condtext);
112
2021-12-17
jrmu
$tf = @eval("return ({$Conditions[$condname]});");
113
2021-12-17
jrmu
if ($tf xor $not)
114
2021-12-17
jrmu
return preg_replace_callback($CondTextPattern, $repl, $condtext);
115
2021-12-17
jrmu
}
116
2021-12-17
jrmu
return '';
117
2021-12-17
jrmu
}
118
2021-12-17
jrmu
119
2021-12-17
jrmu
120
2021-12-17
jrmu
## (:include:)
121
2021-12-17
jrmu
Markup('include', '>if',
122
2021-12-17
jrmu
'/\\(:include\\s+(\\S.*?):\\)/i',
123
2021-12-17
jrmu
"MarkupRedirectInclude");
124
2021-12-17
jrmu
125
2021-12-17
jrmu
## (:redirect:)
126
2021-12-17
jrmu
Markup('redirect', '<include',
127
2021-12-17
jrmu
'/\\(:redirect\\s+(\\S.*?):\\)/i',
128
2021-12-17
jrmu
"MarkupRedirectInclude");
129
2021-12-17
jrmu
130
2021-12-17
jrmu
function MarkupRedirectInclude($m) {
131
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
132
2021-12-17
jrmu
switch ($markupid) {
133
2021-12-17
jrmu
case 'include': return PRR(IncludeText($pagename, $m[1]));
134
2021-12-17
jrmu
case 'redirect': return RedirectMarkup($pagename, $m[1]);
135
2021-12-17
jrmu
}
136
2021-12-17
jrmu
}
137
2021-12-17
jrmu
$SaveAttrPatterns['/\\(:(if\\d*|include|redirect)(\\s.*?)?:\\)/i'] = ' ';
138
2021-12-17
jrmu
139
2021-12-17
jrmu
## GroupHeader/GroupFooter handling
140
2021-12-17
jrmu
Markup('nogroupheader', '>include',
141
2021-12-17
jrmu
'/\\(:nogroupheader:\\)/i',
142
2021-12-17
jrmu
"MarkupGroupHeaderFooter");
143
2021-12-17
jrmu
Markup('nogroupfooter', '>include',
144
2021-12-17
jrmu
'/\\(:nogroupfooter:\\)/i',
145
2021-12-17
jrmu
"MarkupGroupHeaderFooter");
146
2021-12-17
jrmu
Markup('groupheader', '>nogroupheader',
147
2021-12-17
jrmu
'/\\(:groupheader:\\)/i',
148
2021-12-17
jrmu
"MarkupGroupHeaderFooter");
149
2021-12-17
jrmu
Markup('groupfooter','>nogroupfooter',
150
2021-12-17
jrmu
'/\\(:groupfooter:\\)/i',
151
2021-12-17
jrmu
"MarkupGroupHeaderFooter");
152
2021-12-17
jrmu
153
2021-12-17
jrmu
function MarkupGroupHeaderFooter($m) {
154
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
155
2021-12-17
jrmu
global $GroupHeaderFmt, $GroupFooterFmt;
156
2021-12-17
jrmu
switch ($markupid) {
157
2021-12-17
jrmu
case 'nogroupheader': return PZZ($GroupHeaderFmt='');
158
2021-12-17
jrmu
case 'nogroupfooter': return PZZ($GroupFooterFmt='');
159
2021-12-17
jrmu
case 'groupheader': return PRR(FmtPageName($GroupHeaderFmt,$pagename));
160
2021-12-17
jrmu
case 'groupfooter': return PRR(FmtPageName($GroupFooterFmt,$pagename));
161
2021-12-17
jrmu
}
162
2021-12-17
jrmu
}
163
2021-12-17
jrmu
## (:nl:)
164
2021-12-17
jrmu
Markup('nl0','<split',"/([^\n])(?>(?:\\(:nl:\\))+)([^\n])/i","$1\n$2");
165
2021-12-17
jrmu
Markup('nl1','>nl0',"/\\(:nl:\\)/i",'');
166
2021-12-17
jrmu
167
2021-12-17
jrmu
## \\$ (end of line joins)
168
2021-12-17
jrmu
Markup('\\$','>nl1',"/\\\\(?>(\\\\*))\n/", "MarkupEndLineJoin");
169
2021-12-17
jrmu
function MarkupEndLineJoin($m) { return str_repeat('<br />',strlen($m[1])); }
170
2021-12-17
jrmu
171
2021-12-17
jrmu
## Remove one <:vspace> after !headings
172
2021-12-17
jrmu
Markup('!vspace', '>\\$', "/^(!(?>[^\n]+)\n)<:vspace>/m", '$1');
173
2021-12-17
jrmu
174
2021-12-17
jrmu
## (:noheader:),(:nofooter:),(:notitle:)...
175
2021-12-17
jrmu
Markup('noheader', 'directives', '/\\(:noheader:\\)/i', "MarkupTmplDisplay");
176
2021-12-17
jrmu
Markup('nofooter', 'directives', '/\\(:nofooter:\\)/i', "MarkupTmplDisplay");
177
2021-12-17
jrmu
Markup('notitle', 'directives', '/\\(:notitle:\\)/i', "MarkupTmplDisplay");
178
2021-12-17
jrmu
Markup('noleft', 'directives', '/\\(:noleft:\\)/i', "MarkupTmplDisplay");
179
2021-12-17
jrmu
Markup('noright', 'directives', '/\\(:noright:\\)/i', "MarkupTmplDisplay");
180
2021-12-17
jrmu
Markup('noaction', 'directives', '/\\(:noaction:\\)/i', "MarkupTmplDisplay");
181
2021-12-17
jrmu
182
2021-12-17
jrmu
function MarkupTmplDisplay($m) {
183
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
184
2021-12-17
jrmu
switch ($markupid) {
185
2021-12-17
jrmu
case 'noheader': return SetTmplDisplay('PageHeaderFmt',0);
186
2021-12-17
jrmu
case 'nofooter': return SetTmplDisplay('PageFooterFmt',0);
187
2021-12-17
jrmu
case 'notitle': return SetTmplDisplay('PageTitleFmt',0);
188
2021-12-17
jrmu
case 'noleft': return SetTmplDisplay('PageLeftFmt',0);
189
2021-12-17
jrmu
case 'noright': return SetTmplDisplay('PageRightFmt',0);
190
2021-12-17
jrmu
case 'noaction': return SetTmplDisplay('PageActionFmt',0);
191
2021-12-17
jrmu
}
192
2021-12-17
jrmu
}
193
2021-12-17
jrmu
194
2021-12-17
jrmu
## (:spacewikiwords:)
195
2021-12-17
jrmu
Markup('spacewikiwords', 'directives',
196
2021-12-17
jrmu
'/\\(:(no)?spacewikiwords:\\)/i',
197
2021-12-17
jrmu
"MarkupDirectives");
198
2021-12-17
jrmu
199
2021-12-17
jrmu
## (:linkwikiwords:)
200
2021-12-17
jrmu
Markup('linkwikiwords', 'directives',
201
2021-12-17
jrmu
'/\\(:(no)?linkwikiwords:\\)/i',
202
2021-12-17
jrmu
"MarkupDirectives");
203
2021-12-17
jrmu
204
2021-12-17
jrmu
## (:linebreaks:)
205
2021-12-17
jrmu
Markup('linebreaks', 'directives',
206
2021-12-17
jrmu
'/\\(:(no)?linebreaks:\\)/i',
207
2021-12-17
jrmu
"MarkupDirectives");
208
2021-12-17
jrmu
209
2021-12-17
jrmu
## (:messages:)
210
2021-12-17
jrmu
Markup('messages', 'directives',
211
2021-12-17
jrmu
'/^\\(:messages:\\)/i',
212
2021-12-17
jrmu
"MarkupDirectives");
213
2021-12-17
jrmu
214
2021-12-17
jrmu
function MarkupDirectives($m) {
215
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
216
2021-12-17
jrmu
switch ($markupid) {
217
2021-12-17
jrmu
case 'linkwikiwords': return PZZ($GLOBALS['LinkWikiWords']=($m[1]!='no'));
218
2021-12-17
jrmu
case 'spacewikiwords': return PZZ($GLOBALS['SpaceWikiWords']=($m[1]!='no'));
219
2021-12-17
jrmu
case 'linebreaks':
220
2021-12-17
jrmu
return PZZ($GLOBALS['HTMLPNewline'] = (@$m[1]!='no') ? '<br />' : '');
221
2021-12-17
jrmu
case 'messages':
222
2021-12-17
jrmu
return '<:block>'.Keep(FmtPageName(
223
2021-12-17
jrmu
implode('',(array)$GLOBALS['MessagesFmt']), $pagename));
224
2021-12-17
jrmu
}
225
2021-12-17
jrmu
}
226
2021-12-17
jrmu
227
2021-12-17
jrmu
228
2021-12-17
jrmu
## (:comment:)
229
2021-12-17
jrmu
Markup('comment', 'directives', '/\\(:comment .*?:\\)/i', '');
230
2021-12-17
jrmu
231
2021-12-17
jrmu
## (:title:) +fix for PITS:00266, 00779
232
2021-12-17
jrmu
$tmpwhen = IsEnabled($EnablePageTitlePriority, 0) ? '<include' : 'directives';
233
2021-12-17
jrmu
Markup('title', $tmpwhen,
234
2021-12-17
jrmu
'/\\(:title\\s(.*?):\\)/i',
235
2021-12-17
jrmu
"MarkupSetProperty");
236
2021-12-17
jrmu
unset($tmpwhen);
237
2021-12-17
jrmu
238
2021-12-17
jrmu
function MarkupSetProperty($m){ # title, description, keywords
239
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
240
2021-12-17
jrmu
switch ($markupid) {
241
2021-12-17
jrmu
case 'title':
242
2021-12-17
jrmu
global $EnablePageTitlePriority;
243
2021-12-17
jrmu
return PZZ(PCache($pagename, $zz=array('title' =>
244
2021-12-17
jrmu
SetProperty($pagename, 'title', $m[1], NULL, $EnablePageTitlePriority))));
245
2021-12-17
jrmu
case 'keywords':
246
2021-12-17
jrmu
return PZZ(SetProperty($pagename, 'keywords', $m[1], ', '));
247
2021-12-17
jrmu
case 'description':
248
2021-12-17
jrmu
return PZZ(SetProperty($pagename, 'description', $m[1], '\n'));
249
2021-12-17
jrmu
}
250
2021-12-17
jrmu
}
251
2021-12-17
jrmu
252
2021-12-17
jrmu
## (:keywords:), (:description:)
253
2021-12-17
jrmu
Markup('keywords', 'directives', "/\\(:keywords?\\s+(.+?):\\)/i", "MarkupSetProperty");
254
2021-12-17
jrmu
Markup('description', 'directives', "/\\(:description\\s+(.+?):\\)/i", "MarkupSetProperty");
255
2021-12-17
jrmu
$HTMLHeaderFmt['meta'] = 'function:PrintMetaTags';
256
2021-12-17
jrmu
function PrintMetaTags($pagename, $args) {
257
2021-12-17
jrmu
global $PCache;
258
2021-12-17
jrmu
foreach(array('keywords', 'description') as $n) {
259
2021-12-17
jrmu
foreach((array)@$PCache[$pagename]["=p_$n"] as $v) {
260
2021-12-17
jrmu
$v = str_replace("'", '&#039;', $v);
261
2021-12-17
jrmu
print "<meta name='$n' content='$v' />\n";
262
2021-12-17
jrmu
}
263
2021-12-17
jrmu
}
264
2021-12-17
jrmu
}
265
2021-12-17
jrmu
266
2021-12-17
jrmu
#### inline markups ####
267
2021-12-17
jrmu
## ''emphasis''
268
2021-12-17
jrmu
Markup("''",'inline',"/''(.*?)''/",'<em>$1</em>');
269
2021-12-17
jrmu
270
2021-12-17
jrmu
## '''strong'''
271
2021-12-17
jrmu
Markup("'''","<''","/'''(.*?)'''/",'<strong>$1</strong>');
272
2021-12-17
jrmu
273
2021-12-17
jrmu
## '''''strong emphasis'''''
274
2021-12-17
jrmu
Markup("'''''","<'''","/'''''(.*?)'''''/",'<strong><em>$1</em></strong>');
275
2021-12-17
jrmu
276
2021-12-17
jrmu
## @@code@@
277
2021-12-17
jrmu
Markup('@@','inline','/@@(.*?)@@/','<code>$1</code>');
278
2021-12-17
jrmu
279
2021-12-17
jrmu
## '+big+', '-small-'
280
2021-12-17
jrmu
Markup("'+","<'''''","/'\\+(.*?)\\+'/",'<big>$1</big>');
281
2021-12-17
jrmu
Markup("'-","<'''''","/'\\-(.*?)\\-'/",'<small>$1</small>');
282
2021-12-17
jrmu
283
2021-12-17
jrmu
## '^superscript^', '_subscript_'
284
2021-12-17
jrmu
Markup("'^","<'''''","/'\\^(.*?)\\^'/",'<sup>$1</sup>');
285
2021-12-17
jrmu
Markup("'_","<'''''","/'_(.*?)_'/",'<sub>$1</sub>');
286
2021-12-17
jrmu
287
2021-12-17
jrmu
## [+big+], [-small-]
288
2021-12-17
jrmu
Markup('[+','inline','/\\[(([-+])+)(.*?)\\1\\]/',
289
2021-12-17
jrmu
"MarkupBigSmall");
290
2021-12-17
jrmu
291
2021-12-17
jrmu
function MarkupBigSmall($m) {
292
2021-12-17
jrmu
return '<span style=\'font-size:'
293
2021-12-17
jrmu
.(round(pow(6/5,($m[2]=='-'? -1:1)*strlen($m[1]))*100,0))
294
2021-12-17
jrmu
.'%\'>'. $m[3].'</span>';
295
2021-12-17
jrmu
}
296
2021-12-17
jrmu
297
2021-12-17
jrmu
## {+ins+}, {-del-}
298
2021-12-17
jrmu
Markup('{+','inline','/\\{\\+(.*?)\\+\\}/','<ins>$1</ins>');
299
2021-12-17
jrmu
Markup('{-','inline','/\\{-(.*?)-\\}/','<del>$1</del>');
300
2021-12-17
jrmu
301
2021-12-17
jrmu
## [[<<]] (break)
302
2021-12-17
jrmu
Markup('[[<<]]','inline','/\\[\\[&lt;&lt;\\]\\]/',"<br clear='all' />");
303
2021-12-17
jrmu
304
2021-12-17
jrmu
###### Links ######
305
2021-12-17
jrmu
function MarkupLinks($m){
306
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
307
2021-12-17
jrmu
switch ($markupid) {
308
2021-12-17
jrmu
case '[[':
309
2021-12-17
jrmu
return Keep(MakeLink($pagename,$m[1],NULL,$m[2]),'L');
310
2021-12-17
jrmu
case '[[!':
311
2021-12-17
jrmu
global $CategoryGroup, $LinkCategoryFmt;
312
2021-12-17
jrmu
return Keep(MakeLink($pagename,"$CategoryGroup/{$m[1]}",NULL,'',
313
2021-12-17
jrmu
$LinkCategoryFmt),'L');
314
2021-12-17
jrmu
case '[[|':
315
2021-12-17
jrmu
return Keep(MakeLink($pagename,$m[1],$m[2],$m[3]),'L');
316
2021-12-17
jrmu
case '[[->':
317
2021-12-17
jrmu
return Keep(MakeLink($pagename,$m[2],$m[1],$m[3]),'L');
318
2021-12-17
jrmu
case '[[|#':
319
2021-12-17
jrmu
return Keep(MakeLink($pagename,$m[1],
320
2021-12-17
jrmu
'['.++$GLOBALS['MarkupFrame'][0]['ref'].']'),'L');
321
2021-12-17
jrmu
case '[[#':
322
2021-12-17
jrmu
return Keep(TrackAnchors($m[1]) ? '' : "<a name='{$m[1]}' id='{$m[1]}'></a>", 'L');
323
2021-12-17
jrmu
case 'urllink':
324
2021-12-17
jrmu
return Keep(MakeLink($pagename,$m[0],$m[0]),'L');
325
2021-12-17
jrmu
case 'mailto':
326
2021-12-17
jrmu
return Keep(MakeLink($pagename,$m[0],$m[1]),'L');
327
2021-12-17
jrmu
case 'img':
328
2021-12-17
jrmu
global $LinkFunctions, $ImgTagFmt;
329
2021-12-17
jrmu
return Keep($LinkFunctions[$m[1]]($pagename,$m[1],$m[2],@$m[4],$m[1].$m[2],
330
2021-12-17
jrmu
$ImgTagFmt),'L');
331
2021-12-17
jrmu
}
332
2021-12-17
jrmu
}
333
2021-12-17
jrmu
334
2021-12-17
jrmu
## [[free links]]
335
2021-12-17
jrmu
Markup('[[','links',"/(?>\\[\\[\\s*(.*?)\\]\\])($SuffixPattern)/", "MarkupLinks");
336
2021-12-17
jrmu
337
2021-12-17
jrmu
## [[!Category]]
338
2021-12-17
jrmu
SDV($CategoryGroup,'Category');
339
2021-12-17
jrmu
SDV($LinkCategoryFmt,"<a class='categorylink' href='\$LinkUrl'>\$LinkText</a>");
340
2021-12-17
jrmu
Markup('[[!','<[[','/\\[\\[!(.*?)\\]\\]/', "MarkupLinks");
341
2021-12-17
jrmu
# This is a temporary workaround for blank category pages.
342
2021-12-17
jrmu
# It may be removed in a future release (Pm, 2006-01-24)
343
2021-12-17
jrmu
if (preg_match("/^$CategoryGroup\\./", $pagename)) {
344
2021-12-17
jrmu
SDV($DefaultPageTextFmt, '');
345
2021-12-17
jrmu
SDV($PageNotFoundHeaderFmt, 'HTTP/1.1 200 Ok');
346
2021-12-17
jrmu
}
347
2021-12-17
jrmu
348
2021-12-17
jrmu
## [[target | text]]
349
2021-12-17
jrmu
Markup('[[|','<[[',
350
2021-12-17
jrmu
"/(?>\\[\\[([^|\\]]*)\\|\\s*)(.*?)\\s*\\]\\]($SuffixPattern)/",
351
2021-12-17
jrmu
"MarkupLinks");
352
2021-12-17
jrmu
353
2021-12-17
jrmu
## [[text -> target ]]
354
2021-12-17
jrmu
Markup('[[->','>[[|',
355
2021-12-17
jrmu
"/(?>\\[\\[([^\\]]+?)\\s*-+&gt;\\s*)(.*?)\\]\\]($SuffixPattern)/",
356
2021-12-17
jrmu
"MarkupLinks");
357
2021-12-17
jrmu
358
2021-12-17
jrmu
## [[#anchor]]
359
2021-12-17
jrmu
Markup('[[#','<[[','/(?>\\[\\[#([A-Za-z][-.:\\w]*))\\]\\]/', "MarkupLinks");
360
2021-12-17
jrmu
function TrackAnchors($x) { global $SeenAnchor; return @$SeenAnchor[$x]++; }
361
2021-12-17
jrmu
362
2021-12-17
jrmu
## [[target |#]] reference links
363
2021-12-17
jrmu
Markup('[[|#', '<[[|',
364
2021-12-17
jrmu
"/(?>\\[\\[([^|\\]]+))\\|\\s*#\\s*\\]\\]/",
365
2021-12-17
jrmu
"MarkupLinks");
366
2021-12-17
jrmu
367
2021-12-17
jrmu
## [[target |+]] title links moved inside LinkPage()
368
2021-12-17
jrmu
369
2021-12-17
jrmu
## bare urllinks
370
2021-12-17
jrmu
Markup('urllink','>[[',
371
2021-12-17
jrmu
"/\\b(?>(\\L))[^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars]/",
372
2021-12-17
jrmu
"MarkupLinks");
373
2021-12-17
jrmu
374
2021-12-17
jrmu
## mailto: links
375
2021-12-17
jrmu
Markup('mailto','<urllink',
376
2021-12-17
jrmu
"/\\bmailto:([^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars])/",
377
2021-12-17
jrmu
"MarkupLinks");
378
2021-12-17
jrmu
379
2021-12-17
jrmu
## inline images
380
2021-12-17
jrmu
Markup('img','<urllink',
381
2021-12-17
jrmu
"/\\b(?>(\\L))([^\\s$UrlExcludeChars]+$ImgExtPattern)(\"([^\"]*)\")?/",
382
2021-12-17
jrmu
"MarkupLinks");
383
2021-12-17
jrmu
384
2021-12-17
jrmu
if (IsEnabled($EnableRelativePageLinks, 1))
385
2021-12-17
jrmu
SDV($QualifyPatterns['/(\\[\\[(?>[^\\]]+?->)?\\s*)([-\\w\\x80-\\xfe\\s\'()]+([|#?].*?)?\\]\\])/'],
386
2021-12-17
jrmu
'cb_qualifylinks');
387
2021-12-17
jrmu
388
2021-12-17
jrmu
function cb_qualifylinks($m) {
389
2021-12-17
jrmu
extract($GLOBALS['tmp_qualify']);
390
2021-12-17
jrmu
return "{$m[1]}$group/{$m[2]}";
391
2021-12-17
jrmu
}
392
2021-12-17
jrmu
393
2021-12-17
jrmu
## bare wikilinks
394
2021-12-17
jrmu
## v2.2: markup rule moved to scripts/wikiwords.php)
395
2021-12-17
jrmu
Markup('wikilink', '>urllink');
396
2021-12-17
jrmu
397
2021-12-17
jrmu
## escaped `WikiWords
398
2021-12-17
jrmu
## v2.2: rule kept here for markup compatibility with 2.1 and earlier
399
2021-12-17
jrmu
Markup('`wikiword', '<wikilink',
400
2021-12-17
jrmu
"/`(($GroupPattern([\\/.]))?($WikiWordPattern))/",
401
2021-12-17
jrmu
"MarkupNoWikiWord");
402
2021-12-17
jrmu
function MarkupNoWikiWord($m) { return Keep($m[1]); }
403
2021-12-17
jrmu
404
2021-12-17
jrmu
#### Block markups ####
405
2021-12-17
jrmu
## Completely blank lines don't do anything.
406
2021-12-17
jrmu
Markup('blank', '<block', '/^\\s+$/', '');
407
2021-12-17
jrmu
408
2021-12-17
jrmu
## process any <:...> markup (after all other block markups)
409
2021-12-17
jrmu
Markup('^<:','>block','/^(?=\\s*\\S)(<:([^>]+)>)?/',"MarkupBlock");
410
2021-12-17
jrmu
function MarkupBlock($m) {return Block(@$m[2]);}
411
2021-12-17
jrmu
412
2021-12-17
jrmu
## unblocked lines w/block markup become anonymous <:block>
413
2021-12-17
jrmu
Markup('^!<:', '<^<:',
414
2021-12-17
jrmu
"/^(?!<:)(?=.*(<\\/?($BlockPattern)\\b)|$KeepToken\\d+B$KeepToken)/",
415
2021-12-17
jrmu
'<:block>');
416
2021-12-17
jrmu
417
2021-12-17
jrmu
## Lines that begin with displayed images receive their own block. A
418
2021-12-17
jrmu
## pipe following the image indicates a "caption" (generates a linebreak).
419
2021-12-17
jrmu
Markup('^img', 'block',
420
2021-12-17
jrmu
"/^((?>(\\s+|%%|%[A-Za-z][-,=:#\\w\\s'\".]*%)*)$KeepToken(\\d+L)$KeepToken)(\\s*\\|\\s?)?(.*)$/",
421
2021-12-17
jrmu
"ImgCaptionDiv");
422
2021-12-17
jrmu
function ImgCaptionDiv($m) {
423
2021-12-17
jrmu
global $KPV;
424
2021-12-17
jrmu
if (strpos($KPV[$m[3]], '<img')===false) return $m[0];
425
2021-12-17
jrmu
$dclass = 'img';
426
2021-12-17
jrmu
$ret = $m[1];
427
2021-12-17
jrmu
if ($m[4]) {
428
2021-12-17
jrmu
$dclass .= " imgcaption";
429
2021-12-17
jrmu
$ret .= "<br /><span class='caption'>$m[5]</span>";
430
2021-12-17
jrmu
}
431
2021-12-17
jrmu
elseif (! $m[5]) $dclass .= " imgonly";
432
2021-12-17
jrmu
else $ret .= $m[5];
433
2021-12-17
jrmu
return "<:block,1><div class='$dclass'>$ret</div>";
434
2021-12-17
jrmu
}
435
2021-12-17
jrmu
436
2021-12-17
jrmu
## Whitespace at the beginning of lines can be used to maintain the
437
2021-12-17
jrmu
## indent level of a previous list item, or a preformatted text block.
438
2021-12-17
jrmu
Markup('^ws', '<^img', '/^\\s+ #1/x', "WSIndent");
439
2021-12-17
jrmu
function WSIndent($i) {
440
2021-12-17
jrmu
if(is_array($i)) $i = $i[0];
441
2021-12-17
jrmu
global $MarkupFrame;
442
2021-12-17
jrmu
$icol = strlen($i);
443
2021-12-17
jrmu
for($depth = count(@$MarkupFrame[0]['cs']); $depth > 0; $depth--)
444
2021-12-17
jrmu
if (@$MarkupFrame[0]['is'][$depth] == $icol) {
445
2021-12-17
jrmu
$MarkupFrame[0]['idep'] = $depth;
446
2021-12-17
jrmu
$MarkupFrame[0]['icol'] = $icol;
447
2021-12-17
jrmu
return '';
448
2021-12-17
jrmu
}
449
2021-12-17
jrmu
return $i;
450
2021-12-17
jrmu
}
451
2021-12-17
jrmu
452
2021-12-17
jrmu
## The $EnableWSPre setting uses leading spaces on markup lines to indicate
453
2021-12-17
jrmu
## blocks of preformatted text.
454
2021-12-17
jrmu
SDV($EnableWSPre, 1);
455
2021-12-17
jrmu
Markup('^ ', 'block',
456
2021-12-17
jrmu
'/^\\s+ #2/x',
457
2021-12-17
jrmu
"MarkupWSPre");
458
2021-12-17
jrmu
function MarkupWSPre($m) {
459
2021-12-17
jrmu
global $EnableWSPre;
460
2021-12-17
jrmu
return ($EnableWSPre > 0 && strlen($m[0]) >= $EnableWSPre)
461
2021-12-17
jrmu
? '<:pre,1>'.$m[0] : $m[0];
462
2021-12-17
jrmu
}
463
2021-12-17
jrmu
## bullet lists
464
2021-12-17
jrmu
Markup('^*','block','/^(\\*+)\\s?(\\s*)/','<:ul,$1,$0>$2');
465
2021-12-17
jrmu
466
2021-12-17
jrmu
## numbered lists
467
2021-12-17
jrmu
Markup('^#','block','/^(#+)\\s?(\\s*)/','<:ol,$1,$0>$2');
468
2021-12-17
jrmu
469
2021-12-17
jrmu
## indented (->) /hanging indent (-<) text
470
2021-12-17
jrmu
Markup('^->','block','/^(?>(-+))&gt;\\s?(\\s*)/','<:indent,$1,$1 $2>$2');
471
2021-12-17
jrmu
Markup('^-<','block','/^(?>(-+))&lt;\\s?(\\s*)/','<:outdent,$1,$1 $2>$2');
472
2021-12-17
jrmu
473
2021-12-17
jrmu
## definition lists
474
2021-12-17
jrmu
Markup('^::','block','/^(:+)(\s*)([^:]+):/','<:dl,$1,$1$2><dt>$2$3</dt><dd>');
475
2021-12-17
jrmu
476
2021-12-17
jrmu
## Q: and A:
477
2021-12-17
jrmu
Markup('^Q:', 'block', '/^Q:(.*)$/', "<:block,1><p class='question'>$1</p>");
478
2021-12-17
jrmu
Markup('^A:', 'block', '/^A:/', Keep(''));
479
2021-12-17
jrmu
480
2021-12-17
jrmu
## tables
481
2021-12-17
jrmu
function MarkupTables($m) {
482
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]);
483
2021-12-17
jrmu
switch ($markupid) {
484
2021-12-17
jrmu
case 'table': return Cells(@$m[1],@$m[2]);
485
2021-12-17
jrmu
case '^||||': return FormatTableRow($m[0]);
486
2021-12-17
jrmu
case '^||':
487
2021-12-17
jrmu
$GLOBALS['BlockMarkups']['table'][0] = '<table '.SimpleTableAttr($m[1]).'>';
488
2021-12-17
jrmu
return '<:block,1>';
489
2021-12-17
jrmu
}
490
2021-12-17
jrmu
}
491
2021-12-17
jrmu
492
2021-12-17
jrmu
## ||cell||, ||!header cell||, ||!caption!||
493
2021-12-17
jrmu
Markup('^||||', 'block',
494
2021-12-17
jrmu
'/^\\|\\|.*\\|\\|.*$/',
495
2021-12-17
jrmu
"MarkupTables");
496
2021-12-17
jrmu
## ||table attributes
497
2021-12-17
jrmu
Markup('^||','>^||||','/^\\|\\|(.*)$/',
498
2021-12-17
jrmu
"MarkupTables");
499
2021-12-17
jrmu
500
2021-12-17
jrmu
#### (:table:) markup (AdvancedTables)
501
2021-12-17
jrmu
Markup('table', '<block',
502
2021-12-17
jrmu
'/^\\(:(table|cell|cellnr|head|headnr|tableend|(?:div\\d*|section\\d*|details\\d*|article\\d*|header|footer|nav|address|aside)(?:end)?)(\\s.*?)?:\\)/i',
503
2021-12-17
jrmu
"MarkupTables");
504
2021-12-17
jrmu
Markup('^>>', '<table',
505
2021-12-17
jrmu
'/^&gt;&gt;(.+?)&lt;&lt;(.*)$/',
506
2021-12-17
jrmu
'(:div:)%div $1 apply=div%$2 ');
507
2021-12-17
jrmu
Markup('^>><<', '<^>>',
508
2021-12-17
jrmu
'/^&gt;&gt;&lt;&lt;/',
509
2021-12-17
jrmu
'(:divend:)');
510
2021-12-17
jrmu
511
2021-12-17
jrmu
function SimpleTableAttr($attr) {
512
2021-12-17
jrmu
global $SimpleTableDefaultClassName;
513
2021-12-17
jrmu
$qattr = PQA($attr);
514
2021-12-17
jrmu
if(IsEnabled($SimpleTableDefaultClassName) && !preg_match("/(^| )class='.*?' /", $qattr))
515
2021-12-17
jrmu
$qattr .= "class='$SimpleTableDefaultClassName'";
516
2021-12-17
jrmu
return $qattr;
517
2021-12-17
jrmu
}
518
2021-12-17
jrmu
519
2021-12-17
jrmu
#### (:table:) markup (AdvancedTables)
520
2021-12-17
jrmu
function Cells($name,$attr) {
521
2021-12-17
jrmu
global $MarkupFrame, $EnableTableAutoValignTop;
522
2021-12-17
jrmu
$attr = PQA($attr);
523
2021-12-17
jrmu
$tattr = @$MarkupFrame[0]['tattr'];
524
2021-12-17
jrmu
$name = strtolower($name);
525
2021-12-17
jrmu
$key = preg_replace('/end$/', '', $name);
526
2021-12-17
jrmu
if (preg_match("/^(?:head|cell)(nr)?$/", $name)) $key = 'cell';
527
2021-12-17
jrmu
$out = '<:block>'.MarkupClose($key);
528
2021-12-17
jrmu
if (substr($name, -3) == 'end') return $out;
529
2021-12-17
jrmu
$cf = & $MarkupFrame[0]['closeall'];
530
2021-12-17
jrmu
if ($name == 'table') $MarkupFrame[0]['tattr'] = $attr;
531
2021-12-17
jrmu
else if ($key == 'cell') {
532
2021-12-17
jrmu
if (IsEnabled($EnableTableAutoValignTop, 1) && strpos($attr, "valign=")===false)
533
2021-12-17
jrmu
$attr .= " valign='top'";
534
2021-12-17
jrmu
$t = (strpos($name, 'head')===0 ) ? 'th' : 'td';
535
2021-12-17
jrmu
if (!@$cf['table']) {
536
2021-12-17
jrmu
$tattr = @$MarkupFrame[0]['tattr'];
537
2021-12-17
jrmu
$out .= "<table $tattr><tr><$t $attr>";
538
2021-12-17
jrmu
$cf['table'] = '</tr></table>';
539
2021-12-17
jrmu
} else if ( preg_match("/nr$/", $name)) $out .= "</tr><tr><$t $attr>";
540
2021-12-17
jrmu
else $out .= "<$t $attr>";
541
2021-12-17
jrmu
$cf['cell'] = "</$t>";
542
2021-12-17
jrmu
} else {
543
2021-12-17
jrmu
$tag = preg_replace('/\\d+$/', '', $key);
544
2021-12-17
jrmu
$tmp = "<$tag $attr>";
545
2021-12-17
jrmu
if ($tag == 'details') {
546
2021-12-17
jrmu
$tmp = preg_replace("#(<details.*) summary='(.*?)'(.*)$#", '$1$3<summary>$2</summary>', $tmp);
547
2021-12-17
jrmu
}
548
2021-12-17
jrmu
$out .= $tmp;
549
2021-12-17
jrmu
$cf[$key] = "</$tag>";
550
2021-12-17
jrmu
}
551
2021-12-17
jrmu
return $out;
552
2021-12-17
jrmu
}
553
2021-12-17
jrmu
554
2021-12-17
jrmu
555
2021-12-17
jrmu
## headings
556
2021-12-17
jrmu
Markup('^!', 'block', '/^(!{1,6})\\s?(.*)$/', "MarkupHeadings");
557
2021-12-17
jrmu
function MarkupHeadings($m) {
558
2021-12-17
jrmu
$len = strlen($m[1]);
559
2021-12-17
jrmu
return "<:block,1><h$len>$m[2]</h$len>";
560
2021-12-17
jrmu
}
561
2021-12-17
jrmu
562
2021-12-17
jrmu
## horiz rule
563
2021-12-17
jrmu
Markup('^----','>^->','/^----+/','<:block,1><hr />');
564
2021-12-17
jrmu
565
2021-12-17
jrmu
#### special stuff ####
566
2021-12-17
jrmu
## (:markup:) for displaying markup examples
567
2021-12-17
jrmu
function MarkupMarkup($pagename, $text, $opt = '') {
568
2021-12-17
jrmu
global $MarkupWordwrapFunction, $MarkupWrapTag;
569
2021-12-17
jrmu
SDV($MarkupWordwrapFunction, 'IsEnabled');
570
2021-12-17
jrmu
SDV($MarkupWrapTag, 'pre');
571
2021-12-17
jrmu
$MarkupMarkupOpt = array('class' => 'vert');
572
2021-12-17
jrmu
$opt = array_merge($MarkupMarkupOpt, ParseArgs($opt));
573
2021-12-17
jrmu
$html = MarkupToHTML($pagename, $text, array('escape' => 0));
574
2021-12-17
jrmu
if (@$opt['caption'])
575
2021-12-17
jrmu
$caption = str_replace("'", '&#039;',
576
2021-12-17
jrmu
"<caption>{$opt['caption']}</caption>");
577
2021-12-17
jrmu
$class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']);
578
2021-12-17
jrmu
if (strpos($class, 'horiz') !== false)
579
2021-12-17
jrmu
{ $sep = ''; $pretext = $MarkupWordwrapFunction($text, 40); }
580
2021-12-17
jrmu
else
581
2021-12-17
jrmu
{ $sep = '</tr><tr>'; $pretext = $MarkupWordwrapFunction($text, 75); }
582
2021-12-17
jrmu
return Keep(@"<table class='markup $class' align='center'>$caption
583
2021-12-17
jrmu
<tr><td class='markup1' valign='top'><$MarkupWrapTag>$pretext</$MarkupWrapTag></td>$sep<td
584
2021-12-17
jrmu
class='markup2' valign='top'>$html</td></tr></table>");
585
2021-12-17
jrmu
}
586
2021-12-17
jrmu
587
2021-12-17
jrmu
Markup('markup', '<[=',
588
2021-12-17
jrmu
"/\\(:markup(\\s+([^\n]*?))?:\\)[^\\S\n]*\\[([=@])(.*?)\\3\\]/si",
589
2021-12-17
jrmu
"MarkupMarkupMarkup");
590
2021-12-17
jrmu
Markup('markupend', '>markup', # $1 only shifts the other matches
591
2021-12-17
jrmu
"/\\(:(markup)(\\s+([^\n]*?))?:\\)[^\\S\n]*\n(.*?)\\(:markupend:\\)/si",
592
2021-12-17
jrmu
"MarkupMarkupMarkup");
593
2021-12-17
jrmu
function MarkupMarkupMarkup($m) { # cannot be joined, $markupid resets
594
2021-12-17
jrmu
extract($GLOBALS["MarkupToHTML"]); global $MarkupMarkupLevel;
595
2021-12-17
jrmu
@$MarkupMarkupLevel++;
596
2021-12-17
jrmu
$x = MarkupMarkup($pagename, $m[4], $m[2]);
597
2021-12-17
jrmu
$MarkupMarkupLevel--;
598
2021-12-17
jrmu
return $x;
599
2021-12-17
jrmu
}
600
2021-12-17
jrmu
601
2021-12-17
jrmu
SDV($HTMLStylesFmt['markup'], "
602
2021-12-17
jrmu
table.markup { border:2px dotted #ccf; width:90%; }
603
2021-12-17
jrmu
td.markup1, td.markup2 { padding-left:10px; padding-right:10px; }
604
2021-12-17
jrmu
table.vert td.markup1 { border-bottom:1px solid #ccf; }
605
2021-12-17
jrmu
table.horiz td.markup1 { width:23em; border-right:1px solid #ccf; }
606
2021-12-17
jrmu
table.markup caption { text-align:left; }
607
2021-12-17
jrmu
div.faq p, div.faq pre { margin-left:2em; }
608
2021-12-17
jrmu
div.faq p.question { margin:1em 0 0.75em 0; font-weight:bold; }
609
2021-12-17
jrmu
div.faqtoc div.faq * { display:none; }
610
2021-12-17
jrmu
div.faqtoc div.faq p.question
611
2021-12-17
jrmu
{ display:block; font-weight:normal; margin:0.5em 0 0.5em 20px; line-height:normal; }
612
2021-12-17
jrmu
div.faqtoc div.faq p.question * { display:inline; }
613
2021-12-17
jrmu
td.markup1 pre { white-space: pre-wrap; }
614
2021-12-17
jrmu
");
615
2021-12-17
jrmu
616
2021-12-17
jrmu
#### Special conditions ####
617
2021-12-17
jrmu
## The code below adds (:if date:) conditions to the markup.
618
2021-12-17
jrmu
$Conditions['date'] = "CondDate(\$condparm)";
619
2021-12-17
jrmu
620
2021-12-17
jrmu
function CondDate($condparm) {
621
2021-12-17
jrmu
global $Now;
622
2021-12-17
jrmu
if (!preg_match('/^(\\S*?)(\\.\\.(\\S*))?(\\s+\\S.*)?$/',
623
2021-12-17
jrmu
trim($condparm), $match))
624
2021-12-17
jrmu
return false;
625
2021-12-17
jrmu
if ($match[4] == '') { $x0 = $Now; NoCache(); }
626
2021-12-17
jrmu
else { list($x0, $x1) = DRange($match[4]); }
627
2021-12-17
jrmu
if ($match[1] > '') {
628
2021-12-17
jrmu
list($t0, $t1) = DRange($match[1]);
629
2021-12-17
jrmu
if ($x0 < $t0) return false;
630
2021-12-17
jrmu
if ($match[2] == '' && $x0 >= $t1) return false;
631
2021-12-17
jrmu
}
632
2021-12-17
jrmu
if ($match[3] > '') {
633
2021-12-17
jrmu
list($t0, $t1) = DRange($match[3]);
634
2021-12-17
jrmu
if ($x0 >= $t1) return false;
635
2021-12-17
jrmu
}
636
2021-12-17
jrmu
return true;
637
2021-12-17
jrmu
}
638
2021-12-17
jrmu
639
2021-12-17
jrmu
# This pattern enables the (:encrypt <phrase>:) markup/replace-on-save
640
2021-12-17
jrmu
# pattern.
641
2021-12-17
jrmu
SDV($ROSPatterns['/\\(:encrypt\\s+([^\\s:=]+).*?:\\)/'], 'cb_encrypt');
642
2021-12-17
jrmu
function cb_encrypt($m) { return pmcrypt($m[1]);}
643
2021-12-17
jrmu
644
2021-12-17
jrmu
# Table of contents, based on Cookbook:AutoTOC by Petko Yotov
645
2021-12-17
jrmu
SDVA($PmTOC, array(
646
2021-12-17
jrmu
'Enable' => 0,
647
2021-12-17
jrmu
'MaxLevel' => 6,
648
2021-12-17
jrmu
'MinNumber' => 3,
649
2021-12-17
jrmu
'ParentElement'=>'',
650
2021-12-17
jrmu
'NumberedHeadings'=>'',
651
2021-12-17
jrmu
'EnableBacklinks'=>0,
652
2021-12-17
jrmu
'EnableQMarkup' => 0,
653
2021-12-17
jrmu
'contents' => XL('Contents'),
654
2021-12-17
jrmu
'hide' => XL('hide'),
655
2021-12-17
jrmu
'show' => XL('show'),
656
2021-12-17
jrmu
));
657
2021-12-17
jrmu
658
2021-12-17
jrmu
if ($action!='browse') $PmTOC['Enable'] = 0;
659
2021-12-17
jrmu
660
2021-12-17
jrmu
Markup("PmTOC", 'directives', '/^\\(:[#*]?(?:toc|tdm).*?:\\)\\s*$/im', 'FmtPmTOC');
661
2021-12-17
jrmu
Markup("noPmTOC", 'directives', '/\\(:(no)(?:toc|tdm).*?:\\)/im', 'FmtPmTOC');
662
2021-12-17
jrmu
function FmtPmTOC($m) {
663
2021-12-17
jrmu
if (@$m[1]) return Keep('<span class="noPmTOC"></span>');
664
2021-12-17
jrmu
return "<:block,1>".Keep("<div class='PmTOCdiv'></div>");
665
2021-12-17
jrmu
}
666
2021-12-17
jrmu
SDV($HTMLStylesFmt['PmTOC'], '.noPmTOC, .PmTOCdiv:empty {display:none;}
667
2021-12-17
jrmu
.PmTOCdiv { display: inline-block; font-size: 13px; overflow: auto; max-height: 500px;}
668
2021-12-17
jrmu
.PmTOCdiv a { text-decoration: none;}
669
2021-12-17
jrmu
.back-arrow {font-size: .9em; text-decoration: none;}
670
2021-12-17
jrmu
#PmTOCchk + label {cursor: pointer;}
671
2021-12-17
jrmu
#PmTOCchk {display: none;}
672
2021-12-17
jrmu
#PmTOCchk:not(:checked) + label > .pmtoc-show {display: none;}
673
2021-12-17
jrmu
#PmTOCchk:checked + label > .pmtoc-hide {display: none;}
674
2021-12-17
jrmu
#PmTOCchk:checked + label + div {display: none;}');
675
2021-12-17
jrmu
676
2021-12-17
jrmu
SDV($HTMLStylesFmt['PmSortable'], 'table.sortable th { cursor: pointer; }
677
2021-12-17
jrmu
table.sortable th::after { color: transparent; content: "\00A0\025B8"; }
678
2021-12-17
jrmu
table.sortable th:hover::after { color: inherit; content: "\00A0\025B8"; }
679
2021-12-17
jrmu
table.sortable th.dir-u::after { color: inherit; content: "\00A0\025BE"; }
680
2021-12-17
jrmu
table.sortable th.dir-d::after { color: inherit; content: "\00A0\025B4"; }');
681
2021-12-17
jrmu
IRCNow