| @@ 378-414 (lines=37) @@ | ||
| 375 | "runBasicBlockGamut" => 30, |
|
| 376 | ); |
|
| 377 | ||
| 378 | function stripLinkDefinitions($text) |
|
| 379 | { |
|
| 380 | # |
|
| 381 | # Strips link definitions from text, stores the URLs and titles in |
|
| 382 | # hash references. |
|
| 383 | # |
|
| 384 | $less_than_tab = $this->tab_width - 1; |
|
| 385 | ||
| 386 | # Link defs are in the form: ^[id]: url "optional title" |
|
| 387 | $text = preg_replace_callback( |
|
| 388 | '{ |
|
| 389 | ^[ ]{0,' . $less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
| 390 | [ ]* |
|
| 391 | \n? # maybe *one* newline |
|
| 392 | [ ]* |
|
| 393 | (?: |
|
| 394 | <(.+?)> # url = $2 |
|
| 395 | | |
|
| 396 | (\S+?) # url = $3 |
|
| 397 | ) |
|
| 398 | [ ]* |
|
| 399 | \n? # maybe one newline |
|
| 400 | [ ]* |
|
| 401 | (?: |
|
| 402 | (?<=\s) # lookbehind for whitespace |
|
| 403 | ["(] |
|
| 404 | (.*?) # title = $4 |
|
| 405 | [")] |
|
| 406 | [ ]* |
|
| 407 | )? # title is optional |
|
| 408 | (?:\n+|\Z) |
|
| 409 | }xm', |
|
| 410 | array(&$this, '_stripLinkDefinitions_callback'), |
|
| 411 | $text |
|
| 412 | ); |
|
| 413 | return $text; |
|
| 414 | } |
|
| 415 | ||
| 416 | function _stripLinkDefinitions_callback($matches) |
|
| 417 | { |
|
| @@ 1996-2033 (lines=38) @@ | ||
| 1993 | return $attr_str; |
|
| 1994 | } |
|
| 1995 | ||
| 1996 | function stripLinkDefinitions($text) |
|
| 1997 | { |
|
| 1998 | # |
|
| 1999 | # Strips link definitions from text, stores the URLs and titles in |
|
| 2000 | # hash references. |
|
| 2001 | # |
|
| 2002 | $less_than_tab = $this->tab_width - 1; |
|
| 2003 | ||
| 2004 | # Link defs are in the form: ^[id]: url "optional title" |
|
| 2005 | $text = preg_replace_callback( |
|
| 2006 | '{ |
|
| 2007 | ^[ ]{0,' . $less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
| 2008 | [ ]* |
|
| 2009 | \n? # maybe *one* newline |
|
| 2010 | [ ]* |
|
| 2011 | (?: |
|
| 2012 | <(.+?)> # url = $2 |
|
| 2013 | | |
|
| 2014 | (\S+?) # url = $3 |
|
| 2015 | ) |
|
| 2016 | [ ]* |
|
| 2017 | \n? # maybe one newline |
|
| 2018 | [ ]* |
|
| 2019 | (?: |
|
| 2020 | (?<=\s) # lookbehind for whitespace |
|
| 2021 | ["(] |
|
| 2022 | (.*?) # title = $4 |
|
| 2023 | [")] |
|
| 2024 | [ ]* |
|
| 2025 | )? # title is optional |
|
| 2026 | (?:[ ]* ' . $this->id_class_attr_catch_re . ' )? # $5 = extra id & class attr |
|
| 2027 | (?:\n+|\Z) |
|
| 2028 | }xm', |
|
| 2029 | array(&$this, '_stripLinkDefinitions_callback'), |
|
| 2030 | $text |
|
| 2031 | ); |
|
| 2032 | return $text; |
|
| 2033 | } |
|
| 2034 | ||
| 2035 | function _stripLinkDefinitions_callback($matches) |
|
| 2036 | { |
|
| @@ 3162-3204 (lines=43) @@ | ||
| 3159 | return "\n<dd>" . $def . "</dd>\n"; |
|
| 3160 | } |
|
| 3161 | ||
| 3162 | function doFencedCodeBlocks($text) |
|
| 3163 | { |
|
| 3164 | # |
|
| 3165 | # Adding the fenced code block syntax to regular Markdown: |
|
| 3166 | # |
|
| 3167 | # ~~~ |
|
| 3168 | # Code block |
|
| 3169 | # ~~~ |
|
| 3170 | # |
|
| 3171 | $less_than_tab = $this->tab_width; |
|
| 3172 | ||
| 3173 | $text = preg_replace_callback( |
|
| 3174 | '{ |
|
| 3175 | (?:\n|\A) |
|
| 3176 | # 1: Opening marker |
|
| 3177 | ( |
|
| 3178 | ~{3,} # Marker: three tilde or more. |
|
| 3179 | ) |
|
| 3180 | [ ]* |
|
| 3181 | (?: |
|
| 3182 | \.?([-_:a-zA-Z0-9]+) # 2: standalone class name |
|
| 3183 | | |
|
| 3184 | ' . $this->id_class_attr_catch_re . ' # 3: Extra attributes |
|
| 3185 | )? |
|
| 3186 | [ ]* \n # Whitespace and newline following marker. |
|
| 3187 | ||
| 3188 | # 4: Content |
|
| 3189 | ( |
|
| 3190 | (?> |
|
| 3191 | (?!\1 [ ]* \n) # Not a closing marker. |
|
| 3192 | .*\n+ |
|
| 3193 | )+ |
|
| 3194 | ) |
|
| 3195 | ||
| 3196 | # Closing marker. |
|
| 3197 | \1 [ ]* \n |
|
| 3198 | }xm', |
|
| 3199 | array(&$this, '_doFencedCodeBlocks_callback'), |
|
| 3200 | $text |
|
| 3201 | ); |
|
| 3202 | ||
| 3203 | return $text; |
|
| 3204 | } |
|
| 3205 | ||
| 3206 | function _doFencedCodeBlocks_callback($matches) |
|
| 3207 | { |
|
| @@ 3302-3331 (lines=30) @@ | ||
| 3299 | ||
| 3300 | ### Footnotes |
|
| 3301 | ||
| 3302 | function stripFootnotes($text) |
|
| 3303 | { |
|
| 3304 | # |
|
| 3305 | # Strips link definitions from text, stores the URLs and titles in |
|
| 3306 | # hash references. |
|
| 3307 | # |
|
| 3308 | $less_than_tab = $this->tab_width - 1; |
|
| 3309 | ||
| 3310 | # Link defs are in the form: [^id]: url "optional title" |
|
| 3311 | $text = preg_replace_callback( |
|
| 3312 | '{ |
|
| 3313 | ^[ ]{0,' . $less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1 |
|
| 3314 | [ ]* |
|
| 3315 | \n? # maybe *one* newline |
|
| 3316 | ( # text = $2 (no blank lines allowed) |
|
| 3317 | (?: |
|
| 3318 | .+ # actual text |
|
| 3319 | | |
|
| 3320 | \n # newlines but |
|
| 3321 | (?!\[\^.+?\]:\s)# negative lookahead for footnote marker. |
|
| 3322 | (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed |
|
| 3323 | # by non-indented content |
|
| 3324 | )* |
|
| 3325 | ) |
|
| 3326 | }xm', |
|
| 3327 | array(&$this, '_stripFootnotes_callback'), |
|
| 3328 | $text |
|
| 3329 | ); |
|
| 3330 | return $text; |
|
| 3331 | } |
|
| 3332 | ||
| 3333 | function _stripFootnotes_callback($matches) |
|
| 3334 | { |
|
| @@ 3469-3486 (lines=18) @@ | ||
| 3466 | ||
| 3467 | ### Abbreviations ### |
|
| 3468 | ||
| 3469 | function stripAbbreviations($text) |
|
| 3470 | { |
|
| 3471 | # |
|
| 3472 | # Strips abbreviations from text, stores titles in hash references. |
|
| 3473 | # |
|
| 3474 | $less_than_tab = $this->tab_width - 1; |
|
| 3475 | ||
| 3476 | # Link defs are in the form: [id]*: url "optional title" |
|
| 3477 | $text = preg_replace_callback( |
|
| 3478 | '{ |
|
| 3479 | ^[ ]{0,' . $less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
| 3480 | (.*) # text = $2 (no blank lines allowed) |
|
| 3481 | }xm', |
|
| 3482 | array(&$this, '_stripAbbreviations_callback'), |
|
| 3483 | $text |
|
| 3484 | ); |
|
| 3485 | return $text; |
|
| 3486 | } |
|
| 3487 | ||
| 3488 | function _stripAbbreviations_callback($matches) |
|
| 3489 | { |
|