@@ -5,8 +5,8 @@ |
||
| 5 | 5 | // you like. |
| 6 | 6 | |
| 7 | 7 | // Install PSR-4-compatible class autoloader |
| 8 | -spl_autoload_register(function($class){ |
|
| 9 | - require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php'; |
|
| 8 | +spl_autoload_register(function($class) { |
|
| 9 | + require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')) . '.php'; |
|
| 10 | 10 | }); |
| 11 | 11 | // If using Composer, use this instead: |
| 12 | 12 | //require 'vendor/autoloader.php'; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $this->abbr_desciptions = array(); |
| 189 | 189 | $this->abbr_word_re = ''; |
| 190 | 190 | |
| 191 | - if ( ! $this->omit_footnotes ) |
|
| 191 | + if (!$this->omit_footnotes) |
|
| 192 | 192 | $this->footnotes_assembled = null; |
| 193 | 193 | |
| 194 | 194 | parent::teardown(); |
@@ -252,13 +252,13 @@ discard block |
||
| 252 | 252 | // Compose attributes as string |
| 253 | 253 | $attr_str = ""; |
| 254 | 254 | if (!empty($id)) { |
| 255 | - $attr_str .= ' id="'.$this->encodeAttribute($id) .'"'; |
|
| 255 | + $attr_str .= ' id="' . $this->encodeAttribute($id) . '"'; |
|
| 256 | 256 | } |
| 257 | 257 | if (!empty($classes)) { |
| 258 | - $attr_str .= ' class="'. implode(" ", $classes) . '"'; |
|
| 258 | + $attr_str .= ' class="' . implode(" ", $classes) . '"'; |
|
| 259 | 259 | } |
| 260 | 260 | if (!$this->no_markup && !empty($attributes)) { |
| 261 | - $attr_str .= ' '.implode(" ", $attributes); |
|
| 261 | + $attr_str .= ' ' . implode(" ", $attributes); |
|
| 262 | 262 | } |
| 263 | 263 | return $attr_str; |
| 264 | 264 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | // Link defs are in the form: ^[id]: url "optional title" |
| 276 | 276 | $text = preg_replace_callback('{ |
| 277 | - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 277 | + ^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
| 278 | 278 | [ ]* |
| 279 | 279 | \n? # maybe *one* newline |
| 280 | 280 | [ ]* |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | [")] |
| 294 | 294 | [ ]* |
| 295 | 295 | )? # title is optional |
| 296 | - (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
| 296 | + (?:[ ]* '.$this->id_class_attr_catch_re . ' )? # $5 = extra id & class attr |
|
| 297 | 297 | (?:\n+|\Z) |
| 298 | 298 | }xm', |
| 299 | 299 | array($this, '_stripLinkDefinitions_callback'), |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | $link_id = strtolower($matches[1]); |
| 311 | 311 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
| 312 | 312 | $this->urls[$link_id] = $url; |
| 313 | - $this->titles[$link_id] =& $matches[4]; |
|
| 314 | - $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]); |
|
| 313 | + $this->titles[$link_id] = & $matches[4]; |
|
| 314 | + $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]); |
|
| 315 | 315 | return ''; // String that will replace the block |
| 316 | 316 | } |
| 317 | 317 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Call the HTML-in-Markdown hasher. |
| 377 | - list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 377 | + list($text,) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 378 | 378 | |
| 379 | 379 | return $text; |
| 380 | 380 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | <\?.*?\?> | <%.*?%> # Processing instruction |
| 452 | 452 | | |
| 453 | 453 | <!\[CDATA\[.*?\]\]> # CData Block |
| 454 | - ' . ( !$span ? ' # If not in span. |
|
| 454 | + ' . (!$span ? ' # If not in span. |
|
| 455 | 455 | | |
| 456 | 456 | # Indented code block |
| 457 | 457 | (?: ^[ ]*\n | ^ | \n[ ]*\n ) |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | (?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes |
| 470 | 470 | [ ]* |
| 471 | 471 | (?= \n ) |
| 472 | - ' : '' ) . ' # End (if not is span). |
|
| 472 | + ' : '') . ' # End (if not is span). |
|
| 473 | 473 | | |
| 474 | 474 | # Code span marker |
| 475 | 475 | # Note, this regex needs to go after backtick fenced |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | }xs'; |
| 481 | 481 | |
| 482 | 482 | |
| 483 | - $depth = 0; // Current depth inside the tag tree. |
|
| 484 | - $parsed = ""; // Parsed text that will be returned. |
|
| 483 | + $depth = 0; // Current depth inside the tag tree. |
|
| 484 | + $parsed = ""; // Parsed text that will be returned. |
|
| 485 | 485 | |
| 486 | 486 | // Loop through every tag until we find the closing tag of the parent |
| 487 | 487 | // or loop until reaching the end of text if no parent tag specified. |
@@ -559,9 +559,9 @@ discard block |
||
| 559 | 559 | // Opening Context Block tag (like ins and del) |
| 560 | 560 | // used as a block tag (tag is alone on it's line). |
| 561 | 561 | else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) || |
| 562 | - ( preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
| 562 | + (preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
| 563 | 563 | preg_match($newline_before_re, $parsed) && |
| 564 | - preg_match($newline_after_re, $text) ) |
|
| 564 | + preg_match($newline_after_re, $text)) |
|
| 565 | 565 | ) |
| 566 | 566 | { |
| 567 | 567 | // Need to parse tag and following text using the HTML parser. |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | { |
| 591 | 591 | // Increase/decrease nested tag count. |
| 592 | 592 | if ($tag{1} == '/') $depth--; |
| 593 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 593 | + else if ($tag{strlen($tag) - 2} != '/') $depth++; |
|
| 594 | 594 | |
| 595 | 595 | if ($depth < 0) { |
| 596 | 596 | // Going out of parent element. Clean up and break so we |
@@ -665,11 +665,11 @@ discard block |
||
| 665 | 665 | ) |
| 666 | 666 | }xs'; |
| 667 | 667 | |
| 668 | - $original_text = $text; // Save original text in case of faliure. |
|
| 668 | + $original_text = $text; // Save original text in case of faliure. |
|
| 669 | 669 | |
| 670 | - $depth = 0; // Current depth inside the tag tree. |
|
| 671 | - $block_text = ""; // Temporary text holder for current text. |
|
| 672 | - $parsed = ""; // Parsed text that will be returned. |
|
| 670 | + $depth = 0; // Current depth inside the tag tree. |
|
| 671 | + $block_text = ""; // Temporary text holder for current text. |
|
| 672 | + $parsed = ""; // Parsed text that will be returned. |
|
| 673 | 673 | |
| 674 | 674 | // Get the name of the starting tag. |
| 675 | 675 | // (This pattern makes $base_tag_name_re safe without quoting.) |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | // the tag's name match base tag's. |
| 710 | 710 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
| 711 | 711 | if ($tag{1} == '/') $depth--; |
| 712 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 712 | + else if ($tag{strlen($tag) - 2} != '/') $depth++; |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | // Check for `markdown="1"` attribute and handle it. |
@@ -858,9 +858,9 @@ discard block |
||
| 858 | 858 | * @return string |
| 859 | 859 | */ |
| 860 | 860 | protected function _doAnchors_reference_callback($matches) { |
| 861 | - $whole_match = $matches[1]; |
|
| 862 | - $link_text = $matches[2]; |
|
| 863 | - $link_id =& $matches[3]; |
|
| 861 | + $whole_match = $matches[1]; |
|
| 862 | + $link_text = $matches[2]; |
|
| 863 | + $link_id = & $matches[3]; |
|
| 864 | 864 | |
| 865 | 865 | if ($link_id == "") { |
| 866 | 866 | // for shortcut links like [this][] or [this]. |
@@ -876,10 +876,10 @@ discard block |
||
| 876 | 876 | $url = $this->encodeURLAttribute($url); |
| 877 | 877 | |
| 878 | 878 | $result = "<a href=\"$url\""; |
| 879 | - if ( isset( $this->titles[$link_id] ) ) { |
|
| 879 | + if (isset($this->titles[$link_id])) { |
|
| 880 | 880 | $title = $this->titles[$link_id]; |
| 881 | 881 | $title = $this->encodeAttribute($title); |
| 882 | - $result .= " title=\"$title\""; |
|
| 882 | + $result .= " title=\"$title\""; |
|
| 883 | 883 | } |
| 884 | 884 | if (isset($this->ref_attr[$link_id])) |
| 885 | 885 | $result .= $this->ref_attr[$link_id]; |
@@ -900,11 +900,11 @@ discard block |
||
| 900 | 900 | * @return string |
| 901 | 901 | */ |
| 902 | 902 | protected function _doAnchors_inline_callback($matches) { |
| 903 | - $whole_match = $matches[1]; |
|
| 904 | - $link_text = $this->runSpanGamut($matches[2]); |
|
| 905 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 906 | - $title =& $matches[7]; |
|
| 907 | - $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]); |
|
| 903 | + $whole_match = $matches[1]; |
|
| 904 | + $link_text = $this->runSpanGamut($matches[2]); |
|
| 905 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 906 | + $title = & $matches[7]; |
|
| 907 | + $attr = $this->doExtraAttributes("a", $dummy = & $matches[8]); |
|
| 908 | 908 | |
| 909 | 909 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
| 910 | 910 | // tag parser and hashed. Need to reverse the process before using the URL. |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | $result = "<a href=\"$url\""; |
| 918 | 918 | if (isset($title)) { |
| 919 | 919 | $title = $this->encodeAttribute($title); |
| 920 | - $result .= " title=\"$title\""; |
|
| 920 | + $result .= " title=\"$title\""; |
|
| 921 | 921 | } |
| 922 | 922 | $result .= $attr; |
| 923 | 923 | |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | if (isset($this->titles[$link_id])) { |
| 1004 | 1004 | $title = $this->titles[$link_id]; |
| 1005 | 1005 | $title = $this->encodeAttribute($title); |
| 1006 | - $result .= " title=\"$title\""; |
|
| 1006 | + $result .= " title=\"$title\""; |
|
| 1007 | 1007 | } |
| 1008 | 1008 | if (isset($this->ref_attr[$link_id])) |
| 1009 | 1009 | $result .= $this->ref_attr[$link_id]; |
@@ -1024,18 +1024,18 @@ discard block |
||
| 1024 | 1024 | * @return string |
| 1025 | 1025 | */ |
| 1026 | 1026 | protected function _doImages_inline_callback($matches) { |
| 1027 | - $whole_match = $matches[1]; |
|
| 1028 | - $alt_text = $matches[2]; |
|
| 1027 | + $whole_match = $matches[1]; |
|
| 1028 | + $alt_text = $matches[2]; |
|
| 1029 | 1029 | $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
| 1030 | - $title =& $matches[7]; |
|
| 1031 | - $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); |
|
| 1030 | + $title = & $matches[7]; |
|
| 1031 | + $attr = $this->doExtraAttributes("img", $dummy = & $matches[8]); |
|
| 1032 | 1032 | |
| 1033 | 1033 | $alt_text = $this->encodeAttribute($alt_text); |
| 1034 | 1034 | $url = $this->encodeURLAttribute($url); |
| 1035 | 1035 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
| 1036 | 1036 | if (isset($title)) { |
| 1037 | 1037 | $title = $this->encodeAttribute($title); |
| 1038 | - $result .= " title=\"$title\""; // $title already quoted |
|
| 1038 | + $result .= " title=\"$title\""; // $title already quoted |
|
| 1039 | 1039 | } |
| 1040 | 1040 | $result .= $attr; |
| 1041 | 1041 | $result .= $this->empty_element_suffix; |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | // |
| 1074 | 1074 | $text = preg_replace_callback('{ |
| 1075 | 1075 | ^(\#{1,6}) # $1 = string of #\'s |
| 1076 | - [ ]'.($this->hashtag_protection ? '+' : '*').' |
|
| 1076 | + [ ]'.($this->hashtag_protection ? '+' : '*') . ' |
|
| 1077 | 1077 | (.+?) # $2 = Header text |
| 1078 | 1078 | [ ]* |
| 1079 | 1079 | \#* # optional closing #\'s (not counted) |
@@ -1100,7 +1100,7 @@ discard block |
||
| 1100 | 1100 | |
| 1101 | 1101 | $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null; |
| 1102 | 1102 | |
| 1103 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId); |
|
| 1103 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId); |
|
| 1104 | 1104 | $block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
| 1105 | 1105 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 1106 | 1106 | } |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | $level = strlen($matches[1]); |
| 1115 | 1115 | |
| 1116 | 1116 | $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null; |
| 1117 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId); |
|
| 1117 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId); |
|
| 1118 | 1118 | $block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
| 1119 | 1119 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 1120 | 1120 | } |
@@ -1185,8 +1185,8 @@ discard block |
||
| 1185 | 1185 | * @return string |
| 1186 | 1186 | */ |
| 1187 | 1187 | protected function _doTable_leadingPipe_callback($matches) { |
| 1188 | - $head = $matches[1]; |
|
| 1189 | - $underline = $matches[2]; |
|
| 1188 | + $head = $matches[1]; |
|
| 1189 | + $underline = $matches[2]; |
|
| 1190 | 1190 | $content = $matches[3]; |
| 1191 | 1191 | |
| 1192 | 1192 | $content = preg_replace('/^ *[|]/m', '', $content); |
@@ -1215,14 +1215,14 @@ discard block |
||
| 1215 | 1215 | * @return string |
| 1216 | 1216 | */ |
| 1217 | 1217 | protected function _doTable_callback($matches) { |
| 1218 | - $head = $matches[1]; |
|
| 1219 | - $underline = $matches[2]; |
|
| 1220 | - $content = $matches[3]; |
|
| 1218 | + $head = $matches[1]; |
|
| 1219 | + $underline = $matches[2]; |
|
| 1220 | + $content = $matches[3]; |
|
| 1221 | 1221 | |
| 1222 | 1222 | // Remove any tailing pipes for each line. |
| 1223 | - $head = preg_replace('/[|] *$/m', '', $head); |
|
| 1224 | - $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 1225 | - $content = preg_replace('/[|] *$/m', '', $content); |
|
| 1223 | + $head = preg_replace('/[|] *$/m', '', $head); |
|
| 1224 | + $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 1225 | + $content = preg_replace('/[|] *$/m', '', $content); |
|
| 1226 | 1226 | |
| 1227 | 1227 | // Reading alignement from header underline. |
| 1228 | 1228 | $separators = preg_split('/ *[|] */', $underline); |
@@ -1239,10 +1239,10 @@ discard block |
||
| 1239 | 1239 | |
| 1240 | 1240 | // Parsing span elements, including code spans, character escapes, |
| 1241 | 1241 | // and inline HTML tags, so that pipes inside those gets ignored. |
| 1242 | - $head = $this->parseSpan($head); |
|
| 1243 | - $headers = preg_split('/ *[|] */', $head); |
|
| 1244 | - $col_count = count($headers); |
|
| 1245 | - $attr = array_pad($attr, $col_count, ''); |
|
| 1242 | + $head = $this->parseSpan($head); |
|
| 1243 | + $headers = preg_split('/ *[|] */', $head); |
|
| 1244 | + $col_count = count($headers); |
|
| 1245 | + $attr = array_pad($attr, $col_count, ''); |
|
| 1246 | 1246 | |
| 1247 | 1247 | // Write column headers. |
| 1248 | 1248 | $text = "<table>\n"; |
@@ -1408,13 +1408,13 @@ discard block |
||
| 1408 | 1408 | protected function _processDefListItems_callback_dd($matches) { |
| 1409 | 1409 | $leading_line = $matches[1]; |
| 1410 | 1410 | $marker_space = $matches[2]; |
| 1411 | - $def = $matches[3]; |
|
| 1411 | + $def = $matches[3]; |
|
| 1412 | 1412 | |
| 1413 | 1413 | if ($leading_line || preg_match('/\n{2,}/', $def)) { |
| 1414 | 1414 | // Replace marker with the appropriate whitespace indentation |
| 1415 | 1415 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 1416 | 1416 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 1417 | - $def = "\n". $def ."\n"; |
|
| 1417 | + $def = "\n" . $def . "\n"; |
|
| 1418 | 1418 | } |
| 1419 | 1419 | else { |
| 1420 | 1420 | $def = rtrim($def); |
@@ -1476,8 +1476,8 @@ discard block |
||
| 1476 | 1476 | * @return string |
| 1477 | 1477 | */ |
| 1478 | 1478 | protected function _doFencedCodeBlocks_callback($matches) { |
| 1479 | - $classname =& $matches[2]; |
|
| 1480 | - $attrs =& $matches[3]; |
|
| 1479 | + $classname = & $matches[2]; |
|
| 1480 | + $attrs = & $matches[3]; |
|
| 1481 | 1481 | $codeblock = $matches[4]; |
| 1482 | 1482 | |
| 1483 | 1483 | if ($this->code_block_content_func) { |
@@ -1498,9 +1498,9 @@ discard block |
||
| 1498 | 1498 | $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes); |
| 1499 | 1499 | $pre_attr_str = $this->code_attr_on_pre ? $attr_str : ''; |
| 1500 | 1500 | $code_attr_str = $this->code_attr_on_pre ? '' : $attr_str; |
| 1501 | - $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
| 1501 | + $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
| 1502 | 1502 | |
| 1503 | - return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
| 1503 | + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | 1506 | /** |
@@ -1633,9 +1633,9 @@ discard block |
||
| 1633 | 1633 | $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', |
| 1634 | 1634 | array($this, '_appendFootnotes_callback'), $text); |
| 1635 | 1635 | |
| 1636 | - if ( ! empty( $this->footnotes_ordered ) ) { |
|
| 1636 | + if (!empty($this->footnotes_ordered)) { |
|
| 1637 | 1637 | $this->_doFootnotes(); |
| 1638 | - if ( ! $this->omit_footnotes ) { |
|
| 1638 | + if (!$this->omit_footnotes) { |
|
| 1639 | 1639 | $text .= "\n\n"; |
| 1640 | 1640 | $text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n"; |
| 1641 | 1641 | $text .= "<hr" . $this->empty_element_suffix . "\n"; |
@@ -1717,7 +1717,7 @@ discard block |
||
| 1717 | 1717 | // Create footnote marker only if it has a corresponding footnote *and* |
| 1718 | 1718 | // the footnote hasn't been used by another marker. |
| 1719 | 1719 | if (isset($this->footnotes[$node_id])) { |
| 1720 | - $num =& $this->footnotes_numbers[$node_id]; |
|
| 1720 | + $num = & $this->footnotes_numbers[$node_id]; |
|
| 1721 | 1721 | if (!isset($num)) { |
| 1722 | 1722 | // Transfer footnote content to the ordered list and give it its |
| 1723 | 1723 | // number |
@@ -1746,8 +1746,8 @@ discard block |
||
| 1746 | 1746 | $node_id = $this->encodeAttribute($node_id); |
| 1747 | 1747 | |
| 1748 | 1748 | return |
| 1749 | - "<sup id=\"fnref$ref_count_mark:$node_id\">". |
|
| 1750 | - "<a href=\"#fn:$node_id\"$attr>$num</a>". |
|
| 1749 | + "<sup id=\"fnref$ref_count_mark:$node_id\">" . |
|
| 1750 | + "<a href=\"#fn:$node_id\"$attr>$num</a>" . |
|
| 1751 | 1751 | "</sup>"; |
| 1752 | 1752 | } |
| 1753 | 1753 | |
@@ -170,8 +170,9 @@ discard block |
||
| 170 | 170 | $this->footnotes_assembled = null; |
| 171 | 171 | |
| 172 | 172 | foreach ($this->predef_abbr as $abbr_word => $abbr_desc) { |
| 173 | - if ($this->abbr_word_re) |
|
| 174 | - $this->abbr_word_re .= '|'; |
|
| 173 | + if ($this->abbr_word_re) { |
|
| 174 | + $this->abbr_word_re .= '|'; |
|
| 175 | + } |
|
| 175 | 176 | $this->abbr_word_re .= preg_quote($abbr_word); |
| 176 | 177 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
| 177 | 178 | } |
@@ -188,8 +189,9 @@ discard block |
||
| 188 | 189 | $this->abbr_desciptions = array(); |
| 189 | 190 | $this->abbr_word_re = ''; |
| 190 | 191 | |
| 191 | - if ( ! $this->omit_footnotes ) |
|
| 192 | - $this->footnotes_assembled = null; |
|
| 192 | + if ( ! $this->omit_footnotes ) { |
|
| 193 | + $this->footnotes_assembled = null; |
|
| 194 | + } |
|
| 193 | 195 | |
| 194 | 196 | parent::teardown(); |
| 195 | 197 | } |
@@ -227,7 +229,9 @@ discard block |
||
| 227 | 229 | * @return string |
| 228 | 230 | */ |
| 229 | 231 | protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $classes = array()) { |
| 230 | - if (empty($attr) && !$defaultIdValue && empty($classes)) return ""; |
|
| 232 | + if (empty($attr) && !$defaultIdValue && empty($classes)) { |
|
| 233 | + return ""; |
|
| 234 | + } |
|
| 231 | 235 | |
| 232 | 236 | // Split on components |
| 233 | 237 | preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches); |
@@ -240,14 +244,18 @@ discard block |
||
| 240 | 244 | if ($element{0} == '.') { |
| 241 | 245 | $classes[] = substr($element, 1); |
| 242 | 246 | } else if ($element{0} == '#') { |
| 243 | - if ($id === false) $id = substr($element, 1); |
|
| 247 | + if ($id === false) { |
|
| 248 | + $id = substr($element, 1); |
|
| 249 | + } |
|
| 244 | 250 | } else if (strpos($element, '=') > 0) { |
| 245 | 251 | $parts = explode('=', $element, 2); |
| 246 | 252 | $attributes[] = $parts[0] . '="' . $parts[1] . '"'; |
| 247 | 253 | } |
| 248 | 254 | } |
| 249 | 255 | |
| 250 | - if (!$id) $id = $defaultIdValue; |
|
| 256 | + if (!$id) { |
|
| 257 | + $id = $defaultIdValue; |
|
| 258 | + } |
|
| 251 | 259 | |
| 252 | 260 | // Compose attributes as string |
| 253 | 261 | $attr_str = ""; |
@@ -414,7 +422,9 @@ discard block |
||
| 414 | 422 | $enclosing_tag_re = '', $span = false) |
| 415 | 423 | { |
| 416 | 424 | |
| 417 | - if ($text === '') return array('', ''); |
|
| 425 | + if ($text === '') { |
|
| 426 | + return array('', ''); |
|
| 427 | + } |
|
| 418 | 428 | |
| 419 | 429 | // Regex to check for the presense of newlines around a block tag. |
| 420 | 430 | $newline_before_re = '/(?:^\n?|\n\n)*$/'; |
@@ -526,8 +536,7 @@ discard block |
||
| 526 | 536 | // End marker found: pass text unchanged until marker. |
| 527 | 537 | $parsed .= $tag . $matches[0]; |
| 528 | 538 | $text = substr($text, strlen($matches[0])); |
| 529 | - } |
|
| 530 | - else { |
|
| 539 | + } else { |
|
| 531 | 540 | // No end marker: just skip it. |
| 532 | 541 | $parsed .= $tag; |
| 533 | 542 | } |
@@ -549,8 +558,7 @@ discard block |
||
| 549 | 558 | // End marker found: pass text unchanged until marker. |
| 550 | 559 | $parsed .= $tag . $matches[0]; |
| 551 | 560 | $text = substr($text, strlen($matches[0])); |
| 552 | - } |
|
| 553 | - else { |
|
| 561 | + } else { |
|
| 554 | 562 | // Unmatched marker: just skip it. |
| 555 | 563 | $parsed .= $tag; |
| 556 | 564 | } |
@@ -589,8 +597,11 @@ discard block |
||
| 589 | 597 | preg_match('{^</?(?:' . $enclosing_tag_re . ')\b}', $tag)) |
| 590 | 598 | { |
| 591 | 599 | // Increase/decrease nested tag count. |
| 592 | - if ($tag{1} == '/') $depth--; |
|
| 593 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 600 | + if ($tag{1} == '/') { |
|
| 601 | + $depth--; |
|
| 602 | + } else if ($tag{strlen($tag)-2} != '/') { |
|
| 603 | + $depth++; |
|
| 604 | + } |
|
| 594 | 605 | |
| 595 | 606 | if ($depth < 0) { |
| 596 | 607 | // Going out of parent element. Clean up and break so we |
@@ -600,8 +611,7 @@ discard block |
||
| 600 | 611 | } |
| 601 | 612 | |
| 602 | 613 | $parsed .= $tag; |
| 603 | - } |
|
| 604 | - else { |
|
| 614 | + } else { |
|
| 605 | 615 | $parsed .= $tag; |
| 606 | 616 | } |
| 607 | 617 | } while ($depth >= 0); |
@@ -624,7 +634,9 @@ discard block |
||
| 624 | 634 | * @return array |
| 625 | 635 | */ |
| 626 | 636 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
| 627 | - if ($text === '') return array('', ''); |
|
| 637 | + if ($text === '') { |
|
| 638 | + return array('', ''); |
|
| 639 | + } |
|
| 628 | 640 | |
| 629 | 641 | // Regex to match `markdown` attribute inside of a tag. |
| 630 | 642 | $markdown_attr_re = ' |
@@ -673,8 +685,9 @@ discard block |
||
| 673 | 685 | |
| 674 | 686 | // Get the name of the starting tag. |
| 675 | 687 | // (This pattern makes $base_tag_name_re safe without quoting.) |
| 676 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
| 677 | - $base_tag_name_re = $matches[1]; |
|
| 688 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
| 689 | + $base_tag_name_re = $matches[1]; |
|
| 690 | + } |
|
| 678 | 691 | |
| 679 | 692 | // Loop through every tag until we find the corresponding closing tag. |
| 680 | 693 | do { |
@@ -703,13 +716,15 @@ discard block |
||
| 703 | 716 | { |
| 704 | 717 | // Just add the tag to the block as if it was text. |
| 705 | 718 | $block_text .= $tag; |
| 706 | - } |
|
| 707 | - else { |
|
| 719 | + } else { |
|
| 708 | 720 | // Increase/decrease nested tag count. Only do so if |
| 709 | 721 | // the tag's name match base tag's. |
| 710 | 722 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
| 711 | - if ($tag{1} == '/') $depth--; |
|
| 712 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 723 | + if ($tag{1} == '/') { |
|
| 724 | + $depth--; |
|
| 725 | + } else if ($tag{strlen($tag)-2} != '/') { |
|
| 726 | + $depth++; |
|
| 727 | + } |
|
| 713 | 728 | } |
| 714 | 729 | |
| 715 | 730 | // Check for `markdown="1"` attribute and handle it. |
@@ -754,13 +769,17 @@ discard block |
||
| 754 | 769 | } |
| 755 | 770 | |
| 756 | 771 | // Append tag content to parsed text. |
| 757 | - if (!$span_mode) $parsed .= "\n\n$block_text\n\n"; |
|
| 758 | - else $parsed .= "$block_text"; |
|
| 772 | + if (!$span_mode) { |
|
| 773 | + $parsed .= "\n\n$block_text\n\n"; |
|
| 774 | + } else { |
|
| 775 | + $parsed .= "$block_text"; |
|
| 776 | + } |
|
| 759 | 777 | |
| 760 | 778 | // Start over with a new block. |
| 761 | 779 | $block_text = ""; |
| 780 | + } else { |
|
| 781 | + $block_text .= $tag; |
|
| 762 | 782 | } |
| 763 | - else $block_text .= $tag; |
|
| 764 | 783 | } |
| 765 | 784 | |
| 766 | 785 | } while ($depth > 0); |
@@ -881,14 +900,14 @@ discard block |
||
| 881 | 900 | $title = $this->encodeAttribute($title); |
| 882 | 901 | $result .= " title=\"$title\""; |
| 883 | 902 | } |
| 884 | - if (isset($this->ref_attr[$link_id])) |
|
| 885 | - $result .= $this->ref_attr[$link_id]; |
|
| 903 | + if (isset($this->ref_attr[$link_id])) { |
|
| 904 | + $result .= $this->ref_attr[$link_id]; |
|
| 905 | + } |
|
| 886 | 906 | |
| 887 | 907 | $link_text = $this->runSpanGamut($link_text); |
| 888 | 908 | $result .= ">$link_text</a>"; |
| 889 | 909 | $result = $this->hashPart($result); |
| 890 | - } |
|
| 891 | - else { |
|
| 910 | + } else { |
|
| 892 | 911 | $result = $whole_match; |
| 893 | 912 | } |
| 894 | 913 | return $result; |
@@ -909,8 +928,9 @@ discard block |
||
| 909 | 928 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
| 910 | 929 | // tag parser and hashed. Need to reverse the process before using the URL. |
| 911 | 930 | $unhashed = $this->unhash($url); |
| 912 | - if ($unhashed != $url) |
|
| 913 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 931 | + if ($unhashed != $url) { |
|
| 932 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 933 | + } |
|
| 914 | 934 | |
| 915 | 935 | $url = $this->encodeURLAttribute($url); |
| 916 | 936 | |
@@ -1005,12 +1025,12 @@ discard block |
||
| 1005 | 1025 | $title = $this->encodeAttribute($title); |
| 1006 | 1026 | $result .= " title=\"$title\""; |
| 1007 | 1027 | } |
| 1008 | - if (isset($this->ref_attr[$link_id])) |
|
| 1009 | - $result .= $this->ref_attr[$link_id]; |
|
| 1028 | + if (isset($this->ref_attr[$link_id])) { |
|
| 1029 | + $result .= $this->ref_attr[$link_id]; |
|
| 1030 | + } |
|
| 1010 | 1031 | $result .= $this->empty_element_suffix; |
| 1011 | 1032 | $result = $this->hashPart($result); |
| 1012 | - } |
|
| 1013 | - else { |
|
| 1033 | + } else { |
|
| 1014 | 1034 | // If there's no such link ID, leave intact: |
| 1015 | 1035 | $result = $whole_match; |
| 1016 | 1036 | } |
@@ -1227,14 +1247,15 @@ discard block |
||
| 1227 | 1247 | // Reading alignement from header underline. |
| 1228 | 1248 | $separators = preg_split('/ *[|] */', $underline); |
| 1229 | 1249 | foreach ($separators as $n => $s) { |
| 1230 | - if (preg_match('/^ *-+: *$/', $s)) |
|
| 1231 | - $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 1232 | - else if (preg_match('/^ *:-+: *$/', $s)) |
|
| 1233 | - $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 1234 | - else if (preg_match('/^ *:-+ *$/', $s)) |
|
| 1235 | - $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 1236 | - else |
|
| 1237 | - $attr[$n] = ''; |
|
| 1250 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
| 1251 | + $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 1252 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
| 1253 | + $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 1254 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
| 1255 | + $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 1256 | + } else { |
|
| 1257 | + $attr[$n] = ''; |
|
| 1258 | + } |
|
| 1238 | 1259 | } |
| 1239 | 1260 | |
| 1240 | 1261 | // Parsing span elements, including code spans, character escapes, |
@@ -1248,8 +1269,9 @@ discard block |
||
| 1248 | 1269 | $text = "<table>\n"; |
| 1249 | 1270 | $text .= "<thead>\n"; |
| 1250 | 1271 | $text .= "<tr>\n"; |
| 1251 | - foreach ($headers as $n => $header) |
|
| 1252 | - $text .= " <th$attr[$n]>" . $this->runSpanGamut(trim($header)) . "</th>\n"; |
|
| 1272 | + foreach ($headers as $n => $header) { |
|
| 1273 | + $text .= " <th$attr[$n]>" . $this->runSpanGamut(trim($header)) . "</th>\n"; |
|
| 1274 | + } |
|
| 1253 | 1275 | $text .= "</tr>\n"; |
| 1254 | 1276 | $text .= "</thead>\n"; |
| 1255 | 1277 | |
@@ -1267,8 +1289,9 @@ discard block |
||
| 1267 | 1289 | $row_cells = array_pad($row_cells, $col_count, ''); |
| 1268 | 1290 | |
| 1269 | 1291 | $text .= "<tr>\n"; |
| 1270 | - foreach ($row_cells as $n => $cell) |
|
| 1271 | - $text .= " <td$attr[$n]>" . $this->runSpanGamut(trim($cell)) . "</td>\n"; |
|
| 1292 | + foreach ($row_cells as $n => $cell) { |
|
| 1293 | + $text .= " <td$attr[$n]>" . $this->runSpanGamut(trim($cell)) . "</td>\n"; |
|
| 1294 | + } |
|
| 1272 | 1295 | $text .= "</tr>\n"; |
| 1273 | 1296 | } |
| 1274 | 1297 | $text .= "</tbody>\n"; |
@@ -1415,8 +1438,7 @@ discard block |
||
| 1415 | 1438 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 1416 | 1439 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 1417 | 1440 | $def = "\n". $def ."\n"; |
| 1418 | - } |
|
| 1419 | - else { |
|
| 1441 | + } else { |
|
| 1420 | 1442 | $def = rtrim($def); |
| 1421 | 1443 | $def = $this->runSpanGamut($this->outdent($def)); |
| 1422 | 1444 | } |
@@ -1491,8 +1513,9 @@ discard block |
||
| 1491 | 1513 | |
| 1492 | 1514 | $classes = array(); |
| 1493 | 1515 | if ($classname != "") { |
| 1494 | - if ($classname{0} == '.') |
|
| 1495 | - $classname = substr($classname, 1); |
|
| 1516 | + if ($classname{0} == '.') { |
|
| 1517 | + $classname = substr($classname, 1); |
|
| 1518 | + } |
|
| 1496 | 1519 | $classes[] = $this->code_class_prefix . $classname; |
| 1497 | 1520 | } |
| 1498 | 1521 | $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @param integer $indent |
| 409 | 409 | * @param string $enclosing_tag_re |
| 410 | 410 | * @param boolean $span |
| 411 | - * @return array |
|
| 411 | + * @return string[] |
|
| 412 | 412 | */ |
| 413 | 413 | protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0, |
| 414 | 414 | $enclosing_tag_re = '', $span = false) |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @param string $text |
| 622 | 622 | * @param string $hash_method |
| 623 | 623 | * @param string $md_attr |
| 624 | - * @return array |
|
| 624 | + * @return string[] |
|
| 625 | 625 | */ |
| 626 | 626 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
| 627 | 627 | if ($text === '') return array('', ''); |
@@ -776,8 +776,9 @@ |
||
| 776 | 776 | // tag parser and hashed. Need to reverse the process before using |
| 777 | 777 | // the URL. |
| 778 | 778 | $unhashed = $this->unhash($url); |
| 779 | - if ($unhashed != $url) |
|
| 780 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 779 | + if ($unhashed != $url) { |
|
| 780 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 781 | + } |
|
| 781 | 782 | |
| 782 | 783 | $url = $this->encodeURLAttribute($url); |
| 783 | 784 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | // Try to take parser from the static parser list |
| 37 | 37 | static $parser_list; |
| 38 | - $parser =& $parser_list[$parser_class]; |
|
| 38 | + $parser = & $parser_list[$parser_class]; |
|
| 39 | 39 | |
| 40 | 40 | // Create the parser it not already set |
| 41 | 41 | if (!$parser) { |
@@ -157,15 +157,15 @@ discard block |
||
| 157 | 157 | $this->prepareItalicsAndBold(); |
| 158 | 158 | |
| 159 | 159 | $this->nested_brackets_re = |
| 160 | - str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth). |
|
| 160 | + str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) . |
|
| 161 | 161 | str_repeat('\])*', $this->nested_brackets_depth); |
| 162 | 162 | |
| 163 | 163 | $this->nested_url_parenthesis_re = |
| 164 | - str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth). |
|
| 164 | + str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) . |
|
| 165 | 165 | str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth); |
| 166 | 166 | |
| 167 | 167 | // Test change |
| 168 | - $this->escape_chars_re = '['.preg_quote($this->escape_chars).']'; |
|
| 168 | + $this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']'; |
|
| 169 | 169 | |
| 170 | 170 | // Sort document, block, and span gamut in ascendent priority order. |
| 171 | 171 | asort($this->document_gamut); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | // Link defs are in the form: ^[id]: url "optional title" |
| 286 | 286 | $text = preg_replace_callback('{ |
| 287 | - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 287 | + ^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
| 288 | 288 | [ ]* |
| 289 | 289 | \n? # maybe *one* newline |
| 290 | 290 | [ ]* |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $link_id = strtolower($matches[1]); |
| 321 | 321 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
| 322 | 322 | $this->urls[$link_id] = $url; |
| 323 | - $this->titles[$link_id] =& $matches[4]; |
|
| 323 | + $this->titles[$link_id] = & $matches[4]; |
|
| 324 | 324 | return ''; // String that will replace the block |
| 325 | 325 | } |
| 326 | 326 | |
@@ -352,9 +352,9 @@ discard block |
||
| 352 | 352 | * * List "b" is made of tags which are always block-level; |
| 353 | 353 | */ |
| 354 | 354 | $block_tags_a_re = 'ins|del'; |
| 355 | - $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'. |
|
| 356 | - 'script|noscript|style|form|fieldset|iframe|math|svg|'. |
|
| 357 | - 'article|section|nav|aside|hgroup|header|footer|'. |
|
| 355 | + $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' . |
|
| 356 | + 'script|noscript|style|form|fieldset|iframe|math|svg|' . |
|
| 357 | + 'article|section|nav|aside|hgroup|header|footer|' . |
|
| 358 | 358 | 'figure'; |
| 359 | 359 | |
| 360 | 360 | // Regular expression for the content of a block tag. |
@@ -379,12 +379,12 @@ discard block |
||
| 379 | 379 | [^<]+ # content without tag |
| 380 | 380 | | |
| 381 | 381 | <\2 # nested opening tag |
| 382 | - '.$attr.' # attributes |
|
| 382 | + '.$attr . ' # attributes |
|
| 383 | 383 | (?> |
| 384 | 384 | /> |
| 385 | 385 | | |
| 386 | - >', $nested_tags_level). // end of opening tag |
|
| 387 | - '.*?'. // last level nested tag content |
|
| 386 | + >', $nested_tags_level) . // end of opening tag |
|
| 387 | + '.*?' . // last level nested tag content |
|
| 388 | 388 | str_repeat(' |
| 389 | 389 | </\2\s*> # closing nested tag |
| 390 | 390 | ) |
@@ -420,20 +420,20 @@ discard block |
||
| 420 | 420 | # Match from `\n<tag>` to `</tag>\n`, handling nested tags |
| 421 | 421 | # in between. |
| 422 | 422 | |
| 423 | - [ ]{0,'.$less_than_tab.'} |
|
| 424 | - <('.$block_tags_b_re.')# start tag = $2 |
|
| 425 | - '.$attr.'> # attributes followed by > and \n |
|
| 426 | - '.$content.' # content, support nesting |
|
| 423 | + [ ]{0,'.$less_than_tab . '} |
|
| 424 | + <('.$block_tags_b_re . ')# start tag = $2 |
|
| 425 | + '.$attr . '> # attributes followed by > and \n |
|
| 426 | + '.$content . ' # content, support nesting |
|
| 427 | 427 | </\2> # the matching end tag |
| 428 | 428 | [ ]* # trailing spaces/tabs |
| 429 | 429 | (?=\n+|\Z) # followed by a newline or end of document |
| 430 | 430 | |
| 431 | 431 | | # Special version for tags of group a. |
| 432 | 432 | |
| 433 | - [ ]{0,'.$less_than_tab.'} |
|
| 434 | - <('.$block_tags_a_re.')# start tag = $3 |
|
| 435 | - '.$attr.'>[ ]*\n # attributes followed by > |
|
| 436 | - '.$content2.' # content, support nesting |
|
| 433 | + [ ]{0,'.$less_than_tab . '} |
|
| 434 | + <('.$block_tags_a_re . ')# start tag = $3 |
|
| 435 | + '.$attr . '>[ ]*\n # attributes followed by > |
|
| 436 | + '.$content2 . ' # content, support nesting |
|
| 437 | 437 | </\3> # the matching end tag |
| 438 | 438 | [ ]* # trailing spaces/tabs |
| 439 | 439 | (?=\n+|\Z) # followed by a newline or end of document |
@@ -441,16 +441,16 @@ discard block |
||
| 441 | 441 | | # Special case just for <hr />. It was easier to make a special |
| 442 | 442 | # case than to make the other regex more complicated. |
| 443 | 443 | |
| 444 | - [ ]{0,'.$less_than_tab.'} |
|
| 444 | + [ ]{0,'.$less_than_tab . '} |
|
| 445 | 445 | <(hr) # start tag = $2 |
| 446 | - '.$attr.' # attributes |
|
| 446 | + '.$attr . ' # attributes |
|
| 447 | 447 | /?> # the matching end tag |
| 448 | 448 | [ ]* |
| 449 | 449 | (?=\n{2,}|\Z) # followed by a blank line or end of document |
| 450 | 450 | |
| 451 | 451 | | # Special case for standalone HTML comments: |
| 452 | 452 | |
| 453 | - [ ]{0,'.$less_than_tab.'} |
|
| 453 | + [ ]{0,'.$less_than_tab . '} |
|
| 454 | 454 | (?s: |
| 455 | 455 | <!-- .*? --> |
| 456 | 456 | ) |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | | # PHP and ASP-style processor instructions (<? and <%) |
| 461 | 461 | |
| 462 | - [ ]{0,'.$less_than_tab.'} |
|
| 462 | + [ ]{0,'.$less_than_tab . '} |
|
| 463 | 463 | (?s: |
| 464 | 464 | <([?%]) # $2 |
| 465 | 465 | .*? |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | [ ]* # Tailing spaces |
| 591 | 591 | $ # End of line. |
| 592 | 592 | }mx', |
| 593 | - "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n", |
|
| 593 | + "\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n", |
|
| 594 | 594 | $text |
| 595 | 595 | ); |
| 596 | 596 | } |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | $text = preg_replace_callback('{ |
| 670 | 670 | ( # wrap whole match in $1 |
| 671 | 671 | \[ |
| 672 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 672 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 673 | 673 | \] |
| 674 | 674 | |
| 675 | 675 | [ ]? # one optional space |
@@ -686,14 +686,14 @@ discard block |
||
| 686 | 686 | $text = preg_replace_callback('{ |
| 687 | 687 | ( # wrap whole match in $1 |
| 688 | 688 | \[ |
| 689 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 689 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 690 | 690 | \] |
| 691 | 691 | \( # literal paren |
| 692 | 692 | [ \n]* |
| 693 | 693 | (?: |
| 694 | 694 | <(.+?)> # href = $3 |
| 695 | 695 | | |
| 696 | - ('.$this->nested_url_parenthesis_re.') # href = $4 |
|
| 696 | + ('.$this->nested_url_parenthesis_re . ') # href = $4 |
|
| 697 | 697 | ) |
| 698 | 698 | [ \n]* |
| 699 | 699 | ( # $5 |
@@ -729,9 +729,9 @@ discard block |
||
| 729 | 729 | * @return string |
| 730 | 730 | */ |
| 731 | 731 | protected function _doAnchors_reference_callback($matches) { |
| 732 | - $whole_match = $matches[1]; |
|
| 733 | - $link_text = $matches[2]; |
|
| 734 | - $link_id =& $matches[3]; |
|
| 732 | + $whole_match = $matches[1]; |
|
| 733 | + $link_text = $matches[2]; |
|
| 734 | + $link_id = & $matches[3]; |
|
| 735 | 735 | |
| 736 | 736 | if ($link_id == "") { |
| 737 | 737 | // for shortcut links like [this][] or [this]. |
@@ -747,10 +747,10 @@ discard block |
||
| 747 | 747 | $url = $this->encodeURLAttribute($url); |
| 748 | 748 | |
| 749 | 749 | $result = "<a href=\"$url\""; |
| 750 | - if ( isset( $this->titles[$link_id] ) ) { |
|
| 750 | + if (isset($this->titles[$link_id])) { |
|
| 751 | 751 | $title = $this->titles[$link_id]; |
| 752 | 752 | $title = $this->encodeAttribute($title); |
| 753 | - $result .= " title=\"$title\""; |
|
| 753 | + $result .= " title=\"$title\""; |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | $link_text = $this->runSpanGamut($link_text); |
@@ -768,10 +768,10 @@ discard block |
||
| 768 | 768 | * @return string |
| 769 | 769 | */ |
| 770 | 770 | protected function _doAnchors_inline_callback($matches) { |
| 771 | - $whole_match = $matches[1]; |
|
| 772 | - $link_text = $this->runSpanGamut($matches[2]); |
|
| 773 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 774 | - $title =& $matches[7]; |
|
| 771 | + $whole_match = $matches[1]; |
|
| 772 | + $link_text = $this->runSpanGamut($matches[2]); |
|
| 773 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 774 | + $title = & $matches[7]; |
|
| 775 | 775 | |
| 776 | 776 | // If the URL was of the form <s p a c e s> it got caught by the HTML |
| 777 | 777 | // tag parser and hashed. Need to reverse the process before using |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | $result = "<a href=\"$url\""; |
| 786 | 786 | if (isset($title)) { |
| 787 | 787 | $title = $this->encodeAttribute($title); |
| 788 | - $result .= " title=\"$title\""; |
|
| 788 | + $result .= " title=\"$title\""; |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | $link_text = $this->runSpanGamut($link_text); |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | $text = preg_replace_callback('{ |
| 805 | 805 | ( # wrap whole match in $1 |
| 806 | 806 | !\[ |
| 807 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 807 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 808 | 808 | \] |
| 809 | 809 | |
| 810 | 810 | [ ]? # one optional space |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | $text = preg_replace_callback('{ |
| 824 | 824 | ( # wrap whole match in $1 |
| 825 | 825 | !\[ |
| 826 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 826 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 827 | 827 | \] |
| 828 | 828 | \s? # One optional whitespace character |
| 829 | 829 | \( # literal paren |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | (?: |
| 832 | 832 | <(\S*)> # src url = $3 |
| 833 | 833 | | |
| 834 | - ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 834 | + ('.$this->nested_url_parenthesis_re . ') # src url = $4 |
|
| 835 | 835 | ) |
| 836 | 836 | [ \n]* |
| 837 | 837 | ( # $5 |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | if (isset($this->titles[$link_id])) { |
| 870 | 870 | $title = $this->titles[$link_id]; |
| 871 | 871 | $title = $this->encodeAttribute($title); |
| 872 | - $result .= " title=\"$title\""; |
|
| 872 | + $result .= " title=\"$title\""; |
|
| 873 | 873 | } |
| 874 | 874 | $result .= $this->empty_element_suffix; |
| 875 | 875 | $result = $this->hashPart($result); |
@@ -887,17 +887,17 @@ discard block |
||
| 887 | 887 | * @return string |
| 888 | 888 | */ |
| 889 | 889 | protected function _doImages_inline_callback($matches) { |
| 890 | - $whole_match = $matches[1]; |
|
| 891 | - $alt_text = $matches[2]; |
|
| 892 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 893 | - $title =& $matches[7]; |
|
| 890 | + $whole_match = $matches[1]; |
|
| 891 | + $alt_text = $matches[2]; |
|
| 892 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 893 | + $title = & $matches[7]; |
|
| 894 | 894 | |
| 895 | 895 | $alt_text = $this->encodeAttribute($alt_text); |
| 896 | 896 | $url = $this->encodeURLAttribute($url); |
| 897 | 897 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
| 898 | 898 | if (isset($title)) { |
| 899 | 899 | $title = $this->encodeAttribute($title); |
| 900 | - $result .= " title=\"$title\""; // $title already quoted |
|
| 900 | + $result .= " title=\"$title\""; // $title already quoted |
|
| 901 | 901 | } |
| 902 | 902 | $result .= $this->empty_element_suffix; |
| 903 | 903 | |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | // ID attribute generation |
| 959 | 959 | $idAtt = $this->_generateIdFromHeaderValue($matches[1]); |
| 960 | 960 | |
| 961 | - $block = "<h$level$idAtt>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
| 961 | + $block = "<h$level$idAtt>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
| 962 | 962 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 963 | 963 | } |
| 964 | 964 | |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | $idAtt = $this->_generateIdFromHeaderValue($matches[2]); |
| 973 | 973 | |
| 974 | 974 | $level = strlen($matches[1]); |
| 975 | - $block = "<h$level$idAtt>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
| 975 | + $block = "<h$level$idAtt>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
| 976 | 976 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 977 | 977 | } |
| 978 | 978 | |
@@ -1020,8 +1020,8 @@ discard block |
||
| 1020 | 1020 | $whole_list_re = ' |
| 1021 | 1021 | ( # $1 = whole list |
| 1022 | 1022 | ( # $2 |
| 1023 | - ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces |
|
| 1024 | - ('.$marker_re.') # $4 = first list item marker |
|
| 1023 | + ([ ]{0,'.$less_than_tab . '}) # $3 = number of spaces |
|
| 1024 | + ('.$marker_re . ') # $4 = first list item marker |
|
| 1025 | 1025 | [ ]+ |
| 1026 | 1026 | ) |
| 1027 | 1027 | (?s:.+?) |
@@ -1032,13 +1032,13 @@ discard block |
||
| 1032 | 1032 | (?=\S) |
| 1033 | 1033 | (?! # Negative lookahead for another list item marker |
| 1034 | 1034 | [ ]* |
| 1035 | - '.$marker_re.'[ ]+ |
|
| 1035 | + '.$marker_re . '[ ]+ |
|
| 1036 | 1036 | ) |
| 1037 | 1037 | | |
| 1038 | 1038 | (?= # Lookahead for another kind of list |
| 1039 | 1039 | \n |
| 1040 | 1040 | \3 # Must have the same indentation |
| 1041 | - '.$other_marker_re.'[ ]+ |
|
| 1041 | + '.$other_marker_re . '[ ]+ |
|
| 1042 | 1042 | ) |
| 1043 | 1043 | ) |
| 1044 | 1044 | ) |
@@ -1050,13 +1050,13 @@ discard block |
||
| 1050 | 1050 | if ($this->list_level) { |
| 1051 | 1051 | $text = preg_replace_callback('{ |
| 1052 | 1052 | ^ |
| 1053 | - '.$whole_list_re.' |
|
| 1053 | + '.$whole_list_re . ' |
|
| 1054 | 1054 | }mx', |
| 1055 | 1055 | array($this, '_doLists_callback'), $text); |
| 1056 | 1056 | } else { |
| 1057 | 1057 | $text = preg_replace_callback('{ |
| 1058 | 1058 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
| 1059 | - '.$whole_list_re.' |
|
| 1059 | + '.$whole_list_re . ' |
|
| 1060 | 1060 | }mx', |
| 1061 | 1061 | array($this, '_doLists_callback'), $text); |
| 1062 | 1062 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | $list = $matches[1]; |
| 1081 | 1081 | $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol"; |
| 1082 | 1082 | |
| 1083 | - $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re ); |
|
| 1083 | + $marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re); |
|
| 1084 | 1084 | |
| 1085 | 1085 | $list .= "\n"; |
| 1086 | 1086 | $result = $this->processListItems($list, $marker_any_re); |
@@ -1091,18 +1091,18 @@ discard block |
||
| 1091 | 1091 | if ($list_type == 'ol') { |
| 1092 | 1092 | $ol_start_array = array(); |
| 1093 | 1093 | $ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array); |
| 1094 | - if ($ol_start_check){ |
|
| 1094 | + if ($ol_start_check) { |
|
| 1095 | 1095 | $ol_start = $ol_start_array[0]; |
| 1096 | 1096 | } |
| 1097 | 1097 | } |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - if ($ol_start > 1 && $list_type == 'ol'){ |
|
| 1100 | + if ($ol_start > 1 && $list_type == 'ol') { |
|
| 1101 | 1101 | $result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>"); |
| 1102 | 1102 | } else { |
| 1103 | 1103 | $result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>"); |
| 1104 | 1104 | } |
| 1105 | - return "\n". $result ."\n\n"; |
|
| 1105 | + return "\n" . $result . "\n\n"; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | /** |
@@ -1149,12 +1149,12 @@ discard block |
||
| 1149 | 1149 | $list_str = preg_replace_callback('{ |
| 1150 | 1150 | (\n)? # leading line = $1 |
| 1151 | 1151 | (^[ ]*) # leading whitespace = $2 |
| 1152 | - ('.$marker_any_re.' # list marker and space = $3 |
|
| 1152 | + ('.$marker_any_re . ' # list marker and space = $3 |
|
| 1153 | 1153 | (?:[ ]+|(?=\n)) # space only required if item is not empty |
| 1154 | 1154 | ) |
| 1155 | 1155 | ((?s:.*?)) # list item text = $4 |
| 1156 | 1156 | (?:(\n+(?=\n))|\n) # tailing blank line = $5 |
| 1157 | - (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n)))) |
|
| 1157 | + (?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n)))) |
|
| 1158 | 1158 | }xm', |
| 1159 | 1159 | array($this, '_processListItems_callback'), $list_str); |
| 1160 | 1160 | |
@@ -1169,17 +1169,17 @@ discard block |
||
| 1169 | 1169 | */ |
| 1170 | 1170 | protected function _processListItems_callback($matches) { |
| 1171 | 1171 | $item = $matches[4]; |
| 1172 | - $leading_line =& $matches[1]; |
|
| 1173 | - $leading_space =& $matches[2]; |
|
| 1172 | + $leading_line = & $matches[1]; |
|
| 1173 | + $leading_space = & $matches[2]; |
|
| 1174 | 1174 | $marker_space = $matches[3]; |
| 1175 | - $tailing_blank_line =& $matches[5]; |
|
| 1175 | + $tailing_blank_line = & $matches[5]; |
|
| 1176 | 1176 | |
| 1177 | 1177 | if ($leading_line || $tailing_blank_line || |
| 1178 | 1178 | preg_match('/\n{2,}/', $item)) |
| 1179 | 1179 | { |
| 1180 | 1180 | // Replace marker with the appropriate whitespace indentation |
| 1181 | 1181 | $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
| 1182 | - $item = $this->runBlockGamut($this->outdent($item)."\n"); |
|
| 1182 | + $item = $this->runBlockGamut($this->outdent($item) . "\n"); |
|
| 1183 | 1183 | } else { |
| 1184 | 1184 | // Recursion for sub-lists: |
| 1185 | 1185 | $item = $this->doLists($this->outdent($item)); |
@@ -1199,11 +1199,11 @@ discard block |
||
| 1199 | 1199 | (?:\n\n|\A\n?) |
| 1200 | 1200 | ( # $1 = the code block -- one or more lines, starting with a space/tab |
| 1201 | 1201 | (?> |
| 1202 | - [ ]{'.$this->tab_width.'} # Lines must start with a tab or a tab-width of spaces |
|
| 1202 | + [ ]{'.$this->tab_width . '} # Lines must start with a tab or a tab-width of spaces |
|
| 1203 | 1203 | .*\n+ |
| 1204 | 1204 | )+ |
| 1205 | 1205 | ) |
| 1206 | - ((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
| 1206 | + ((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
| 1207 | 1207 | }xm', |
| 1208 | 1208 | array($this, '_doCodeBlocks_callback'), $text); |
| 1209 | 1209 | |
@@ -1331,8 +1331,8 @@ discard block |
||
| 1331 | 1331 | // Each token is then passed to handleSpanToken. |
| 1332 | 1332 | $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); |
| 1333 | 1333 | $text_stack[0] .= $parts[0]; |
| 1334 | - $token =& $parts[1]; |
|
| 1335 | - $text =& $parts[2]; |
|
| 1334 | + $token = & $parts[1]; |
|
| 1335 | + $text = & $parts[2]; |
|
| 1336 | 1336 | |
| 1337 | 1337 | if (empty($token)) { |
| 1338 | 1338 | // Reached end of text span: empty stack without emitting. |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | } else { |
| 1360 | 1360 | // Other closing marker: close one em or strong and |
| 1361 | 1361 | // change current token state to match the other |
| 1362 | - $token_stack[0] = str_repeat($token{0}, 3-$token_len); |
|
| 1362 | + $token_stack[0] = str_repeat($token{0}, 3 - $token_len); |
|
| 1363 | 1363 | $tag = $token_len == 2 ? "strong" : "em"; |
| 1364 | 1364 | $span = $text_stack[0]; |
| 1365 | 1365 | $span = $this->runSpanGamut($span); |
@@ -1705,7 +1705,7 @@ discard block |
||
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | $chars = preg_split('/(?<!^)(?!$)/', $text); |
| 1708 | - $seed = (int)abs(crc32($text) / strlen($text)); // Deterministic seed. |
|
| 1708 | + $seed = (int) abs(crc32($text) / strlen($text)); // Deterministic seed. |
|
| 1709 | 1709 | |
| 1710 | 1710 | foreach ($chars as $key => $char) { |
| 1711 | 1711 | $ord = ord($char); |
@@ -1718,9 +1718,9 @@ discard block |
||
| 1718 | 1718 | if ($r > 90 && strpos('@"&>', $char) === false) { |
| 1719 | 1719 | /* do nothing */ |
| 1720 | 1720 | } else if ($r < 45) { |
| 1721 | - $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1721 | + $chars[$key] = '&#x' . dechex($ord) . ';'; |
|
| 1722 | 1722 | } else { |
| 1723 | - $chars[$key] = '&#'.$ord.';'; |
|
| 1723 | + $chars[$key] = '&#' . $ord . ';'; |
|
| 1724 | 1724 | } |
| 1725 | 1725 | } |
| 1726 | 1726 | } |
@@ -1742,11 +1742,11 @@ discard block |
||
| 1742 | 1742 | |
| 1743 | 1743 | $span_re = '{ |
| 1744 | 1744 | ( |
| 1745 | - \\\\'.$this->escape_chars_re.' |
|
| 1745 | + \\\\'.$this->escape_chars_re . ' |
|
| 1746 | 1746 | | |
| 1747 | 1747 | (?<![`\\\\]) |
| 1748 | 1748 | `+ # code span marker |
| 1749 | - '.( $this->no_markup ? '' : ' |
|
| 1749 | + '.($this->no_markup ? '' : ' |
|
| 1750 | 1750 | | |
| 1751 | 1751 | <!-- .*? --> # comment |
| 1752 | 1752 | | |
@@ -1762,7 +1762,7 @@ discard block |
||
| 1762 | 1762 | <[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag |
| 1763 | 1763 | | |
| 1764 | 1764 | </[-a-zA-Z0-9:_]+\s*> # closing tag |
| 1765 | - ').' |
|
| 1765 | + ') . ' |
|
| 1766 | 1766 | ) |
| 1767 | 1767 | }xs'; |
| 1768 | 1768 | |
@@ -1799,10 +1799,10 @@ discard block |
||
| 1799 | 1799 | protected function handleSpanToken($token, &$str) { |
| 1800 | 1800 | switch ($token{0}) { |
| 1801 | 1801 | case "\\": |
| 1802 | - return $this->hashPart("&#". ord($token{1}). ";"); |
|
| 1802 | + return $this->hashPart("&#" . ord($token{1}) . ";"); |
|
| 1803 | 1803 | case "`": |
| 1804 | 1804 | // Search for end marker in remaining text. |
| 1805 | - if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', |
|
| 1805 | + if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm', |
|
| 1806 | 1806 | $str, $matches)) |
| 1807 | 1807 | { |
| 1808 | 1808 | $str = $matches[2]; |