@@ -113,8 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | - } |
|
| 117 | - else if (!$quote) |
|
| 116 | + } else if (!$quote) |
|
| 118 | 117 | { |
| 119 | 118 | $quote = $c; |
| 120 | 119 | |
@@ -211,12 +210,10 @@ discard block |
||
| 211 | 210 | if (is_numeric($part)) |
| 212 | 211 | { |
| 213 | 212 | $part = (int) $part; |
| 214 | - } |
|
| 215 | - else if (is_float($part)) |
|
| 213 | + } else if (is_float($part)) |
|
| 216 | 214 | { |
| 217 | 215 | $part = (float) $part; |
| 218 | - } |
|
| 219 | - else |
|
| 216 | + } else |
|
| 220 | 217 | { |
| 221 | 218 | $part = constant($part); |
| 222 | 219 | } |
@@ -359,19 +356,16 @@ discard block |
||
| 359 | 356 | if (function_exists('str' . $method)) |
| 360 | 357 | { |
| 361 | 358 | $callback = 'str' . $method; |
| 362 | - } |
|
| 363 | - else if (function_exists('str_' . $method)) |
|
| 359 | + } else if (function_exists('str_' . $method)) |
|
| 364 | 360 | { |
| 365 | 361 | $callback = 'str_' . $method; |
| 366 | 362 | } |
| 367 | - } |
|
| 368 | - else if (is_array($context) || is_object($context)) |
|
| 363 | + } else if (is_array($context) || is_object($context)) |
|
| 369 | 364 | { |
| 370 | 365 | if (function_exists('ICanBoogie\array_' . $method)) |
| 371 | 366 | { |
| 372 | 367 | $callback = 'ICanBoogie\array_' . $method; |
| 373 | - } |
|
| 374 | - else if (function_exists('array_' . $method)) |
|
| 368 | + } else if (function_exists('array_' . $method)) |
|
| 375 | 369 | { |
| 376 | 370 | $callback = 'array_' . $method; |
| 377 | 371 | } |
@@ -425,13 +419,11 @@ discard block |
||
| 425 | 419 | if ($callback == 'array_shift') |
| 426 | 420 | { |
| 427 | 421 | $context = array_shift($context); |
| 428 | - } |
|
| 429 | - else |
|
| 422 | + } else |
|
| 430 | 423 | { |
| 431 | 424 | $context = call_user_func_array($callback, $args); |
| 432 | 425 | } |
| 433 | - } |
|
| 434 | - else |
|
| 426 | + } else |
|
| 435 | 427 | { |
| 436 | 428 | $context = call_user_func_array($callback, $args); |
| 437 | 429 | } |
@@ -513,8 +513,7 @@ discard block |
||
| 513 | 513 | if ($style) |
| 514 | 514 | { |
| 515 | 515 | $value = '<p style="' . $style . '">' . $value . '</p>'; |
| 516 | - } |
|
| 517 | - else |
|
| 516 | + } else |
|
| 518 | 517 | { |
| 519 | 518 | $value = "<p>$value</p>"; |
| 520 | 519 | } |
@@ -704,8 +703,7 @@ discard block |
||
| 704 | 703 | ) |
| 705 | 704 | ->fetchAndClose(); |
| 706 | 705 | |
| 707 | - } |
|
| 708 | - else |
|
| 706 | + } else |
|
| 709 | 707 | { |
| 710 | 708 | $entry = $module->model()->loadRange |
| 711 | 709 | ( |
@@ -953,16 +951,13 @@ discard block |
||
| 953 | 951 | if (($c == $in_quotes) && (($i > 1) && ($line{$i - 1} != '\\'))) |
| 954 | 952 | { |
| 955 | 953 | $in_quotes = NULL; |
| 956 | - } |
|
| 957 | - else if ($in_quotes) |
|
| 954 | + } else if ($in_quotes) |
|
| 958 | 955 | { |
| 959 | 956 | continue; |
| 960 | - } |
|
| 961 | - else if (($c == '\'') || ($c == '"')) |
|
| 957 | + } else if (($c == '\'') || ($c == '"')) |
|
| 962 | 958 | { |
| 963 | 959 | $in_quotes = $c; |
| 964 | - } |
|
| 965 | - else if (substr($line, $i, $marker_len) == $marker) |
|
| 960 | + } else if (substr($line, $i, $marker_len) == $marker) |
|
| 966 | 961 | { |
| 967 | 962 | // echo l('found marker at \1 (\2)<br />', $i, \ICanBoogie\escape(substr($line, $i, 16))); |
| 968 | 963 | |
@@ -1005,27 +1000,23 @@ discard block |
||
| 1005 | 1000 | $escaped = false; |
| 1006 | 1001 | |
| 1007 | 1002 | continue; |
| 1008 | - } |
|
| 1009 | - else if ($quote_start !== null && $c == $quote) |
|
| 1003 | + } else if ($quote_start !== null && $c == $quote) |
|
| 1010 | 1004 | { |
| 1011 | 1005 | $out .= $this->hashPart('<span class="string">' . \ICanBoogie\escape($quote . substr($text, $quote_start + 1, $i - $quote_start - 1) . $quote) . '</span>'); |
| 1012 | 1006 | |
| 1013 | 1007 | $quote_start = null; |
| 1014 | 1008 | $quote = null; |
| 1015 | - } |
|
| 1016 | - else |
|
| 1009 | + } else |
|
| 1017 | 1010 | { |
| 1018 | 1011 | $quote = $c; |
| 1019 | 1012 | $quote_start = $i; |
| 1020 | 1013 | } |
| 1021 | - } |
|
| 1022 | - else |
|
| 1014 | + } else |
|
| 1023 | 1015 | { |
| 1024 | 1016 | if ($c == '\\') |
| 1025 | 1017 | { |
| 1026 | 1018 | $escaped = !$escaped; |
| 1027 | - } |
|
| 1028 | - else |
|
| 1019 | + } else |
|
| 1029 | 1020 | { |
| 1030 | 1021 | $escaped = false; |
| 1031 | 1022 | } |
@@ -260,8 +260,7 @@ discard block |
||
| 260 | 260 | if ($args['equals'] !== null) |
| 261 | 261 | { |
| 262 | 262 | $true = $args['select'] == $args['equals']; |
| 263 | - } |
|
| 264 | - else |
|
| 263 | + } else |
|
| 265 | 264 | { |
| 266 | 265 | $true = !empty($args['test']); |
| 267 | 266 | } |
@@ -407,12 +406,10 @@ discard block |
||
| 407 | 406 | $patron->error('Ambiguous selection'); |
| 408 | 407 | |
| 409 | 408 | return null; |
| 410 | - } |
|
| 411 | - else if ($select) |
|
| 409 | + } else if ($select) |
|
| 412 | 410 | { |
| 413 | 411 | $value = $select; |
| 414 | - } |
|
| 415 | - else |
|
| 412 | + } else |
|
| 416 | 413 | { |
| 417 | 414 | $value = $patron($template); |
| 418 | 415 | } |
@@ -170,8 +170,7 @@ discard block |
||
| 170 | 170 | # |
| 171 | 171 | |
| 172 | 172 | $nodes[] = $this->parseMarkup(substr($value, 0, -1)); |
| 173 | - } |
|
| 174 | - else if ($closing) |
|
| 173 | + } else if ($closing) |
|
| 175 | 174 | { |
| 176 | 175 | # |
| 177 | 176 | # closing markup |
@@ -185,8 +184,7 @@ discard block |
||
| 185 | 184 | } |
| 186 | 185 | |
| 187 | 186 | return $nodes; |
| 188 | - } |
|
| 189 | - else |
|
| 187 | + } else |
|
| 190 | 188 | { |
| 191 | 189 | # |
| 192 | 190 | # this is an open markup with possible children |
@@ -134,12 +134,10 @@ discard block |
||
| 134 | 134 | $this->errors[] = '<div class="alert alert-error alert-danger">' . $alert->getMessage() . '</div>'; |
| 135 | 135 | |
| 136 | 136 | return; |
| 137 | - } |
|
| 138 | - else if ($alert instanceof \Exception) |
|
| 137 | + } else if ($alert instanceof \Exception) |
|
| 139 | 138 | { |
| 140 | 139 | $alert = class_exists('ICanBoogie\Debug') ? Debug::format_alert($alert) : (string) $alert; |
| 141 | - } |
|
| 142 | - else |
|
| 140 | + } else |
|
| 143 | 141 | { |
| 144 | 142 | $alert = \ICanBoogie\format($alert, $args); |
| 145 | 143 | } |
@@ -189,8 +187,7 @@ discard block |
||
| 189 | 187 | if ($e instanceof \ICanBoogie\HTTP\Exception) |
| 190 | 188 | { |
| 191 | 189 | throw $e; |
| 192 | - } |
|
| 193 | - else if ($e instanceof \ICanBoogie\ActiveRecord\Exception) |
|
| 190 | + } else if ($e instanceof \ICanBoogie\ActiveRecord\Exception) |
|
| 194 | 191 | { |
| 195 | 192 | throw $e; |
| 196 | 193 | } |
@@ -267,8 +264,7 @@ discard block |
||
| 267 | 264 | if ($template_resolver instanceof Render\BasicTemplateResolver) |
| 268 | 265 | { |
| 269 | 266 | $basic_template_resolver = $template_resolver; |
| 270 | - } |
|
| 271 | - else if ($template_resolver instanceof Render\TemplateResolverDecorator) |
|
| 267 | + } else if ($template_resolver instanceof Render\TemplateResolverDecorator) |
|
| 272 | 268 | { |
| 273 | 269 | $basic_template_resolver = $template_resolver->find_renderer(Render\BasicTemplateResolver::class); |
| 274 | 270 | } |
@@ -470,14 +466,12 @@ discard block |
||
| 470 | 466 | try |
| 471 | 467 | { |
| 472 | 468 | $rc .= $node($this, $this->context); |
| 473 | - } |
|
| 474 | - catch (\Exception $e) |
|
| 469 | + } catch (\Exception $e) |
|
| 475 | 470 | { |
| 476 | 471 | if (class_exists('ICanBoogie\Debug')) |
| 477 | 472 | { |
| 478 | 473 | $rc .= Debug::format_alert($e); |
| 479 | - } |
|
| 480 | - else |
|
| 474 | + } else |
|
| 481 | 475 | { |
| 482 | 476 | $rc .= $e; |
| 483 | 477 | } |
@@ -74,19 +74,16 @@ discard block |
||
| 74 | 74 | if ($value{0} == ':') |
| 75 | 75 | { |
| 76 | 76 | $args[$param] = substr($value, 1); |
| 77 | - } |
|
| 78 | - else |
|
| 77 | + } else |
|
| 79 | 78 | { |
| 80 | 79 | $args[$param] = $engine->evaluate($value, $silent, $context); |
| 81 | 80 | } |
| 82 | 81 | } |
| 83 | - } |
|
| 84 | - else if (isset($options['required'])) |
|
| 82 | + } else if (isset($options['required'])) |
|
| 85 | 83 | { |
| 86 | 84 | $missing[$param] = true; |
| 87 | 85 | } |
| 88 | - } |
|
| 89 | - else |
|
| 86 | + } else |
|
| 90 | 87 | { |
| 91 | 88 | if (!array_key_exists($param, $args)) |
| 92 | 89 | { |
@@ -122,8 +119,7 @@ discard block |
||
| 122 | 119 | if (isset($arg->args['select'])) |
| 123 | 120 | { |
| 124 | 121 | $arg = $engine->evaluate($arg->args['select'], false, $context); |
| 125 | - } |
|
| 126 | - else |
|
| 122 | + } else |
|
| 127 | 123 | { |
| 128 | 124 | $arg = $engine($arg->nodes); |
| 129 | 125 | } |
@@ -155,8 +151,7 @@ discard block |
||
| 155 | 151 | try |
| 156 | 152 | { |
| 157 | 153 | $rc = call_user_func($callback, $args, $engine, $this->nodes); |
| 158 | - } |
|
| 159 | - catch (\Exception $e) |
|
| 154 | + } catch (\Exception $e) |
|
| 160 | 155 | { |
| 161 | 156 | $engine->handle_exception($e); |
| 162 | 157 | } |
@@ -194,8 +194,12 @@ discard block |
||
| 194 | 194 | # Fake Textile class. It calls Markdown instead. |
| 195 | 195 | class Textile { |
| 196 | 196 | function TextileThis($text, $lite='', $encode='') { |
| 197 | - if ($lite == '' && $encode == '') $text = Markdown($text); |
|
| 198 | - if (function_exists('SmartyPants')) $text = SmartyPants($text); |
|
| 197 | + if ($lite == '' && $encode == '') { |
|
| 198 | + $text = Markdown($text); |
|
| 199 | + } |
|
| 200 | + if (function_exists('SmartyPants')) { |
|
| 201 | + $text = SmartyPants($text); |
|
| 202 | + } |
|
| 199 | 203 | return $text; |
| 200 | 204 | } |
| 201 | 205 | # Fake restricted version: restrictions are not supported for now. |
@@ -413,7 +417,9 @@ discard block |
||
| 413 | 417 | |
| 414 | 418 | |
| 415 | 419 | function hashHTMLBlocks($text) { |
| 416 | - if ($this->no_markup) return $text; |
|
| 420 | + if ($this->no_markup) { |
|
| 421 | + return $text; |
|
| 422 | + } |
|
| 417 | 423 | |
| 418 | 424 | $less_than_tab = $this->tab_width - 1; |
| 419 | 425 | |
@@ -689,7 +695,9 @@ discard block |
||
| 689 | 695 | # |
| 690 | 696 | # Turn Markdown link shortcuts into XHTML <a> tags. |
| 691 | 697 | # |
| 692 | - if ($this->in_anchor) return $text; |
|
| 698 | + if ($this->in_anchor) { |
|
| 699 | + return $text; |
|
| 700 | + } |
|
| 693 | 701 | $this->in_anchor = true; |
| 694 | 702 | |
| 695 | 703 | # |
@@ -783,8 +791,7 @@ discard block |
||
| 783 | 791 | $link_text = $this->runSpanGamut($link_text); |
| 784 | 792 | $result .= ">$link_text</a>"; |
| 785 | 793 | $result = $this->hashPart($result); |
| 786 | - } |
|
| 787 | - else { |
|
| 794 | + } else { |
|
| 788 | 795 | $result = $whole_match; |
| 789 | 796 | } |
| 790 | 797 | return $result; |
@@ -885,8 +892,7 @@ discard block |
||
| 885 | 892 | } |
| 886 | 893 | $result .= $this->empty_element_suffix; |
| 887 | 894 | $result = $this->hashPart($result); |
| 888 | - } |
|
| 889 | - else { |
|
| 895 | + } else { |
|
| 890 | 896 | # If there's no such link ID, leave intact: |
| 891 | 897 | $result = $whole_match; |
| 892 | 898 | } |
@@ -944,8 +950,9 @@ discard block |
||
| 944 | 950 | } |
| 945 | 951 | function _doHeaders_callback_setext($matches) { |
| 946 | 952 | # Terrible hack to check we haven't found an empty list item. |
| 947 | - if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) |
|
| 948 | - return $matches[0]; |
|
| 953 | + if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) { |
|
| 954 | + return $matches[0]; |
|
| 955 | + } |
|
| 949 | 956 | |
| 950 | 957 | $level = $matches[2]{0} == '=' ? 1 : 2; |
| 951 | 958 | $block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>"; |
@@ -1012,8 +1019,7 @@ discard block |
||
| 1012 | 1019 | '.$whole_list_re.' |
| 1013 | 1020 | }mx', |
| 1014 | 1021 | array(&$this, '_doLists_callback'), $text); |
| 1015 | - } |
|
| 1016 | - else { |
|
| 1022 | + } else { |
|
| 1017 | 1023 | $text = preg_replace_callback('{ |
| 1018 | 1024 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
| 1019 | 1025 | '.$whole_list_re.' |
@@ -1103,8 +1109,7 @@ discard block |
||
| 1103 | 1109 | # Replace marker with the appropriate whitespace indentation |
| 1104 | 1110 | $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
| 1105 | 1111 | $item = $this->runBlockGamut($this->outdent($item)."\n"); |
| 1106 | - } |
|
| 1107 | - else { |
|
| 1112 | + } else { |
|
| 1108 | 1113 | # Recursion for sub-lists: |
| 1109 | 1114 | $item = $this->doLists($this->outdent($item)); |
| 1110 | 1115 | $item = preg_replace('/\n+$/', '', $item); |
@@ -1149,8 +1154,7 @@ discard block |
||
| 1149 | 1154 | $class = $format_match[1]; |
| 1150 | 1155 | $codeblock = substr($codeblock, strlen($format_match[0])); |
| 1151 | 1156 | $codeblock = $this->format_codeblock($codeblock, $class); |
| 1152 | - } |
|
| 1153 | - else |
|
| 1157 | + } else |
|
| 1154 | 1158 | { |
| 1155 | 1159 | $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); |
| 1156 | 1160 | } |
@@ -1389,8 +1393,7 @@ discard block |
||
| 1389 | 1393 | $value = preg_replace('/^([ ]*)/', "<p>", $value); |
| 1390 | 1394 | $value .= "</p>"; |
| 1391 | 1395 | $grafs[$key] = $this->unhash($value); |
| 1392 | - } |
|
| 1393 | - else { |
|
| 1396 | + } else { |
|
| 1394 | 1397 | # Is a block. |
| 1395 | 1398 | # Modify elements of @grafs in-place... |
| 1396 | 1399 | $graf = $value; |
@@ -1538,8 +1541,11 @@ discard block |
||
| 1538 | 1541 | # roughly 10% raw, 45% hex, 45% dec |
| 1539 | 1542 | # '@' *must* be encoded. I insist. |
| 1540 | 1543 | if ($r > 90 && $char != '@') /* do nothing */; |
| 1541 | - else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1542 | - else $chars[$key] = '&#'.$ord.';'; |
|
| 1544 | + else if ($r < 45) { |
|
| 1545 | + $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1546 | + } else { |
|
| 1547 | + $chars[$key] = '&#'.$ord.';'; |
|
| 1548 | + } |
|
| 1543 | 1549 | } |
| 1544 | 1550 | } |
| 1545 | 1551 | |
@@ -1597,8 +1603,7 @@ discard block |
||
| 1597 | 1603 | if (isset($parts[1])) { |
| 1598 | 1604 | $output .= $this->handleSpanToken($parts[1], $parts[2]); |
| 1599 | 1605 | $str = $parts[2]; |
| 1600 | - } |
|
| 1601 | - else { |
|
| 1606 | + } else { |
|
| 1602 | 1607 | break; |
| 1603 | 1608 | } |
| 1604 | 1609 | } |
@@ -1681,7 +1686,9 @@ discard block |
||
| 1681 | 1686 | # function that will loosely count the number of UTF-8 characters with a |
| 1682 | 1687 | # regular expression. |
| 1683 | 1688 | # |
| 1684 | - if (function_exists($this->utf8_strlen)) return; |
|
| 1689 | + if (function_exists($this->utf8_strlen)) { |
|
| 1690 | + return; |
|
| 1691 | + } |
|
| 1685 | 1692 | $this->utf8_strlen = create_function('$text', 'return preg_match_all( |
| 1686 | 1693 | "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", |
| 1687 | 1694 | $text, $m);'); |
@@ -84,8 +84,9 @@ discard block |
||
| 84 | 84 | $this->footnote_counter = 1; |
| 85 | 85 | |
| 86 | 86 | foreach ($this->predef_abbr as $abbr_word => $abbr_desc) { |
| 87 | - if ($this->abbr_word_re) |
|
| 88 | - $this->abbr_word_re .= '|'; |
|
| 87 | + if ($this->abbr_word_re) { |
|
| 88 | + $this->abbr_word_re .= '|'; |
|
| 89 | + } |
|
| 89 | 90 | $this->abbr_word_re .= preg_quote($abbr_word); |
| 90 | 91 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
| 91 | 92 | } |
@@ -174,7 +175,9 @@ discard block |
||
| 174 | 175 | # |
| 175 | 176 | # Returns an array of that form: ( processed text , remaining text ) |
| 176 | 177 | # |
| 177 | - if ($text === '') return array('', ''); |
|
| 178 | + if ($text === '') { |
|
| 179 | + return array('', ''); |
|
| 180 | + } |
|
| 178 | 181 | |
| 179 | 182 | # Regex to check for the presense of newlines around a block tag. |
| 180 | 183 | $newline_before_re = '/(?:^\n?|\n\n)*$/'; |
@@ -280,8 +283,7 @@ discard block |
||
| 280 | 283 | # End marker found: pass text unchanged until marker. |
| 281 | 284 | $parsed .= $tag . $matches[0]; |
| 282 | 285 | $text = substr($text, strlen($matches[0])); |
| 283 | - } |
|
| 284 | - else { |
|
| 286 | + } else { |
|
| 285 | 287 | # Unmatched marker: just skip it. |
| 286 | 288 | $parsed .= $tag; |
| 287 | 289 | } |
@@ -298,8 +300,7 @@ discard block |
||
| 298 | 300 | # End marker found: pass text unchanged until marker. |
| 299 | 301 | $parsed .= $tag . $matches[0]; |
| 300 | 302 | $text = substr($text, strlen($matches[0])); |
| 301 | - } |
|
| 302 | - else { |
|
| 303 | + } else { |
|
| 303 | 304 | # No end marker: just skip it. |
| 304 | 305 | $parsed .= $tag; |
| 305 | 306 | } |
@@ -354,8 +355,11 @@ discard block |
||
| 354 | 355 | # |
| 355 | 356 | # Increase/decrease nested tag count. |
| 356 | 357 | # |
| 357 | - if ($tag{1} == '/') $depth--; |
|
| 358 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 358 | + if ($tag{1} == '/') { |
|
| 359 | + $depth--; |
|
| 360 | + } else if ($tag{strlen($tag)-2} != '/') { |
|
| 361 | + $depth++; |
|
| 362 | + } |
|
| 359 | 363 | |
| 360 | 364 | if ($depth < 0) { |
| 361 | 365 | # |
@@ -367,8 +371,7 @@ discard block |
||
| 367 | 371 | } |
| 368 | 372 | |
| 369 | 373 | $parsed .= $tag; |
| 370 | - } |
|
| 371 | - else { |
|
| 374 | + } else { |
|
| 372 | 375 | $parsed .= $tag; |
| 373 | 376 | } |
| 374 | 377 | } while ($depth >= 0); |
@@ -386,7 +389,9 @@ discard block |
||
| 386 | 389 | # |
| 387 | 390 | # Returns an array of that form: ( processed text , remaining text ) |
| 388 | 391 | # |
| 389 | - if ($text === '') return array('', ''); |
|
| 392 | + if ($text === '') { |
|
| 393 | + return array('', ''); |
|
| 394 | + } |
|
| 390 | 395 | |
| 391 | 396 | # Regex to match `markdown` attribute inside of a tag. |
| 392 | 397 | $markdown_attr_re = ' |
@@ -437,8 +442,9 @@ discard block |
||
| 437 | 442 | # Get the name of the starting tag. |
| 438 | 443 | # (This pattern makes $base_tag_name_re safe without quoting.) |
| 439 | 444 | # |
| 440 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
| 441 | - $base_tag_name_re = $matches[1]; |
|
| 445 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
| 446 | + $base_tag_name_re = $matches[1]; |
|
| 447 | + } |
|
| 442 | 448 | |
| 443 | 449 | # |
| 444 | 450 | # Loop through every tag until we find the corresponding closing tag. |
@@ -475,15 +481,17 @@ discard block |
||
| 475 | 481 | { |
| 476 | 482 | # Just add the tag to the block as if it was text. |
| 477 | 483 | $block_text .= $tag; |
| 478 | - } |
|
| 479 | - else { |
|
| 484 | + } else { |
|
| 480 | 485 | # |
| 481 | 486 | # Increase/decrease nested tag count. Only do so if |
| 482 | 487 | # the tag's name match base tag's. |
| 483 | 488 | # |
| 484 | 489 | if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) { |
| 485 | - if ($tag{1} == '/') $depth--; |
|
| 486 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 490 | + if ($tag{1} == '/') { |
|
| 491 | + $depth--; |
|
| 492 | + } else if ($tag{strlen($tag)-2} != '/') { |
|
| 493 | + $depth++; |
|
| 494 | + } |
|
| 487 | 495 | } |
| 488 | 496 | |
| 489 | 497 | # |
@@ -530,13 +538,17 @@ discard block |
||
| 530 | 538 | } |
| 531 | 539 | |
| 532 | 540 | # Append tag content to parsed text. |
| 533 | - if (!$span_mode) $parsed .= "\n\n$block_text\n\n"; |
|
| 534 | - else $parsed .= "$block_text"; |
|
| 541 | + if (!$span_mode) { |
|
| 542 | + $parsed .= "\n\n$block_text\n\n"; |
|
| 543 | + } else { |
|
| 544 | + $parsed .= "$block_text"; |
|
| 545 | + } |
|
| 535 | 546 | |
| 536 | 547 | # Start over a new block. |
| 537 | 548 | $block_text = ""; |
| 549 | + } else { |
|
| 550 | + $block_text .= $tag; |
|
| 538 | 551 | } |
| 539 | - else $block_text .= $tag; |
|
| 540 | 552 | } |
| 541 | 553 | |
| 542 | 554 | } while ($depth > 0); |
@@ -601,12 +613,15 @@ discard block |
||
| 601 | 613 | return $text; |
| 602 | 614 | } |
| 603 | 615 | function _doHeaders_attr($attr) { |
| 604 | - if (empty($attr)) return ""; |
|
| 616 | + if (empty($attr)) { |
|
| 617 | + return ""; |
|
| 618 | + } |
|
| 605 | 619 | return " id=\"$attr\""; |
| 606 | 620 | } |
| 607 | 621 | function _doHeaders_callback_setext($matches) { |
| 608 | - if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) |
|
| 609 | - return $matches[0]; |
|
| 622 | + if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) { |
|
| 623 | + return $matches[0]; |
|
| 624 | + } |
|
| 610 | 625 | $level = $matches[3]{0} == '=' ? 1 : 2; |
| 611 | 626 | $attr = $this->_doHeaders_attr($id =& $matches[2]); |
| 612 | 627 | $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>"; |
@@ -704,10 +719,15 @@ discard block |
||
| 704 | 719 | # Reading alignement from header underline. |
| 705 | 720 | $separators = preg_split('/ *[|] */', $underline); |
| 706 | 721 | foreach ($separators as $n => $s) { |
| 707 | - if (preg_match('/^ *-+: *$/', $s)) $attr[$n] = ' align="right"'; |
|
| 708 | - else if (preg_match('/^ *:-+: *$/', $s))$attr[$n] = ' align="center"'; |
|
| 709 | - else if (preg_match('/^ *:-+ *$/', $s)) $attr[$n] = ' align="left"'; |
|
| 710 | - else $attr[$n] = ''; |
|
| 722 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
| 723 | + $attr[$n] = ' align="right"'; |
|
| 724 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
| 725 | + $attr[$n] = ' align="center"'; |
|
| 726 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
| 727 | + $attr[$n] = ' align="left"'; |
|
| 728 | + } else { |
|
| 729 | + $attr[$n] = ''; |
|
| 730 | + } |
|
| 711 | 731 | } |
| 712 | 732 | |
| 713 | 733 | # Parsing span elements, including code spans, character escapes, |
@@ -720,8 +740,9 @@ discard block |
||
| 720 | 740 | $text = "<table>\n"; |
| 721 | 741 | $text .= "<thead>\n"; |
| 722 | 742 | $text .= "<tr>\n"; |
| 723 | - foreach ($headers as $n => $header) |
|
| 724 | - $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n"; |
|
| 743 | + foreach ($headers as $n => $header) { |
|
| 744 | + $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n"; |
|
| 745 | + } |
|
| 725 | 746 | $text .= "</tr>\n"; |
| 726 | 747 | $text .= "</thead>\n"; |
| 727 | 748 | |
@@ -739,8 +760,9 @@ discard block |
||
| 739 | 760 | $row_cells = array_pad($row_cells, $col_count, ''); |
| 740 | 761 | |
| 741 | 762 | $text .= "<tr>\n"; |
| 742 | - foreach ($row_cells as $n => $cell) |
|
| 743 | - $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n"; |
|
| 763 | + foreach ($row_cells as $n => $cell) { |
|
| 764 | + $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n"; |
|
| 765 | + } |
|
| 744 | 766 | $text .= "</tr>\n"; |
| 745 | 767 | } |
| 746 | 768 | $text .= "</tbody>\n"; |
@@ -866,8 +888,7 @@ discard block |
||
| 866 | 888 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 867 | 889 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 868 | 890 | $def = "\n". $def ."\n"; |
| 869 | - } |
|
| 870 | - else { |
|
| 891 | + } else { |
|
| 871 | 892 | $def = rtrim($def); |
| 872 | 893 | $def = $this->runSpanGamut($this->outdent($def)); |
| 873 | 894 | } |
@@ -925,8 +946,7 @@ discard block |
||
| 925 | 946 | { |
| 926 | 947 | $codeblock = $this->format_codeblock($codeblock, $class); |
| 927 | 948 | $codeblock = $this->unhash($codeblock); |
| 928 | - } |
|
| 929 | - else |
|
| 949 | + } else |
|
| 930 | 950 | { |
| 931 | 951 | $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); |
| 932 | 952 | $codeblock = preg_replace_callback('/^\n+/', array($this, '_doFencedCodeBlocks_newlines'), $codeblock); |
@@ -1161,8 +1181,9 @@ discard block |
||
| 1161 | 1181 | function _stripAbbreviations_callback($matches) { |
| 1162 | 1182 | $abbr_word = $matches[1]; |
| 1163 | 1183 | $abbr_desc = $matches[2]; |
| 1164 | - if ($this->abbr_word_re) |
|
| 1165 | - $this->abbr_word_re .= '|'; |
|
| 1184 | + if ($this->abbr_word_re) { |
|
| 1185 | + $this->abbr_word_re .= '|'; |
|
| 1186 | + } |
|
| 1166 | 1187 | $this->abbr_word_re .= preg_quote($abbr_word); |
| 1167 | 1188 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
| 1168 | 1189 | return ''; # String that will replace the block |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $nodes[] = new ControlNode($node['name'], $node['args'], $children); |
| 50 | - } |
|
| 51 | - else |
|
| 50 | + } else |
|
| 52 | 51 | { |
| 53 | 52 | # |
| 54 | 53 | # we don't resolve comments, unless they are Internet Explorer comments e.g. <!--[ |
@@ -61,8 +60,7 @@ discard block |
||
| 61 | 60 | $children = $this->parse_html_node($node); |
| 62 | 61 | |
| 63 | 62 | $nodes = array_merge($nodes, $children); |
| 64 | - } |
|
| 65 | - else |
|
| 63 | + } else |
|
| 66 | 64 | { |
| 67 | 65 | # |
| 68 | 66 | # The comments, which are on odd position, are kept intact. The text, which is |
@@ -74,8 +72,7 @@ discard block |
||
| 74 | 72 | if ($i % 2) |
| 75 | 73 | { |
| 76 | 74 | $nodes[] = new TextNode($part); |
| 77 | - } |
|
| 78 | - else |
|
| 75 | + } else |
|
| 79 | 76 | { |
| 80 | 77 | $children = $this->parse_html_node($part); |
| 81 | 78 | |
@@ -99,8 +96,7 @@ discard block |
||
| 99 | 96 | if ($i % 2) |
| 100 | 97 | { |
| 101 | 98 | $nodes[] = $this->parse_expression($part); |
| 102 | - } |
|
| 103 | - else |
|
| 99 | + } else |
|
| 104 | 100 | { |
| 105 | 101 | $nodes[] = new TextNode($part); |
| 106 | 102 | } |