@@ -154,10 +154,10 @@ |
||
| 154 | 154 | */ |
| 155 | 155 | protected $footnote_counter = 1; |
| 156 | 156 | |
| 157 | - /** |
|
| 158 | - * Ref attribute for links |
|
| 159 | - * @var array |
|
| 160 | - */ |
|
| 157 | + /** |
|
| 158 | + * Ref attribute for links |
|
| 159 | + * @var array |
|
| 160 | + */ |
|
| 161 | 161 | protected $ref_attr = array(); |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $this->abbr_desciptions = array(); |
| 195 | 195 | $this->abbr_word_re = ''; |
| 196 | 196 | |
| 197 | - if ( ! $this->omit_footnotes ) |
|
| 197 | + if (!$this->omit_footnotes) |
|
| 198 | 198 | $this->footnotes_assembled = ""; |
| 199 | 199 | |
| 200 | 200 | parent::teardown(); |
@@ -262,13 +262,13 @@ discard block |
||
| 262 | 262 | // Compose attributes as string |
| 263 | 263 | $attr_str = ""; |
| 264 | 264 | if (!empty($id)) { |
| 265 | - $attr_str .= ' id="'.$this->encodeAttribute($id) .'"'; |
|
| 265 | + $attr_str .= ' id="' . $this->encodeAttribute($id) . '"'; |
|
| 266 | 266 | } |
| 267 | 267 | if (!empty($classes)) { |
| 268 | - $attr_str .= ' class="'. implode(" ", $classes) . '"'; |
|
| 268 | + $attr_str .= ' class="' . implode(" ", $classes) . '"'; |
|
| 269 | 269 | } |
| 270 | 270 | if (!$this->no_markup && !empty($attributes)) { |
| 271 | - $attr_str .= ' '.implode(" ", $attributes); |
|
| 271 | + $attr_str .= ' ' . implode(" ", $attributes); |
|
| 272 | 272 | } |
| 273 | 273 | return $attr_str; |
| 274 | 274 | } |
@@ -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 | [ ]* |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | [")] |
| 304 | 304 | [ ]* |
| 305 | 305 | )? # title is optional |
| 306 | - (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
| 306 | + (?:[ ]* '.$this->id_class_attr_catch_re . ' )? # $5 = extra id & class attr |
|
| 307 | 307 | (?:\n+|\Z) |
| 308 | 308 | }xm', |
| 309 | 309 | array($this, '_stripLinkDefinitions_callback'), |
@@ -320,8 +320,8 @@ 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]; |
|
| 324 | - $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]); |
|
| 323 | + $this->titles[$link_id] = & $matches[4]; |
|
| 324 | + $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]); |
|
| 325 | 325 | return ''; // String that will replace the block |
| 326 | 326 | } |
| 327 | 327 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // Call the HTML-in-Markdown hasher. |
| 387 | - list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 387 | + list($text,) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 388 | 388 | |
| 389 | 389 | return $text; |
| 390 | 390 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | <\?.*?\?> | <%.*?%> # Processing instruction |
| 462 | 462 | | |
| 463 | 463 | <!\[CDATA\[.*?\]\]> # CData Block |
| 464 | - ' . ( !$span ? ' # If not in span. |
|
| 464 | + ' . (!$span ? ' # If not in span. |
|
| 465 | 465 | | |
| 466 | 466 | # Indented code block |
| 467 | 467 | (?: ^[ ]*\n | ^ | \n[ ]*\n ) |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | (?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes |
| 480 | 480 | [ ]* |
| 481 | 481 | (?= \n ) |
| 482 | - ' : '' ) . ' # End (if not is span). |
|
| 482 | + ' : '') . ' # End (if not is span). |
|
| 483 | 483 | | |
| 484 | 484 | # Code span marker |
| 485 | 485 | # Note, this regex needs to go after backtick fenced |
@@ -490,8 +490,8 @@ discard block |
||
| 490 | 490 | }xs'; |
| 491 | 491 | |
| 492 | 492 | |
| 493 | - $depth = 0; // Current depth inside the tag tree. |
|
| 494 | - $parsed = ""; // Parsed text that will be returned. |
|
| 493 | + $depth = 0; // Current depth inside the tag tree. |
|
| 494 | + $parsed = ""; // Parsed text that will be returned. |
|
| 495 | 495 | |
| 496 | 496 | // Loop through every tag until we find the closing tag of the parent |
| 497 | 497 | // or loop until reaching the end of text if no parent tag specified. |
@@ -568,9 +568,9 @@ discard block |
||
| 568 | 568 | // Opening Context Block tag (like ins and del) |
| 569 | 569 | // used as a block tag (tag is alone on it's line). |
| 570 | 570 | else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) || |
| 571 | - ( preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
| 571 | + (preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
| 572 | 572 | preg_match($newline_before_re, $parsed) && |
| 573 | - preg_match($newline_after_re, $text) ) |
|
| 573 | + preg_match($newline_after_re, $text)) |
|
| 574 | 574 | ) |
| 575 | 575 | { |
| 576 | 576 | // Need to parse tag and following text using the HTML parser. |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | // Increase/decrease nested tag count. |
| 601 | 601 | if ($tag{1} === '/') { |
| 602 | 602 | $depth--; |
| 603 | - } else if ($tag{strlen($tag)-2} !== '/') { |
|
| 603 | + } else if ($tag{strlen($tag) - 2} !== '/') { |
|
| 604 | 604 | $depth++; |
| 605 | 605 | } |
| 606 | 606 | |
@@ -677,11 +677,11 @@ discard block |
||
| 677 | 677 | ) |
| 678 | 678 | }xs'; |
| 679 | 679 | |
| 680 | - $original_text = $text; // Save original text in case of faliure. |
|
| 680 | + $original_text = $text; // Save original text in case of faliure. |
|
| 681 | 681 | |
| 682 | - $depth = 0; // Current depth inside the tag tree. |
|
| 683 | - $block_text = ""; // Temporary text holder for current text. |
|
| 684 | - $parsed = ""; // Parsed text that will be returned. |
|
| 682 | + $depth = 0; // Current depth inside the tag tree. |
|
| 683 | + $block_text = ""; // Temporary text holder for current text. |
|
| 684 | + $parsed = ""; // Parsed text that will be returned. |
|
| 685 | 685 | $base_tag_name_re = ''; |
| 686 | 686 | |
| 687 | 687 | // Get the name of the starting tag. |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
| 724 | 724 | if ($tag{1} === '/') { |
| 725 | 725 | $depth--; |
| 726 | - } else if ($tag{strlen($tag)-2} !== '/') { |
|
| 726 | + } else if ($tag{strlen($tag) - 2} !== '/') { |
|
| 727 | 727 | $depth++; |
| 728 | 728 | } |
| 729 | 729 | } |
@@ -877,9 +877,9 @@ discard block |
||
| 877 | 877 | * @return string |
| 878 | 878 | */ |
| 879 | 879 | protected function _doAnchors_reference_callback($matches) { |
| 880 | - $whole_match = $matches[1]; |
|
| 881 | - $link_text = $matches[2]; |
|
| 882 | - $link_id =& $matches[3]; |
|
| 880 | + $whole_match = $matches[1]; |
|
| 881 | + $link_text = $matches[2]; |
|
| 882 | + $link_id = & $matches[3]; |
|
| 883 | 883 | |
| 884 | 884 | if ($link_id == "") { |
| 885 | 885 | // for shortcut links like [this][] or [this]. |
@@ -895,10 +895,10 @@ discard block |
||
| 895 | 895 | $url = $this->encodeURLAttribute($url); |
| 896 | 896 | |
| 897 | 897 | $result = "<a href=\"$url\""; |
| 898 | - if ( isset( $this->titles[$link_id] ) ) { |
|
| 898 | + if (isset($this->titles[$link_id])) { |
|
| 899 | 899 | $title = $this->titles[$link_id]; |
| 900 | 900 | $title = $this->encodeAttribute($title); |
| 901 | - $result .= " title=\"$title\""; |
|
| 901 | + $result .= " title=\"$title\""; |
|
| 902 | 902 | } |
| 903 | 903 | if (isset($this->ref_attr[$link_id])) |
| 904 | 904 | $result .= $this->ref_attr[$link_id]; |
@@ -919,10 +919,10 @@ discard block |
||
| 919 | 919 | * @return string |
| 920 | 920 | */ |
| 921 | 921 | protected function _doAnchors_inline_callback($matches) { |
| 922 | - $link_text = $this->runSpanGamut($matches[2]); |
|
| 923 | - $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
|
| 924 | - $title =& $matches[7]; |
|
| 925 | - $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]); |
|
| 922 | + $link_text = $this->runSpanGamut($matches[2]); |
|
| 923 | + $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
|
| 924 | + $title = & $matches[7]; |
|
| 925 | + $attr = $this->doExtraAttributes("a", $dummy = & $matches[8]); |
|
| 926 | 926 | |
| 927 | 927 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
| 928 | 928 | // tag parser and hashed. Need to reverse the process before using the URL. |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | $result = "<a href=\"$url\""; |
| 936 | 936 | if (isset($title)) { |
| 937 | 937 | $title = $this->encodeAttribute($title); |
| 938 | - $result .= " title=\"$title\""; |
|
| 938 | + $result .= " title=\"$title\""; |
|
| 939 | 939 | } |
| 940 | 940 | $result .= $attr; |
| 941 | 941 | |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | if (isset($this->titles[$link_id])) { |
| 1022 | 1022 | $title = $this->titles[$link_id]; |
| 1023 | 1023 | $title = $this->encodeAttribute($title); |
| 1024 | - $result .= " title=\"$title\""; |
|
| 1024 | + $result .= " title=\"$title\""; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | if (isset($this->ref_attr[$link_id])) { |
| 1027 | 1027 | $result .= $this->ref_attr[$link_id]; |
@@ -1043,17 +1043,17 @@ discard block |
||
| 1043 | 1043 | * @return string |
| 1044 | 1044 | */ |
| 1045 | 1045 | protected function _doImages_inline_callback($matches) { |
| 1046 | - $alt_text = $matches[2]; |
|
| 1046 | + $alt_text = $matches[2]; |
|
| 1047 | 1047 | $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
| 1048 | - $title =& $matches[7]; |
|
| 1049 | - $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); |
|
| 1048 | + $title = & $matches[7]; |
|
| 1049 | + $attr = $this->doExtraAttributes("img", $dummy = & $matches[8]); |
|
| 1050 | 1050 | |
| 1051 | 1051 | $alt_text = $this->encodeAttribute($alt_text); |
| 1052 | 1052 | $url = $this->encodeURLAttribute($url); |
| 1053 | 1053 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
| 1054 | 1054 | if (isset($title)) { |
| 1055 | 1055 | $title = $this->encodeAttribute($title); |
| 1056 | - $result .= " title=\"$title\""; // $title already quoted |
|
| 1056 | + $result .= " title=\"$title\""; // $title already quoted |
|
| 1057 | 1057 | } |
| 1058 | 1058 | $result .= $attr; |
| 1059 | 1059 | $result .= $this->empty_element_suffix; |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | // |
| 1092 | 1092 | $text = preg_replace_callback('{ |
| 1093 | 1093 | ^(\#{1,6}) # $1 = string of #\'s |
| 1094 | - [ ]'.($this->hashtag_protection ? '+' : '*').' |
|
| 1094 | + [ ]'.($this->hashtag_protection ? '+' : '*') . ' |
|
| 1095 | 1095 | (.+?) # $2 = Header text |
| 1096 | 1096 | [ ]* |
| 1097 | 1097 | \#* # optional closing #\'s (not counted) |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | |
| 1119 | 1119 | $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null; |
| 1120 | 1120 | |
| 1121 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId); |
|
| 1121 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId); |
|
| 1122 | 1122 | $block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
| 1123 | 1123 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 1124 | 1124 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | $level = strlen($matches[1]); |
| 1133 | 1133 | |
| 1134 | 1134 | $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null; |
| 1135 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId); |
|
| 1135 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId); |
|
| 1136 | 1136 | $block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
| 1137 | 1137 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 1138 | 1138 | } |
@@ -1203,8 +1203,8 @@ discard block |
||
| 1203 | 1203 | * @return string |
| 1204 | 1204 | */ |
| 1205 | 1205 | protected function _doTable_leadingPipe_callback($matches) { |
| 1206 | - $head = $matches[1]; |
|
| 1207 | - $underline = $matches[2]; |
|
| 1206 | + $head = $matches[1]; |
|
| 1207 | + $underline = $matches[2]; |
|
| 1208 | 1208 | $content = $matches[3]; |
| 1209 | 1209 | |
| 1210 | 1210 | $content = preg_replace('/^ *[|]/m', '', $content); |
@@ -1233,14 +1233,14 @@ discard block |
||
| 1233 | 1233 | * @return string |
| 1234 | 1234 | */ |
| 1235 | 1235 | protected function _doTable_callback($matches) { |
| 1236 | - $head = $matches[1]; |
|
| 1237 | - $underline = $matches[2]; |
|
| 1238 | - $content = $matches[3]; |
|
| 1236 | + $head = $matches[1]; |
|
| 1237 | + $underline = $matches[2]; |
|
| 1238 | + $content = $matches[3]; |
|
| 1239 | 1239 | |
| 1240 | 1240 | // Remove any tailing pipes for each line. |
| 1241 | - $head = preg_replace('/[|] *$/m', '', $head); |
|
| 1242 | - $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 1243 | - $content = preg_replace('/[|] *$/m', '', $content); |
|
| 1241 | + $head = preg_replace('/[|] *$/m', '', $head); |
|
| 1242 | + $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 1243 | + $content = preg_replace('/[|] *$/m', '', $content); |
|
| 1244 | 1244 | |
| 1245 | 1245 | // Reading alignement from header underline. |
| 1246 | 1246 | $separators = preg_split('/ *[|] */', $underline); |
@@ -1257,10 +1257,10 @@ discard block |
||
| 1257 | 1257 | |
| 1258 | 1258 | // Parsing span elements, including code spans, character escapes, |
| 1259 | 1259 | // and inline HTML tags, so that pipes inside those gets ignored. |
| 1260 | - $head = $this->parseSpan($head); |
|
| 1261 | - $headers = preg_split('/ *[|] */', $head); |
|
| 1262 | - $col_count = count($headers); |
|
| 1263 | - $attr = array_pad($attr, $col_count, ''); |
|
| 1260 | + $head = $this->parseSpan($head); |
|
| 1261 | + $headers = preg_split('/ *[|] */', $head); |
|
| 1262 | + $col_count = count($headers); |
|
| 1263 | + $attr = array_pad($attr, $col_count, ''); |
|
| 1264 | 1264 | |
| 1265 | 1265 | // Write column headers. |
| 1266 | 1266 | $text = "<table>\n"; |
@@ -1428,13 +1428,13 @@ discard block |
||
| 1428 | 1428 | protected function _processDefListItems_callback_dd($matches) { |
| 1429 | 1429 | $leading_line = $matches[1]; |
| 1430 | 1430 | $marker_space = $matches[2]; |
| 1431 | - $def = $matches[3]; |
|
| 1431 | + $def = $matches[3]; |
|
| 1432 | 1432 | |
| 1433 | 1433 | if ($leading_line || preg_match('/\n{2,}/', $def)) { |
| 1434 | 1434 | // Replace marker with the appropriate whitespace indentation |
| 1435 | 1435 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 1436 | 1436 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 1437 | - $def = "\n". $def ."\n"; |
|
| 1437 | + $def = "\n" . $def . "\n"; |
|
| 1438 | 1438 | } |
| 1439 | 1439 | else { |
| 1440 | 1440 | $def = rtrim($def); |
@@ -1494,8 +1494,8 @@ discard block |
||
| 1494 | 1494 | * @return string |
| 1495 | 1495 | */ |
| 1496 | 1496 | protected function _doFencedCodeBlocks_callback($matches) { |
| 1497 | - $classname =& $matches[2]; |
|
| 1498 | - $attrs =& $matches[3]; |
|
| 1497 | + $classname = & $matches[2]; |
|
| 1498 | + $attrs = & $matches[3]; |
|
| 1499 | 1499 | $codeblock = $matches[4]; |
| 1500 | 1500 | |
| 1501 | 1501 | if ($this->code_block_content_func) { |
@@ -1517,9 +1517,9 @@ discard block |
||
| 1517 | 1517 | $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes); |
| 1518 | 1518 | $pre_attr_str = $this->code_attr_on_pre ? $attr_str : ''; |
| 1519 | 1519 | $code_attr_str = $this->code_attr_on_pre ? '' : $attr_str; |
| 1520 | - $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
| 1520 | + $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
| 1521 | 1521 | |
| 1522 | - return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
| 1522 | + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | /** |
@@ -1652,9 +1652,9 @@ discard block |
||
| 1652 | 1652 | $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', |
| 1653 | 1653 | array($this, '_appendFootnotes_callback'), $text); |
| 1654 | 1654 | |
| 1655 | - if ( ! empty( $this->footnotes_ordered ) ) { |
|
| 1655 | + if (!empty($this->footnotes_ordered)) { |
|
| 1656 | 1656 | $this->_doFootnotes(); |
| 1657 | - if ( ! $this->omit_footnotes ) { |
|
| 1657 | + if (!$this->omit_footnotes) { |
|
| 1658 | 1658 | $text .= "\n\n"; |
| 1659 | 1659 | $text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n"; |
| 1660 | 1660 | $text .= "<hr" . $this->empty_element_suffix . "\n"; |
@@ -1736,7 +1736,7 @@ discard block |
||
| 1736 | 1736 | // Create footnote marker only if it has a corresponding footnote *and* |
| 1737 | 1737 | // the footnote hasn't been used by another marker. |
| 1738 | 1738 | if (isset($this->footnotes[$node_id])) { |
| 1739 | - $num =& $this->footnotes_numbers[$node_id]; |
|
| 1739 | + $num = & $this->footnotes_numbers[$node_id]; |
|
| 1740 | 1740 | if (!isset($num)) { |
| 1741 | 1741 | // Transfer footnote content to the ordered list and give it its |
| 1742 | 1742 | // number |
@@ -1765,8 +1765,8 @@ discard block |
||
| 1765 | 1765 | $node_id = $this->encodeAttribute($node_id); |
| 1766 | 1766 | |
| 1767 | 1767 | return |
| 1768 | - "<sup id=\"fnref$ref_count_mark:$node_id\">". |
|
| 1769 | - "<a href=\"#fn:$node_id\"$attr>$num</a>". |
|
| 1768 | + "<sup id=\"fnref$ref_count_mark:$node_id\">" . |
|
| 1769 | + "<a href=\"#fn:$node_id\"$attr>$num</a>" . |
|
| 1770 | 1770 | "</sup>"; |
| 1771 | 1771 | } |
| 1772 | 1772 | |
@@ -176,8 +176,9 @@ discard block |
||
| 176 | 176 | $this->footnotes_assembled = ""; |
| 177 | 177 | |
| 178 | 178 | foreach ($this->predef_abbr as $abbr_word => $abbr_desc) { |
| 179 | - if ($this->abbr_word_re) |
|
| 180 | - $this->abbr_word_re .= '|'; |
|
| 179 | + if ($this->abbr_word_re) { |
|
| 180 | + $this->abbr_word_re .= '|'; |
|
| 181 | + } |
|
| 181 | 182 | $this->abbr_word_re .= preg_quote($abbr_word); |
| 182 | 183 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
| 183 | 184 | } |
@@ -194,8 +195,9 @@ discard block |
||
| 194 | 195 | $this->abbr_desciptions = array(); |
| 195 | 196 | $this->abbr_word_re = ''; |
| 196 | 197 | |
| 197 | - if ( ! $this->omit_footnotes ) |
|
| 198 | - $this->footnotes_assembled = ""; |
|
| 198 | + if ( ! $this->omit_footnotes ) { |
|
| 199 | + $this->footnotes_assembled = ""; |
|
| 200 | + } |
|
| 199 | 201 | |
| 200 | 202 | parent::teardown(); |
| 201 | 203 | } |
@@ -248,7 +250,9 @@ discard block |
||
| 248 | 250 | if ($element{0} === '.') { |
| 249 | 251 | $classes[] = substr($element, 1); |
| 250 | 252 | } else if ($element{0} === '#') { |
| 251 | - if ($id === false) $id = substr($element, 1); |
|
| 253 | + if ($id === false) { |
|
| 254 | + $id = substr($element, 1); |
|
| 255 | + } |
|
| 252 | 256 | } else if (strpos($element, '=') > 0) { |
| 253 | 257 | $parts = explode('=', $element, 2); |
| 254 | 258 | $attributes[] = $parts[0] . '="' . $parts[1] . '"'; |
@@ -424,7 +428,9 @@ discard block |
||
| 424 | 428 | $enclosing_tag_re = '', $span = false) |
| 425 | 429 | { |
| 426 | 430 | |
| 427 | - if ($text === '') return array('', ''); |
|
| 431 | + if ($text === '') { |
|
| 432 | + return array('', ''); |
|
| 433 | + } |
|
| 428 | 434 | |
| 429 | 435 | // Regex to check for the presense of newlines around a block tag. |
| 430 | 436 | $newline_before_re = '/(?:^\n?|\n\n)*$/'; |
@@ -535,8 +541,7 @@ discard block |
||
| 535 | 541 | // End marker found: pass text unchanged until marker. |
| 536 | 542 | $parsed .= $tag . $matches[0]; |
| 537 | 543 | $text = substr($text, strlen($matches[0])); |
| 538 | - } |
|
| 539 | - else { |
|
| 544 | + } else { |
|
| 540 | 545 | // No end marker: just skip it. |
| 541 | 546 | $parsed .= $tag; |
| 542 | 547 | } |
@@ -558,8 +563,7 @@ discard block |
||
| 558 | 563 | // End marker found: pass text unchanged until marker. |
| 559 | 564 | $parsed .= $tag . $matches[0]; |
| 560 | 565 | $text = substr($text, strlen($matches[0])); |
| 561 | - } |
|
| 562 | - else { |
|
| 566 | + } else { |
|
| 563 | 567 | // Unmatched marker: just skip it. |
| 564 | 568 | $parsed .= $tag; |
| 565 | 569 | } |
@@ -612,8 +616,7 @@ discard block |
||
| 612 | 616 | } |
| 613 | 617 | |
| 614 | 618 | $parsed .= $tag; |
| 615 | - } |
|
| 616 | - else { |
|
| 619 | + } else { |
|
| 617 | 620 | $parsed .= $tag; |
| 618 | 621 | } |
| 619 | 622 | } while ($depth >= 0); |
@@ -636,7 +639,9 @@ discard block |
||
| 636 | 639 | * @return array |
| 637 | 640 | */ |
| 638 | 641 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
| 639 | - if ($text === '') return array('', ''); |
|
| 642 | + if ($text === '') { |
|
| 643 | + return array('', ''); |
|
| 644 | + } |
|
| 640 | 645 | |
| 641 | 646 | // Regex to match `markdown` attribute inside of a tag. |
| 642 | 647 | $markdown_attr_re = ' |
@@ -686,8 +691,9 @@ discard block |
||
| 686 | 691 | |
| 687 | 692 | // Get the name of the starting tag. |
| 688 | 693 | // (This pattern makes $base_tag_name_re safe without quoting.) |
| 689 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
| 690 | - $base_tag_name_re = $matches[1]; |
|
| 694 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
| 695 | + $base_tag_name_re = $matches[1]; |
|
| 696 | + } |
|
| 691 | 697 | |
| 692 | 698 | // Loop through every tag until we find the corresponding closing tag. |
| 693 | 699 | do { |
@@ -716,8 +722,7 @@ discard block |
||
| 716 | 722 | { |
| 717 | 723 | // Just add the tag to the block as if it was text. |
| 718 | 724 | $block_text .= $tag; |
| 719 | - } |
|
| 720 | - else { |
|
| 725 | + } else { |
|
| 721 | 726 | // Increase/decrease nested tag count. Only do so if |
| 722 | 727 | // the tag's name match base tag's. |
| 723 | 728 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
@@ -778,8 +783,9 @@ discard block |
||
| 778 | 783 | |
| 779 | 784 | // Start over with a new block. |
| 780 | 785 | $block_text = ""; |
| 786 | + } else { |
|
| 787 | + $block_text .= $tag; |
|
| 781 | 788 | } |
| 782 | - else $block_text .= $tag; |
|
| 783 | 789 | } |
| 784 | 790 | |
| 785 | 791 | } while ($depth > 0); |
@@ -900,14 +906,14 @@ discard block |
||
| 900 | 906 | $title = $this->encodeAttribute($title); |
| 901 | 907 | $result .= " title=\"$title\""; |
| 902 | 908 | } |
| 903 | - if (isset($this->ref_attr[$link_id])) |
|
| 904 | - $result .= $this->ref_attr[$link_id]; |
|
| 909 | + if (isset($this->ref_attr[$link_id])) { |
|
| 910 | + $result .= $this->ref_attr[$link_id]; |
|
| 911 | + } |
|
| 905 | 912 | |
| 906 | 913 | $link_text = $this->runSpanGamut($link_text); |
| 907 | 914 | $result .= ">$link_text</a>"; |
| 908 | 915 | $result = $this->hashPart($result); |
| 909 | - } |
|
| 910 | - else { |
|
| 916 | + } else { |
|
| 911 | 917 | $result = $whole_match; |
| 912 | 918 | } |
| 913 | 919 | return $result; |
@@ -927,8 +933,9 @@ discard block |
||
| 927 | 933 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
| 928 | 934 | // tag parser and hashed. Need to reverse the process before using the URL. |
| 929 | 935 | $unhashed = $this->unhash($url); |
| 930 | - if ($unhashed !== $url) |
|
| 931 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 936 | + if ($unhashed !== $url) { |
|
| 937 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 938 | + } |
|
| 932 | 939 | |
| 933 | 940 | $url = $this->encodeURLAttribute($url); |
| 934 | 941 | |
@@ -1028,8 +1035,7 @@ discard block |
||
| 1028 | 1035 | } |
| 1029 | 1036 | $result .= $this->empty_element_suffix; |
| 1030 | 1037 | $result = $this->hashPart($result); |
| 1031 | - } |
|
| 1032 | - else { |
|
| 1038 | + } else { |
|
| 1033 | 1039 | // If there's no such link ID, leave intact: |
| 1034 | 1040 | $result = $whole_match; |
| 1035 | 1041 | } |
@@ -1245,14 +1251,15 @@ discard block |
||
| 1245 | 1251 | // Reading alignement from header underline. |
| 1246 | 1252 | $separators = preg_split('/ *[|] */', $underline); |
| 1247 | 1253 | foreach ($separators as $n => $s) { |
| 1248 | - if (preg_match('/^ *-+: *$/', $s)) |
|
| 1249 | - $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 1250 | - else if (preg_match('/^ *:-+: *$/', $s)) |
|
| 1251 | - $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 1252 | - else if (preg_match('/^ *:-+ *$/', $s)) |
|
| 1253 | - $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 1254 | - else |
|
| 1255 | - $attr[$n] = ''; |
|
| 1254 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
| 1255 | + $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 1256 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
| 1257 | + $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 1258 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
| 1259 | + $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 1260 | + } else { |
|
| 1261 | + $attr[$n] = ''; |
|
| 1262 | + } |
|
| 1256 | 1263 | } |
| 1257 | 1264 | |
| 1258 | 1265 | // Parsing span elements, including code spans, character escapes, |
@@ -1435,8 +1442,7 @@ discard block |
||
| 1435 | 1442 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 1436 | 1443 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 1437 | 1444 | $def = "\n". $def ."\n"; |
| 1438 | - } |
|
| 1439 | - else { |
|
| 1445 | + } else { |
|
| 1440 | 1446 | $def = rtrim($def); |
| 1441 | 1447 | $def = $this->runSpanGamut($this->outdent($def)); |
| 1442 | 1448 | } |