| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
global $MarkdownPHPVersion, $MarkdownSyntaxVersion, |
|---|
| 15 |
$md_empty_element_suffix, $md_tab_width, |
|---|
| 16 |
$md_nested_brackets_depth, $md_nested_brackets, |
|---|
| 17 |
$md_escape_table, $md_backslash_escape_table, |
|---|
| 18 |
$md_list_level; |
|---|
| 19 |
|
|---|
| 20 |
$MarkdownPHPVersion = '1.0.1c'; |
|---|
| 21 |
$MarkdownSyntaxVersion = '1.0.1'; |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
# |
|---|
| 25 |
# Global default settings: |
|---|
| 26 |
# |
|---|
| 27 |
$md_empty_element_suffix = " />"; |
|---|
| 28 |
$md_tab_width = 4; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
$md_wp_posts = true; |
|---|
| 34 |
$md_wp_comments = true; |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
# -- WordPress Plugin Interface ----------------------------------------------- |
|---|
| 38 |
/* |
|---|
| 39 |
Plugin Name: Markdown |
|---|
| 40 |
Plugin URI: http://www.michelf.com/projects/php-markdown/ |
|---|
| 41 |
Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://www.michelf.com/projects/php-markdown/">More...</a> |
|---|
| 42 |
Version: 1.0.1c |
|---|
| 43 |
Author: Michel Fortin |
|---|
| 44 |
Author URI: http://www.michelf.com/ |
|---|
| 45 |
*/ |
|---|
| 46 |
if (isset($wp_version)) { |
|---|
| 47 |
|
|---|
| 48 |
# <http://www.michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/> |
|---|
| 49 |
|
|---|
| 50 |
# Post content and excerpts |
|---|
| 51 |
if ($md_wp_posts) { |
|---|
| 52 |
remove_filter('the_content', 'wpautop'); |
|---|
| 53 |
remove_filter('the_excerpt', 'wpautop'); |
|---|
| 54 |
add_filter('the_content', 'Markdown', 6); |
|---|
| 55 |
add_filter('get_the_excerpt', 'Markdown', 6); |
|---|
| 56 |
add_filter('get_the_excerpt', 'trim', 7); |
|---|
| 57 |
add_filter('the_excerpt', 'md_add_p'); |
|---|
| 58 |
add_filter('the_excerpt_rss', 'md_strip_p'); |
|---|
| 59 |
|
|---|
| 60 |
remove_filter('content_save_pre', 'balanceTags', 50); |
|---|
| 61 |
remove_filter('excerpt_save_pre', 'balanceTags', 50); |
|---|
| 62 |
add_filter('the_content', 'balanceTags', 50); |
|---|
| 63 |
add_filter('get_the_excerpt', 'balanceTags', 9); |
|---|
| 64 |
|
|---|
| 65 |
function md_add_p($text) { |
|---|
| 66 |
if (strlen($text) == 0) return; |
|---|
| 67 |
if (strcasecmp(substr($text, -3), '<p>') == 0) return $text; |
|---|
| 68 |
return '<p>'.$text.'</p>'; |
|---|
| 69 |
} |
|---|
| 70 |
function md_strip_p($t) { return preg_replace('{</?[pP]>}', '', $t); } |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
if ($md_wp_comments) { |
|---|
| 75 |
remove_filter('comment_text', 'wpautop'); |
|---|
| 76 |
remove_filter('comment_text', 'make_clickable'); |
|---|
| 77 |
add_filter('pre_comment_content', 'Markdown', 6); |
|---|
| 78 |
add_filter('pre_comment_content', 'md_hide_tags', 8); |
|---|
| 79 |
add_filter('pre_comment_content', 'md_show_tags', 12); |
|---|
| 80 |
add_filter('get_comment_text', 'Markdown', 6); |
|---|
| 81 |
add_filter('get_comment_excerpt', 'Markdown', 6); |
|---|
| 82 |
add_filter('get_comment_excerpt', 'md_strip_p', 7); |
|---|
| 83 |
|
|---|
| 84 |
global $md_hidden_tags; |
|---|
| 85 |
$md_hidden_tags = array( |
|---|
| 86 |
'<p>' => md5('<p>'), '</p>' => md5('</p>'), |
|---|
| 87 |
'<pre>' => md5('<pre>'), '</pre>'=> md5('</pre>'), |
|---|
| 88 |
'<ol>' => md5('<ol>'), '</ol>' => md5('</ol>'), |
|---|
| 89 |
'<ul>' => md5('<ul>'), '</ul>' => md5('</ul>'), |
|---|
| 90 |
'<li>' => md5('<li>'), '</li>' => md5('</li>'), |
|---|
| 91 |
); |
|---|
| 92 |
|
|---|
| 93 |
function md_hide_tags($text) { |
|---|
| 94 |
global $md_hidden_tags; |
|---|
| 95 |
return str_replace(array_keys($md_hidden_tags), |
|---|
| 96 |
array_values($md_hidden_tags), $text); |
|---|
| 97 |
} |
|---|
| 98 |
function md_show_tags($text) { |
|---|
| 99 |
global $md_hidden_tags; |
|---|
| 100 |
return str_replace(array_values($md_hidden_tags), |
|---|
| 101 |
array_keys($md_hidden_tags), $text); |
|---|
| 102 |
} |
|---|
| 103 |
} |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
function identify_modifier_markdown() { |
|---|
| 109 |
global $MarkdownPHPVersion; |
|---|
| 110 |
return array( |
|---|
| 111 |
'name' => 'markdown', |
|---|
| 112 |
'type' => 'modifier', |
|---|
| 113 |
'nicename' => 'Markdown', |
|---|
| 114 |
'description' => 'A text-to-HTML conversion tool for web writers', |
|---|
| 115 |
'authors' => 'Michel Fortin and John Gruber', |
|---|
| 116 |
'licence' => 'GPL', |
|---|
| 117 |
'version' => $MarkdownPHPVersion, |
|---|
| 118 |
'help' => '<a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://www.michelf.com/projects/php-markdown/">More...</a>' |
|---|
| 119 |
); |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
function smarty_modifier_markdown($text) { |
|---|
| 124 |
return Markdown($text); |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
if (strcasecmp(substr(__FILE__, -16), "classTextile.php") == 0) { |
|---|
| 130 |
|
|---|
| 131 |
@include_once 'smartypants.php'; |
|---|
| 132 |
|
|---|
| 133 |
class Textile { |
|---|
| 134 |
function TextileThis($text, $lite='', $encode='', $noimage='', $strict='') { |
|---|
| 135 |
if ($lite == '' && $encode == '') $text = Markdown($text); |
|---|
| 136 |
if (function_exists('SmartyPants')) $text = SmartyPants($text); |
|---|
| 137 |
return $text; |
|---|
| 138 |
} |
|---|
| 139 |
} |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
$md_nested_brackets_depth = 6; |
|---|
| 151 |
$md_nested_brackets = |
|---|
| 152 |
str_repeat('(?>[^\[\]]+|\[', $md_nested_brackets_depth). |
|---|
| 153 |
str_repeat('\])*', $md_nested_brackets_depth); |
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
$md_escape_table = array( |
|---|
| 157 |
"\\" => md5("\\"), |
|---|
| 158 |
"`" => md5("`"), |
|---|
| 159 |
"*" => md5("*"), |
|---|
| 160 |
"_" => md5("_"), |
|---|
| 161 |
"{" => md5("{"), |
|---|
| 162 |
"}" => md5("}"), |
|---|
| 163 |
"[" => md5("["), |
|---|
| 164 |
"]" => md5("]"), |
|---|
| 165 |
"(" => md5("("), |
|---|
| 166 |
")" => md5(")"), |
|---|
| 167 |
">" => md5(">"), |
|---|
| 168 |
"#" => md5("#"), |
|---|
| 169 |
"+" => md5("+"), |
|---|
| 170 |
"-" => md5("-"), |
|---|
| 171 |
"." => md5("."), |
|---|
| 172 |
"!" => md5("!") |
|---|
| 173 |
); |
|---|
| 174 |
|
|---|
| 175 |
$md_backslash_escape_table; |
|---|
| 176 |
foreach ($md_escape_table as $key => $char) |
|---|
| 177 |
$md_backslash_escape_table["\\$key"] = $char; |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
function Markdown($text) { |
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
global $md_urls, $md_titles, $md_html_blocks; |
|---|
| 192 |
$md_urls = array(); |
|---|
| 193 |
$md_titles = array(); |
|---|
| 194 |
$md_html_blocks = array(); |
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
$text = str_replace(array("\r\n", "\r"), "\n", $text); |
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
$text .= "\n\n"; |
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
$text = _Detab($text); |
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 |
$text = preg_replace('/^[ \t]+$/m', '', $text); |
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
$text = _HashHTMLBlocks($text); |
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
$text = _StripLinkDefinitions($text); |
|---|
| 217 |
|
|---|
| 218 |
$text = _RunBlockGamut($text); |
|---|
| 219 |
|
|---|
| 220 |
$text = _UnescapeSpecialChars($text); |
|---|
| 221 |
|
|---|
| 222 |
$text . "\n"; |
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
_StripLinkDefinitions($text) { |
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
global $md_tab_width; |
|---|
| 232 |
$less_than_tab = $md_tab_width - 1; |
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
$text = preg_replace_callback('{ |
|---|
| 236 |
.$less_than_tab.'}\[(.+)\]: # id = $1 |
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
, |
|---|
| 253 |
'_StripLinkDefinitions_callback', |
|---|
| 254 |
$text); |
|---|
| 255 |
$text; |
|---|
| 256 |
|
|---|
| 257 |
_StripLinkDefinitions_callback($matches) { |
|---|
| 258 |
$md_urls, $md_titles; |
|---|
| 259 |
$link_id = strtolower($matches[1]); |
|---|
| 260 |
$md_urls[$link_id] = _EncodeAmpsAndAngles($matches[2]); |
|---|
| 261 |
$matches[3])) |
|---|
| 262 |
$md_titles[$link_id] = str_replace('"', '"', $matches[3]); |
|---|
| 263 |
''; |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
function _HashHTMLBlocks($text) { |
|---|
| 268 |
global $md_tab_width; |
|---|
| 269 |
$less_than_tab = $md_tab_width - 1; |
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
# We only want to do this for block-level HTML tags, such as headers, |
|---|
| 273 |
# lists, and tables. That's because we still want to wrap <p>s around |
|---|
| 274 |
# "paragraphs" that are wrapped in non-block-level tags, such as anchors, |
|---|
| 275 |
# phrase emphasis, and spans. The list of tags we're looking for is |
|---|
| 276 |
# hard-coded: |
|---|
| 277 |
$block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|'. |
|---|
| 278 |
'script|noscript|form|fieldset|iframe|math|ins|del'; |
|---|
| 279 |
$block_tags_b = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|'. |
|---|
| 280 |
'script|noscript|form|fieldset|iframe|math'; |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
# <div> |
|---|
| 284 |
# <div> |
|---|
| 285 |
# tags for inner block must be indented. |
|---|
| 286 |
# </div> |
|---|
| 287 |
# </div> |
|---|
| 288 |
# |
|---|
| 289 |
# The outermost tags must start at the left margin for this to match, and |
|---|
| 290 |
# the inner nested divs must be indented. |
|---|
| 291 |
# We need to do this before the next, more liberal match, because the next |
|---|
| 292 |
# match will start at the first `<div>` and stop at the first `</div>`. |
|---|
| 293 |
$text = preg_replace_callback("{ |
|---|
| 294 |
( # save in $1 |
|---|
| 295 |
^ # start of line (with /m) |
|---|
| 296 |
<($block_tags_a) # start tag = $2 |
|---|
| 297 |
\\b # word break |
|---|
| 298 |
(.*\\n)*? # any number of lines, minimally matching |
|---|
| 299 |
</\\2> # the matching end tag |
|---|
| 300 |
[ \\t]* # trailing spaces/tabs |
|---|
| 301 |
(?=\\n+|\\Z) # followed by a newline or end of document |
|---|
| 302 |
) |
|---|
| 303 |
}xm", |
|---|
| 304 |
'_HashHTMLBlocks_callback', |
|---|
| 305 |
$text); |
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
# Now match more liberally, simply from `\n<tag>` to `</tag>\n` |
|---|
| 309 |
# |
|---|
| 310 |
$text = preg_replace_callback("{ |
|---|
| 311 |
( # save in $1 |
|---|
| 312 |
^ # start of line (with /m) |
|---|
| 313 |
<($block_tags_b) # start tag = $2 |
|---|
| 314 |
\\b # word break |
|---|
| 315 |
(.*\\n)*? # any number of lines, minimally matching |
|---|
| 316 |
.*</\\2> # the matching end tag |
|---|
| 317 |
[ \\t]* # trailing spaces/tabs |
|---|
| 318 |
(?=\\n+|\\Z) # followed by a newline or end of document |
|---|
| 319 |
) |
|---|
| 320 |
}xm", |
|---|
| 321 |
'_HashHTMLBlocks_callback', |
|---|
| 322 |
$text); |
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
# to make the other regex more complicated. |
|---|
| 326 |
$text = preg_replace_callback('{ |
|---|
| 327 |
(?: |
|---|
| 328 |
(?<=\n\n) # Starting after a blank line |
|---|
| 329 |
| # or |
|---|
| 330 |
\A\n? # the beginning of the doc |
|---|
| 331 |
) |
|---|
| 332 |
( # save in $1 |
|---|
| 333 |
[ ]{0,'.$less_than_tab.'} |
|---|
| 334 |
<(hr) # start tag = $2 |
|---|
| 335 |
\b # word break |
|---|
| 336 |
([^<>])*? # |
|---|
| 337 |
/?> # the matching end tag |
|---|
| 338 |
[ \t]* |
|---|
| 339 |
(?=\n{2,}|\Z) # followed by a blank line or end of document |
|---|
| 340 |
) |
|---|
| 341 |
}x', |
|---|
| 342 |
'_HashHTMLBlocks_callback', |
|---|
| 343 |
$text); |
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
$text = preg_replace_callback('{ |
|---|
| 347 |
(?: |
|---|
| 348 |
(?<=\n\n) # Starting after a blank line |
|---|
| 349 |
| # or |
|---|
| 350 |
\A\n? # the beginning of the doc |
|---|
| 351 |
) |
|---|
| 352 |
( # save in $1 |
|---|
| 353 |
[ ]{0,'.$less_than_tab.'} |
|---|
| 354 |
(?s: |
|---|
| 355 |
<! |
|---|
| 356 |
(--.*?--\s*)+ |
|---|
| 357 |
> |
|---|
| 358 |
) |
|---|
| 359 |
[ \t]* |
|---|
| 360 |
(?=\n{2,}|\Z) # followed by a blank line or end of document |
|---|
| 361 |
) |
|---|
| 362 |
}x', |
|---|
| 363 |
'_HashHTMLBlocks_callback', |
|---|
| 364 |
$text); |
|---|
| 365 |
|
|---|
| 366 |
return $text; |
|---|
| 367 |
} |
|---|
| 368 |
function _HashHTMLBlocks_callback($matches) { |
|---|
| 369 |
global $md_html_blocks; |
|---|
| 370 |
$text = $matches[1]; |
|---|
| 371 |
$key = md5($text); |
|---|
| 372 |
$md_html_blocks[$key] = $text; |
|---|
| 373 |
return "\n\n$key\n\n"; |
|---|
| 374 |
} |
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
function _RunBlockGamut($text) { |
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 |
global $md_empty_element_suffix; |
|---|
| 383 |
|
|---|
| 384 |
$text = _DoHeaders($text); |
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
$text = preg_replace( |
|---|
| 388 |
'{^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$}mx', |
|---|
| 389 |
'{^[ ]{0,2}([ ]? -[ ]?){3,}[ \t]*$}mx', |
|---|
| 390 |
'{^[ ]{0,2}([ ]? _[ ]?){3,}[ \t]*$}mx'), |
|---|
| 391 |
"\n<hr$md_empty_element_suffix\n", |
|---|
| 392 |
$text); |
|---|
| 393 |
|
|---|
| 394 |
$text = _DoLists($text); |
|---|
| 395 |
$text = _DoCodeBlocks($text); |
|---|
| 396 |
$text = _DoBlockQuotes($text); |
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 |
$text = _HashHTMLBlocks($text); |
|---|
| 403 |
$text = _FormParagraphs($text); |
|---|
| 404 |
|
|---|
| 405 |
$text; |
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 |
_RunSpanGamut($text) { |
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 |
|
|---|
| 413 |
|
|---|
| 414 |
global $md_empty_element_suffix; |
|---|
| 415 |
|
|---|
| 416 |
$text = _DoCodeSpans($text); |
|---|
| 417 |
|
|---|
| 418 |
$text = _EscapeSpecialChars($text); |
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
$text = _DoImages($text); |
|---|
| 423 |
$text = _DoAnchors($text); |
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
|
|---|
| 428 |
$text = _DoAutoLinks($text); |
|---|
| 429 |
$text = _EncodeAmpsAndAngles($text); |
|---|
| 430 |
$text = _DoItalicsAndBold($text); |
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
$text = preg_replace('/ {2,}\n/', "<br$md_empty_element_suffix\n", $text); |
|---|
| 434 |
|
|---|
| 435 |
$text; |
|---|
| 436 |
|
|---|
| 437 |
|
|---|
| 438 |
|
|---|
| 439 |
_EscapeSpecialChars($text) { |
|---|
| 440 |
$md_escape_table; |
|---|
| 441 |
$tokens = _TokenizeHTML($text); |
|---|
| 442 |
|
|---|
| 443 |
$text = ''; |
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
foreach ($tokens as $cur_token) { |
|---|
| 448 |
$cur_token[0] == 'tag') { |
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
$cur_token[1] = str_replace(array('*', '_'), |
|---|
| 456 |
$md_escape_table['*'], $md_escape_table['_']), |
|---|
| 457 |
$cur_token[1]); |
|---|
| 458 |
$text .= $cur_token[1]; |
|---|
| 459 |
|
|---|
| 460 |
$t = $cur_token[1]; |
|---|
| 461 |
$t = _EncodeBackslashEscapes($t); |
|---|
| 462 |
$text .= $t; |
|---|
| 463 |
|
|---|
| 464 |
|
|---|
| 465 |
$text; |
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 |
_DoAnchors($text) { |
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
|
|---|
| 473 |
global $md_nested_brackets; |
|---|
| 474 |
|
|---|
| 475 |
|
|---|
| 476 |
|
|---|
| 477 |
$text = preg_replace_callback("{ |
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
|
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 |
|
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 |
, |
|---|
| 491 |
'_DoAnchors_reference_callback', $text); |
|---|
| 492 |
|
|---|
| 493 |
|
|---|
| 494 |
|
|---|
| 495 |
|
|---|
| 496 |
$text = preg_replace_callback("{ |
|---|
| 497 |
|
|---|
| 498 |
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 |
, |
|---|
| 513 |
'_DoAnchors_inline_callback', $text); |
|---|
| 514 |
|
|---|
| 515 |
$text; |
|---|
| 516 |
|
|---|
| 517 |
_DoAnchors_reference_callback($matches) { |
|---|
| 518 |
$md_urls, $md_titles, $md_escape_table; |
|---|
| 519 |
$whole_match = $matches[1]; |
|---|
| 520 |
$link_text = $matches[2]; |
|---|
| 521 |
$link_id = strtolower($matches[3]); |
|---|
| 522 |
|
|---|
| 523 |
$link_id == "") { |
|---|
| 524 |
$link_id = strtolower($link_text); |
|---|
| 525 |
} |
|---|
| 526 |
|
|---|
| 527 |
$md_urls[$link_id])) { |
|---|
| 528 |
$url = $md_urls[$link_id]; |
|---|
| 529 |
|
|---|
| 530 |
$url = str_replace(array('*', '_'), |
|---|
| 531 |
$md_escape_table['*'], $md_escape_table['_']), |
|---|
| 532 |
$url); |
|---|
| 533 |
$result = "<a href=\"$url\""; |
|---|
| 534 |
$md_titles[$link_id] ) ) { |
|---|
| 535 |
$title = $md_titles[$link_id]; |
|---|
| 536 |
$title = str_replace(array('*', '_'), |
|---|
| 537 |
$md_escape_table['*'], |
|---|
| 538 |
$md_escape_table['_']), $title); |
|---|
| 539 |
$result .= " title=\"$title\""; |
|---|
| 540 |
|
|---|
| 541 |
$result .= ">$link_text</a>"; |
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
$result = $whole_match; |
|---|
| 545 |
|
|---|
| 546 |
$result; |
|---|
| 547 |
|
|---|
| 548 |
_DoAnchors_inline_callback($matches) { |
|---|
| 549 |
$md_escape_table; |
|---|
| 550 |
$whole_match = $matches[1]; |
|---|
| 551 |
$link_text = $matches[2]; |
|---|
| 552 |
$url = $matches[3]; |
|---|
| 553 |
$title =& $matches[6]; |
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 |
$url = str_replace(array('*', '_'), |
|---|
| 557 |
$md_escape_table['*'], $md_escape_table['_']), |
|---|
| 558 |
$url); |
|---|
| 559 |
$result |
|---|