@@ -207,6 +207,9 @@ discard block |
||
| 207 | 207 | return $rc; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | + /** |
|
| 211 | + * @return string |
|
| 212 | + */ |
|
| 210 | 213 | public function get_file() |
| 211 | 214 | { |
| 212 | 215 | foreach ($this->trace as $trace) |
@@ -235,6 +238,9 @@ discard block |
||
| 235 | 238 | |
| 236 | 239 | protected $templates = []; |
| 237 | 240 | |
| 241 | + /** |
|
| 242 | + * @param string $name |
|
| 243 | + */ |
|
| 238 | 244 | public function addTemplate($name, $template) |
| 239 | 245 | { |
| 240 | 246 | if (isset($this->templates[$name])) |
@@ -319,7 +325,7 @@ discard block |
||
| 319 | 325 | /** |
| 320 | 326 | * Calls a template. |
| 321 | 327 | * |
| 322 | - * @param $name |
|
| 328 | + * @param string $name |
|
| 323 | 329 | * @param array $args |
| 324 | 330 | * |
| 325 | 331 | * @return string |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param string $expression |
| 90 | 90 | * @param bool $silent |
| 91 | 91 | */ |
| 92 | - public function evaluate($expression, $silent=false, $context=null) |
|
| 92 | + public function evaluate($expression, $silent = false, $context = null) |
|
| 93 | 93 | { |
| 94 | 94 | $evaluator = $this->evaluator; |
| 95 | 95 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | array_shift($this->trace); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function error($alert, array $args=[]) |
|
| 130 | + public function error($alert, array $args = []) |
|
| 131 | 131 | { |
| 132 | 132 | if ($alert instanceof \ICanBoogie\Exception\Config) |
| 133 | 133 | { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | $tries = []; |
| 283 | - $template_pathname = $template_resolver->resolve($name, [ '.patron', '.html' ], $tries); |
|
| 283 | + $template_pathname = $template_resolver->resolve($name, ['.patron', '.html'], $tries); |
|
| 284 | 284 | |
| 285 | 285 | if ($template_pathname) |
| 286 | 286 | { |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $template_name = TemplateName::from($name); |
| 291 | - $template_pathname = $template_resolver->resolve($template_name->as_partial, [ '.patron', '.html' ], $tries); |
|
| 291 | + $template_pathname = $template_resolver->resolve($template_name->as_partial, ['.patron', '.html'], $tries); |
|
| 292 | 292 | |
| 293 | 293 | if ($template_pathname) |
| 294 | 294 | { |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $content = file_get_contents($pathname); |
| 304 | 304 | $nodes = $this->get_compiled($content); |
| 305 | 305 | |
| 306 | - return new Template($nodes, [ 'file' => $pathname ]); |
|
| 306 | + return new Template($nodes, ['file' => $pathname]); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | protected function get_template($name) |
@@ -324,14 +324,14 @@ discard block |
||
| 324 | 324 | * |
| 325 | 325 | * @return string |
| 326 | 326 | */ |
| 327 | - public function callTemplate($name, array $args=[]) |
|
| 327 | + public function callTemplate($name, array $args = []) |
|
| 328 | 328 | { |
| 329 | 329 | $template = $this->get_template($name); |
| 330 | 330 | |
| 331 | 331 | if (!$template) |
| 332 | 332 | { |
| 333 | 333 | $er = 'Unknown template %name'; |
| 334 | - $params = [ '%name' => $name ]; |
|
| 334 | + $params = ['%name' => $name]; |
|
| 335 | 335 | |
| 336 | 336 | if ($this->templates) |
| 337 | 337 | { |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | return null; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $this->trace_enter([ 'template', $name, $template ]); |
|
| 347 | + $this->trace_enter(['template', $name, $template]); |
|
| 348 | 348 | |
| 349 | 349 | $this->context['self']['arguments'] = $args; |
| 350 | 350 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | protected function init_context() |
| 369 | 369 | { |
| 370 | - $this->context = new \BlueTihi\Context([ 'self' => null, 'this' => null ]); |
|
| 370 | + $this->context = new \BlueTihi\Context(['self' => null, 'this' => null]); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /* |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | return $compiler($template); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - public function __invoke($template, $bind=null, array $options=[]) |
|
| 393 | + public function __invoke($template, $bind = null, array $options = []) |
|
| 394 | 394 | { |
| 395 | 395 | if (!$template) |
| 396 | 396 | { |
@@ -450,12 +450,12 @@ discard block |
||
| 450 | 450 | $template = $this->get_compiled($template); |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - $template = new Template($template, [ 'file' => $file ]); |
|
| 453 | + $template = new Template($template, ['file' => $file]); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | if ($template->file) |
| 457 | 457 | { |
| 458 | - $this->trace_enter([ 'file', $template->file ]); |
|
| 458 | + $this->trace_enter(['file', $template->file]); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | $rc = ''; |
@@ -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 | } |
@@ -58,6 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Tokenize Javascript style function chain into an array of identifiers and functions |
| 61 | + * @param string $str |
|
| 61 | 62 | */ |
| 62 | 63 | protected function tokenize($str) |
| 63 | 64 | { |
@@ -264,6 +265,10 @@ discard block |
||
| 264 | 265 | return $parts; |
| 265 | 266 | } |
| 266 | 267 | |
| 268 | + /** |
|
| 269 | + * @param string $expression |
|
| 270 | + * @param boolean $silent |
|
| 271 | + */ |
|
| 267 | 272 | protected function evaluate($context, $expression, $tokens, $silent, $previous_identifier='__context__') |
| 268 | 273 | { |
| 269 | 274 | $expression_path = []; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return mixed |
| 51 | 51 | */ |
| 52 | - public function __invoke($context, $expression, $silent=false) |
|
| 52 | + public function __invoke($context, $expression, $silent = false) |
|
| 53 | 53 | { |
| 54 | 54 | $tokens = $this->tokenize($expression); |
| 55 | 55 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $parts = []; |
| 84 | 84 | |
| 85 | - for ($i = 0 ; $i < $length ; $i++) |
|
| 85 | + for ($i = 0; $i < $length; $i++) |
|
| 86 | 86 | { |
| 87 | 87 | $c = $str{$i}; |
| 88 | 88 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | return $parts; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - protected function evaluate($context, $expression, $tokens, $silent, $previous_identifier='__context__') |
|
| 267 | + protected function evaluate($context, $expression, $tokens, $silent, $previous_identifier = '__context__') |
|
| 268 | 268 | { |
| 269 | 269 | $expression_path = []; |
| 270 | 270 | |
@@ -280,8 +280,7 @@ discard block |
||
| 280 | 280 | { |
| 281 | 281 | if (!is_array($context) && !is_object($context)) |
| 282 | 282 | { |
| 283 | - throw new \InvalidArgumentException(\ICanBoogie\format |
|
| 284 | - ( |
|
| 283 | + throw new \InvalidArgumentException(\ICanBoogie\format( |
|
| 285 | 284 | 'Unexpected variable type: %type (%value) for %identifier in expression %expression, should be either an array or an object', [ |
| 286 | 285 | |
| 287 | 286 | '%type' => gettype($context), |
@@ -326,7 +325,7 @@ discard block |
||
| 326 | 325 | |
| 327 | 326 | if ($args_evaluate) |
| 328 | 327 | { |
| 329 | - $this->error('we should evaluate %eval', [ '%eval' => $args_evaluate ]); |
|
| 328 | + $this->error('we should evaluate %eval', ['%eval' => $args_evaluate]); |
|
| 330 | 329 | } |
| 331 | 330 | |
| 332 | 331 | # |
@@ -335,7 +334,7 @@ discard block |
||
| 335 | 334 | |
| 336 | 335 | if (is_object($context) && method_exists($context, $method)) |
| 337 | 336 | { |
| 338 | - $context = call_user_func_array([ $context, $method ], $args); |
|
| 337 | + $context = call_user_func_array([$context, $method], $args); |
|
| 339 | 338 | |
| 340 | 339 | break; |
| 341 | 340 | } |
@@ -394,7 +393,7 @@ discard block |
||
| 394 | 393 | { |
| 395 | 394 | if (is_object($context) && method_exists($context, '__call')) |
| 396 | 395 | { |
| 397 | - $context = call_user_func_array([ $context, $method ], $args); |
|
| 396 | + $context = call_user_func_array([$context, $method], $args); |
|
| 398 | 397 | |
| 399 | 398 | break; |
| 400 | 399 | } |
@@ -461,7 +460,7 @@ discard block |
||
| 461 | 460 | * |
| 462 | 461 | * @return mixed The extracted value. |
| 463 | 462 | */ |
| 464 | - protected function extract_value($container, $identifier, &$exists=false) |
|
| 463 | + protected function extract_value($container, $identifier, &$exists = false) |
|
| 465 | 464 | { |
| 466 | 465 | $exists = false; |
| 467 | 466 | |
@@ -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 | } |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | namespace Patron; |
| 13 | 13 | |
| 14 | 14 | use Brickrouge\Pager; |
| 15 | - |
|
| 16 | 15 | use ICanBoogie\Core; |
| 17 | 16 | use ICanBoogie\Render\TemplateName; |
| 18 | 17 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $count = null; |
| 45 | 45 | $limit = null; |
| 46 | - $page = null; |
|
| 46 | + $page = null; |
|
| 47 | 47 | $range = null; |
| 48 | 48 | $noarrows = null; |
| 49 | 49 | $with = null; |
@@ -166,10 +166,8 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | if (!is_array($entries) && !is_object($entries)) |
| 168 | 168 | { |
| 169 | - $patron->error |
|
| 170 | - ( |
|
| 171 | - 'Invalid source for %param. Source must either be an array or a traversable object. Given: !entries', array |
|
| 172 | - ( |
|
| 169 | + $patron->error( |
|
| 170 | + 'Invalid source for %param. Source must either be an array or a traversable object. Given: !entries', array( |
|
| 173 | 171 | '%param' => 'in', '!entries' => $entries |
| 174 | 172 | ) |
| 175 | 173 | ); |
@@ -330,7 +328,7 @@ discard block |
||
| 330 | 328 | |
| 331 | 329 | if ($name != 'when') |
| 332 | 330 | { |
| 333 | - $patron->error('Unexpected child: :node', [ ':node' => $node ]); |
|
| 331 | + $patron->error('Unexpected child: :node', [':node' => $node]); |
|
| 334 | 332 | |
| 335 | 333 | return null; |
| 336 | 334 | } |
@@ -716,16 +714,16 @@ discard block |
||
| 716 | 714 | { |
| 717 | 715 | $app->events->attach(function(MarkupCollection\AlterEvent $event, MarkupCollection $markups) use ($app) { |
| 718 | 716 | |
| 719 | - foreach((array) $app->configs['patron.markups'] as $name => $definition) |
|
| 717 | + foreach ((array) $app->configs['patron.markups'] as $name => $definition) |
|
| 720 | 718 | { |
| 721 | - $markups[$name] = $definition + [ 1 => [ ] ]; |
|
| 719 | + $markups[$name] = $definition + [1 => []]; |
|
| 722 | 720 | } |
| 723 | 721 | |
| 724 | 722 | }); |
| 725 | 723 | |
| 726 | 724 | $app->events->attach(function(FunctionCollection\AlterEvent $event, FunctionCollection $markups) use ($app) { |
| 727 | 725 | |
| 728 | - foreach((array) $app->configs['patron.functions'] as $name => $definition) |
|
| 726 | + foreach ((array) $app->configs['patron.functions'] as $name => $definition) |
|
| 729 | 727 | { |
| 730 | 728 | $markups[$name] = $definition; |
| 731 | 729 | } |
@@ -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 | } |
@@ -87,6 +87,9 @@ |
||
| 87 | 87 | return $tree; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | + /** |
|
| 91 | + * @return string |
|
| 92 | + */ |
|
| 90 | 93 | protected function escapeSpecials($html) |
| 91 | 94 | { |
| 92 | 95 | # |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | protected $error_handler; |
| 24 | 24 | protected $namespace; |
| 25 | 25 | |
| 26 | - public function __construct(array $tags=[]) |
|
| 26 | + public function __construct(array $tags = []) |
|
| 27 | 27 | { |
| 28 | 28 | $tags += [ |
| 29 | 29 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $this->error_handler = $tags[self::T_ERROR_HANDLER]; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function parse($html, $namespace=null, $encoding='utf-8') |
|
| 41 | + public function parse($html, $namespace = null, $encoding = 'utf-8') |
|
| 42 | 42 | { |
| 43 | 43 | $this->encoding = $encoding; |
| 44 | 44 | $this->namespace = $namespace; |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | # note that i+2 might end with a '/' indicating an auto-closing markup |
| 64 | 64 | # |
| 65 | 65 | |
| 66 | - $this->matches = preg_split |
|
| 67 | - ( |
|
| 66 | + $this->matches = preg_split( |
|
| 68 | 67 | '#<(/?)' . $namespace . '([^>]*)>#', $html, -1, PREG_SPLIT_DELIM_CAPTURE |
| 69 | 68 | ); |
| 70 | 69 | |
@@ -93,13 +92,13 @@ discard block |
||
| 93 | 92 | # here we escape comments |
| 94 | 93 | # |
| 95 | 94 | |
| 96 | - $html = preg_replace_callback('#<\!--.+-->#sU', [ $this, 'escapeSpecials_callback' ], $html); |
|
| 95 | + $html = preg_replace_callback('#<\!--.+-->#sU', [$this, 'escapeSpecials_callback'], $html); |
|
| 97 | 96 | |
| 98 | 97 | # |
| 99 | 98 | # and processing options |
| 100 | 99 | # |
| 101 | 100 | |
| 102 | - $html = preg_replace_callback('#<\?.+\?>#sU', [ $this, 'escapeSpecials_callback' ], $html); |
|
| 101 | + $html = preg_replace_callback('#<\?.+\?>#sU', [$this, 'escapeSpecials_callback'], $html); |
|
| 103 | 102 | |
| 104 | 103 | return $html; |
| 105 | 104 | } |
@@ -110,10 +109,9 @@ discard block |
||
| 110 | 109 | |
| 111 | 110 | $text = $m[0]; |
| 112 | 111 | |
| 113 | - $text = str_replace |
|
| 114 | - ( |
|
| 115 | - [ '<', '>' ], |
|
| 116 | - [ "\x01", "\x02" ], |
|
| 112 | + $text = str_replace( |
|
| 113 | + ['<', '>'], |
|
| 114 | + ["\x01", "\x02"], |
|
| 117 | 115 | $text |
| 118 | 116 | ); |
| 119 | 117 | |
@@ -122,10 +120,9 @@ discard block |
||
| 122 | 120 | |
| 123 | 121 | protected function unescapeSpecials($tree) |
| 124 | 122 | { |
| 125 | - return is_array($tree) ? array_map([ $this, 'unescapeSpecials' ], $tree) : str_replace |
|
| 126 | - ( |
|
| 127 | - [ "\x01", "\x02" ], |
|
| 128 | - [ '<', '>' ], |
|
| 123 | + return is_array($tree) ? array_map([$this, 'unescapeSpecials'], $tree) : str_replace( |
|
| 124 | + ["\x01", "\x02"], |
|
| 125 | + ['<', '>'], |
|
| 129 | 126 | $tree |
| 130 | 127 | ); |
| 131 | 128 | } |
@@ -246,15 +243,14 @@ discard block |
||
| 246 | 243 | $args[$m[1]] = html_entity_decode($m[2], ENT_QUOTES, $this->encoding); |
| 247 | 244 | } |
| 248 | 245 | |
| 249 | - return [ 'name' => $name, 'args' => $args ]; |
|
| 246 | + return ['name' => $name, 'args' => $args]; |
|
| 250 | 247 | } |
| 251 | 248 | |
| 252 | 249 | protected function error($markup, $expected) |
| 253 | 250 | { |
| 254 | 251 | $this->malformed = true; |
| 255 | 252 | |
| 256 | - call_user_func |
|
| 257 | - ( |
|
| 253 | + call_user_func( |
|
| 258 | 254 | $this->error_handler, $expected |
| 259 | 255 | ? 'unexpected closing markup %markup, should be %expected' |
| 260 | 256 | : 'unexpected closing markup %markup, when none was opened', [ |
@@ -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 |
@@ -1044,6 +1044,10 @@ discard block |
||
| 1044 | 1044 | |
| 1045 | 1045 | var $list_level = 0; |
| 1046 | 1046 | |
| 1047 | + /** |
|
| 1048 | + * @param string $list_str |
|
| 1049 | + * @param string $marker_any_re |
|
| 1050 | + */ |
|
| 1047 | 1051 | function processListItems($list_str, $marker_any_re) { |
| 1048 | 1052 | # |
| 1049 | 1053 | # Process the contents of a single ordered or unordered list, splitting it |
@@ -1644,6 +1648,9 @@ discard block |
||
| 1644 | 1648 | # hanlde UTF-8 if the default function does not exist. |
| 1645 | 1649 | var $utf8_strlen = 'mb_strlen'; |
| 1646 | 1650 | |
| 1651 | + /** |
|
| 1652 | + * @param string $text |
|
| 1653 | + */ |
|
| 1647 | 1654 | function detab($text) { |
| 1648 | 1655 | # |
| 1649 | 1656 | # Replace tabs with the appropriate amount of space. |
@@ -87,10 +87,10 @@ |
||
| 87 | 87 | # - Add paragraph tag around the excerpt, but remove it for the excerpt rss. |
| 88 | 88 | if (MARKDOWN_WP_POSTS) { |
| 89 | 89 | remove_filter('the_content', 'wpautop'); |
| 90 | - remove_filter('the_content_rss', 'wpautop'); |
|
| 90 | + remove_filter('the_content_rss', 'wpautop'); |
|
| 91 | 91 | remove_filter('the_excerpt', 'wpautop'); |
| 92 | 92 | add_filter('the_content', 'mdwp_MarkdownPost', 6); |
| 93 | - add_filter('the_content_rss', 'mdwp_MarkdownPost', 6); |
|
| 93 | + add_filter('the_content_rss', 'mdwp_MarkdownPost', 6); |
|
| 94 | 94 | add_filter('get_the_excerpt', 'mdwp_MarkdownPost', 6); |
| 95 | 95 | add_filter('get_the_excerpt', 'trim', 7); |
| 96 | 96 | add_filter('the_excerpt', 'mdwp_add_p'); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | # <http://daringfireball.net/projects/markdown/> |
| 12 | 12 | # |
| 13 | 13 | |
| 14 | -define( 'MARKDOWN_VERSION', "1.0.1o" ); # Sun 8 Jan 2012 |
|
| 14 | +define('MARKDOWN_VERSION', "1.0.1o"); # Sun 8 Jan 2012 |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | # |
@@ -19,18 +19,18 @@ discard block |
||
| 19 | 19 | # |
| 20 | 20 | |
| 21 | 21 | # Change to ">" for HTML output |
| 22 | -@define( 'MARKDOWN_EMPTY_ELEMENT_SUFFIX', " />"); |
|
| 22 | +@define('MARKDOWN_EMPTY_ELEMENT_SUFFIX', " />"); |
|
| 23 | 23 | |
| 24 | 24 | # Define the width of a tab for code blocks. |
| 25 | -@define( 'MARKDOWN_TAB_WIDTH', 4 ); |
|
| 25 | +@define('MARKDOWN_TAB_WIDTH', 4); |
|
| 26 | 26 | |
| 27 | 27 | # Optional title attribute for footnote links and backlinks. |
| 28 | -@define( 'MARKDOWN_FN_LINK_TITLE', "" ); |
|
| 29 | -@define( 'MARKDOWN_FN_BACKLINK_TITLE', "" ); |
|
| 28 | +@define('MARKDOWN_FN_LINK_TITLE', ""); |
|
| 29 | +@define('MARKDOWN_FN_BACKLINK_TITLE', ""); |
|
| 30 | 30 | |
| 31 | 31 | # Optional class attribute for footnote links and backlinks. |
| 32 | -@define( 'MARKDOWN_FN_LINK_CLASS', "" ); |
|
| 33 | -@define( 'MARKDOWN_FN_BACKLINK_CLASS', "" ); |
|
| 32 | +@define('MARKDOWN_FN_LINK_CLASS', ""); |
|
| 33 | +@define('MARKDOWN_FN_BACKLINK_CLASS', ""); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | # |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | # |
| 39 | 39 | |
| 40 | 40 | # Change to false to remove Markdown from posts and/or comments. |
| 41 | -@define( 'MARKDOWN_WP_POSTS', true ); |
|
| 42 | -@define( 'MARKDOWN_WP_COMMENTS', true ); |
|
| 41 | +@define('MARKDOWN_WP_POSTS', true); |
|
| 42 | +@define('MARKDOWN_WP_COMMENTS', true); |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | if (!defined('MARKDOWN_PARSER_CLASS')) |
| 49 | 49 | { |
| 50 | - define( 'MARKDOWN_PARSER_CLASS', 'MarkdownExtra_Parser' ); |
|
| 50 | + define('MARKDOWN_PARSER_CLASS', 'MarkdownExtra_Parser'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | function Markdown($text) { |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | # - Run Markdown on excerpt, then remove all tags. |
| 87 | 87 | # - Add paragraph tag around the excerpt, but remove it for the excerpt rss. |
| 88 | 88 | if (MARKDOWN_WP_POSTS) { |
| 89 | - remove_filter('the_content', 'wpautop'); |
|
| 89 | + remove_filter('the_content', 'wpautop'); |
|
| 90 | 90 | remove_filter('the_content_rss', 'wpautop'); |
| 91 | - remove_filter('the_excerpt', 'wpautop'); |
|
| 92 | - add_filter('the_content', 'mdwp_MarkdownPost', 6); |
|
| 91 | + remove_filter('the_excerpt', 'wpautop'); |
|
| 92 | + add_filter('the_content', 'mdwp_MarkdownPost', 6); |
|
| 93 | 93 | add_filter('the_content_rss', 'mdwp_MarkdownPost', 6); |
| 94 | 94 | add_filter('get_the_excerpt', 'mdwp_MarkdownPost', 6); |
| 95 | 95 | add_filter('get_the_excerpt', 'trim', 7); |
| 96 | - add_filter('the_excerpt', 'mdwp_add_p'); |
|
| 96 | + add_filter('the_excerpt', 'mdwp_add_p'); |
|
| 97 | 97 | add_filter('the_excerpt_rss', 'mdwp_strip_p'); |
| 98 | 98 | |
| 99 | - remove_filter('content_save_pre', 'balanceTags', 50); |
|
| 100 | - remove_filter('excerpt_save_pre', 'balanceTags', 50); |
|
| 101 | - add_filter('the_content', 'balanceTags', 50); |
|
| 99 | + remove_filter('content_save_pre', 'balanceTags', 50); |
|
| 100 | + remove_filter('excerpt_save_pre', 'balanceTags', 50); |
|
| 101 | + add_filter('the_content', 'balanceTags', 50); |
|
| 102 | 102 | add_filter('get_the_excerpt', 'balanceTags', 9); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | add_filter('pre_comment_content', 'Markdown', 6); |
| 129 | 129 | add_filter('pre_comment_content', 'mdwp_hide_tags', 8); |
| 130 | 130 | add_filter('pre_comment_content', 'mdwp_show_tags', 12); |
| 131 | - add_filter('get_comment_text', 'Markdown', 6); |
|
| 131 | + add_filter('get_comment_text', 'Markdown', 6); |
|
| 132 | 132 | add_filter('get_comment_excerpt', 'Markdown', 6); |
| 133 | 133 | add_filter('get_comment_excerpt', 'mdwp_strip_p', 7); |
| 134 | 134 | |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | $mdwp_hidden_tags = explode(' ', |
| 137 | 137 | '<p> </p> <pre> </pre> <ol> </ol> <ul> </ul> <li> </li>'); |
| 138 | 138 | $mdwp_placeholders = explode(' ', str_rot13( |
| 139 | - 'pEj07ZbbBZ U1kqgh4w4p pre2zmeN6K QTi31t9pre ol0MP1jzJR '. |
|
| 139 | + 'pEj07ZbbBZ U1kqgh4w4p pre2zmeN6K QTi31t9pre ol0MP1jzJR ' . |
|
| 140 | 140 | 'ML5IjmbRol ulANi1NsGY J7zRLJqPul liA8ctl16T K9nhooUHli')); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | function mdwp_add_p($text) { |
| 144 | 144 | if (!preg_match('{^$|^<(p|ul|ol|dl|pre|blockquote)>}i', $text)) { |
| 145 | - $text = '<p>'.$text.'</p>'; |
|
| 145 | + $text = '<p>' . $text . '</p>'; |
|
| 146 | 146 | $text = preg_replace('{\n{2,}}', "</p>\n\n<p>", $text); |
| 147 | 147 | } |
| 148 | 148 | return $text; |
@@ -193,13 +193,13 @@ discard block |
||
| 193 | 193 | @include_once 'smartypants.php'; |
| 194 | 194 | # Fake Textile class. It calls Markdown instead. |
| 195 | 195 | class Textile { |
| 196 | - function TextileThis($text, $lite='', $encode='') { |
|
| 196 | + function TextileThis($text, $lite = '', $encode = '') { |
|
| 197 | 197 | if ($lite == '' && $encode == '') $text = Markdown($text); |
| 198 | 198 | if (function_exists('SmartyPants')) $text = SmartyPants($text); |
| 199 | 199 | return $text; |
| 200 | 200 | } |
| 201 | 201 | # Fake restricted version: restrictions are not supported for now. |
| 202 | - function TextileRestricted($text, $lite='', $noimage='') { |
|
| 202 | + function TextileRestricted($text, $lite = '', $noimage = '') { |
|
| 203 | 203 | return $this->TextileThis($text, $lite); |
| 204 | 204 | } |
| 205 | 205 | # Workaround to ensure compatibility with TextPattern 4.0.3. |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | $this->prepareItalicsAndBold(); |
| 249 | 249 | |
| 250 | 250 | $this->nested_brackets_re = |
| 251 | - str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth). |
|
| 251 | + str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) . |
|
| 252 | 252 | str_repeat('\])*', $this->nested_brackets_depth); |
| 253 | 253 | |
| 254 | 254 | $this->nested_url_parenthesis_re = |
| 255 | - str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth). |
|
| 255 | + str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) . |
|
| 256 | 256 | str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth); |
| 257 | 257 | |
| 258 | - $this->escape_chars_re = '['.preg_quote($this->escape_chars).']'; |
|
| 258 | + $this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']'; |
|
| 259 | 259 | |
| 260 | 260 | # Sort document, block, and span gamut in ascendent priority order. |
| 261 | 261 | asort($this->early_gamut); // @olvlv |
@@ -342,13 +342,11 @@ discard block |
||
| 342 | 342 | return $text . "\n"; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - public $early_gamut = array |
|
| 346 | - ( |
|
| 345 | + public $early_gamut = array( |
|
| 347 | 346 | 'doFencedCodeBlocks' => 5 |
| 348 | 347 | ); |
| 349 | 348 | |
| 350 | - var $document_gamut = array |
|
| 351 | - ( |
|
| 349 | + var $document_gamut = array( |
|
| 352 | 350 | # Strip link definitions, store in hashes. |
| 353 | 351 | "stripLinkDefinitions" => 20, |
| 354 | 352 | |
@@ -359,8 +357,7 @@ discard block |
||
| 359 | 357 | * @var array These are all the transformations that form block-level tags like paragraphs, headers, and |
| 360 | 358 | * list items. |
| 361 | 359 | */ |
| 362 | - public $block_gamut = array |
|
| 363 | - ( |
|
| 360 | + public $block_gamut = array( |
|
| 364 | 361 | "doHeaders" => 10, |
| 365 | 362 | "doHorizontalRules" => 20, |
| 366 | 363 | |
@@ -378,7 +375,7 @@ discard block |
||
| 378 | 375 | |
| 379 | 376 | # Link defs are in the form: ^[id]: url "optional title" |
| 380 | 377 | $text = preg_replace_callback('{ |
| 381 | - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 378 | + ^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
| 382 | 379 | [ ]* |
| 383 | 380 | \n? # maybe *one* newline |
| 384 | 381 | [ ]* |
@@ -407,7 +404,7 @@ discard block |
||
| 407 | 404 | $link_id = strtolower($matches[1]); |
| 408 | 405 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
| 409 | 406 | $this->urls[$link_id] = $url; |
| 410 | - $this->titles[$link_id] =& $matches[4]; |
|
| 407 | + $this->titles[$link_id] = & $matches[4]; |
|
| 411 | 408 | return ''; # String that will replace the block |
| 412 | 409 | } |
| 413 | 410 | |
@@ -431,7 +428,7 @@ discard block |
||
| 431 | 428 | # * List "b" is made of tags which are always block-level; |
| 432 | 429 | # |
| 433 | 430 | $block_tags_a_re = 'ins|del'; |
| 434 | - $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'. |
|
| 431 | + $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' . |
|
| 435 | 432 | 'script|noscript|form|fieldset|iframe|math'; |
| 436 | 433 | |
| 437 | 434 | # Regular expression for the content of a block tag. |
@@ -456,12 +453,12 @@ discard block |
||
| 456 | 453 | [^<]+ # content without tag |
| 457 | 454 | | |
| 458 | 455 | <\2 # nested opening tag |
| 459 | - '.$attr.' # attributes |
|
| 456 | + '.$attr . ' # attributes |
|
| 460 | 457 | (?> |
| 461 | 458 | /> |
| 462 | 459 | | |
| 463 | - >', $nested_tags_level). # end of opening tag |
|
| 464 | - '.*?'. # last level nested tag content |
|
| 460 | + >', $nested_tags_level) . # end of opening tag |
|
| 461 | + '.*?' . # last level nested tag content |
|
| 465 | 462 | str_repeat(' |
| 466 | 463 | </\2\s*> # closing nested tag |
| 467 | 464 | ) |
@@ -494,20 +491,20 @@ discard block |
||
| 494 | 491 | # Match from `\n<tag>` to `</tag>\n`, handling nested tags |
| 495 | 492 | # in between. |
| 496 | 493 | |
| 497 | - [ ]{0,'.$less_than_tab.'} |
|
| 498 | - <('.$block_tags_b_re.')# start tag = $2 |
|
| 499 | - '.$attr.'> # attributes followed by > and \n |
|
| 500 | - '.$content.' # content, support nesting |
|
| 494 | + [ ]{0,'.$less_than_tab . '} |
|
| 495 | + <('.$block_tags_b_re . ')# start tag = $2 |
|
| 496 | + '.$attr . '> # attributes followed by > and \n |
|
| 497 | + '.$content . ' # content, support nesting |
|
| 501 | 498 | </\2> # the matching end tag |
| 502 | 499 | [ ]* # trailing spaces/tabs |
| 503 | 500 | (?=\n+|\Z) # followed by a newline or end of document |
| 504 | 501 | |
| 505 | 502 | | # Special version for tags of group a. |
| 506 | 503 | |
| 507 | - [ ]{0,'.$less_than_tab.'} |
|
| 508 | - <('.$block_tags_a_re.')# start tag = $3 |
|
| 509 | - '.$attr.'>[ ]*\n # attributes followed by > |
|
| 510 | - '.$content2.' # content, support nesting |
|
| 504 | + [ ]{0,'.$less_than_tab . '} |
|
| 505 | + <('.$block_tags_a_re . ')# start tag = $3 |
|
| 506 | + '.$attr . '>[ ]*\n # attributes followed by > |
|
| 507 | + '.$content2 . ' # content, support nesting |
|
| 511 | 508 | </\3> # the matching end tag |
| 512 | 509 | [ ]* # trailing spaces/tabs |
| 513 | 510 | (?=\n+|\Z) # followed by a newline or end of document |
@@ -515,16 +512,16 @@ discard block |
||
| 515 | 512 | | # Special case just for <hr />. It was easier to make a special |
| 516 | 513 | # case than to make the other regex more complicated. |
| 517 | 514 | |
| 518 | - [ ]{0,'.$less_than_tab.'} |
|
| 515 | + [ ]{0,'.$less_than_tab . '} |
|
| 519 | 516 | <(hr) # start tag = $2 |
| 520 | - '.$attr.' # attributes |
|
| 517 | + '.$attr . ' # attributes |
|
| 521 | 518 | /?> # the matching end tag |
| 522 | 519 | [ ]* |
| 523 | 520 | (?=\n{2,}|\Z) # followed by a blank line or end of document |
| 524 | 521 | |
| 525 | 522 | | # Special case for standalone HTML comments: |
| 526 | 523 | |
| 527 | - [ ]{0,'.$less_than_tab.'} |
|
| 524 | + [ ]{0,'.$less_than_tab . '} |
|
| 528 | 525 | (?s: |
| 529 | 526 | <!-- .*? --> |
| 530 | 527 | ) |
@@ -533,7 +530,7 @@ discard block |
||
| 533 | 530 | |
| 534 | 531 | | # PHP and ASP-style processor instructions (<? and <%) |
| 535 | 532 | |
| 536 | - [ ]{0,'.$less_than_tab.'} |
|
| 533 | + [ ]{0,'.$less_than_tab . '} |
|
| 537 | 534 | (?s: |
| 538 | 535 | <([?%]) # $2 |
| 539 | 536 | .*? |
@@ -634,7 +631,7 @@ discard block |
||
| 634 | 631 | [ ]* # Tailing spaces |
| 635 | 632 | $ # End of line. |
| 636 | 633 | }mx', |
| 637 | - "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n", |
|
| 634 | + "\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n", |
|
| 638 | 635 | $text); |
| 639 | 636 | } |
| 640 | 637 | |
@@ -698,7 +695,7 @@ discard block |
||
| 698 | 695 | $text = preg_replace_callback('{ |
| 699 | 696 | ( # wrap whole match in $1 |
| 700 | 697 | \[ |
| 701 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 698 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 702 | 699 | \] |
| 703 | 700 | |
| 704 | 701 | [ ]? # one optional space |
@@ -717,14 +714,14 @@ discard block |
||
| 717 | 714 | $text = preg_replace_callback('{ |
| 718 | 715 | ( # wrap whole match in $1 |
| 719 | 716 | \[ |
| 720 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 717 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 721 | 718 | \] |
| 722 | 719 | \( # literal paren |
| 723 | 720 | [ \n]* |
| 724 | 721 | (?: |
| 725 | 722 | <(.+?)> # href = $3 |
| 726 | 723 | | |
| 727 | - ('.$this->nested_url_parenthesis_re.') # href = $4 |
|
| 724 | + ('.$this->nested_url_parenthesis_re . ') # href = $4 |
|
| 728 | 725 | ) |
| 729 | 726 | [ \n]* |
| 730 | 727 | ( # $5 |
@@ -756,9 +753,9 @@ discard block |
||
| 756 | 753 | return $text; |
| 757 | 754 | } |
| 758 | 755 | function _doAnchors_reference_callback($matches) { |
| 759 | - $whole_match = $matches[1]; |
|
| 760 | - $link_text = $matches[2]; |
|
| 761 | - $link_id =& $matches[3]; |
|
| 756 | + $whole_match = $matches[1]; |
|
| 757 | + $link_text = $matches[2]; |
|
| 758 | + $link_id = & $matches[3]; |
|
| 762 | 759 | |
| 763 | 760 | if ($link_id == "") { |
| 764 | 761 | # for shortcut links like [this][] or [this]. |
@@ -774,10 +771,10 @@ discard block |
||
| 774 | 771 | $url = $this->encodeAttribute($url); |
| 775 | 772 | |
| 776 | 773 | $result = "<a href=\"$url\""; |
| 777 | - if ( isset( $this->titles[$link_id] ) ) { |
|
| 774 | + if (isset($this->titles[$link_id])) { |
|
| 778 | 775 | $title = $this->titles[$link_id]; |
| 779 | 776 | $title = $this->encodeAttribute($title); |
| 780 | - $result .= " title=\"$title\""; |
|
| 777 | + $result .= " title=\"$title\""; |
|
| 781 | 778 | } |
| 782 | 779 | |
| 783 | 780 | $link_text = $this->runSpanGamut($link_text); |
@@ -790,17 +787,17 @@ discard block |
||
| 790 | 787 | return $result; |
| 791 | 788 | } |
| 792 | 789 | function _doAnchors_inline_callback($matches) { |
| 793 | - $whole_match = $matches[1]; |
|
| 794 | - $link_text = $this->runSpanGamut($matches[2]); |
|
| 795 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 796 | - $title =& $matches[7]; |
|
| 790 | + $whole_match = $matches[1]; |
|
| 791 | + $link_text = $this->runSpanGamut($matches[2]); |
|
| 792 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 793 | + $title = & $matches[7]; |
|
| 797 | 794 | |
| 798 | 795 | $url = $this->encodeAttribute($url); |
| 799 | 796 | |
| 800 | 797 | $result = "<a href=\"$url\""; |
| 801 | 798 | if (isset($title)) { |
| 802 | 799 | $title = $this->encodeAttribute($title); |
| 803 | - $result .= " title=\"$title\""; |
|
| 800 | + $result .= " title=\"$title\""; |
|
| 804 | 801 | } |
| 805 | 802 | |
| 806 | 803 | $link_text = $this->runSpanGamut($link_text); |
@@ -820,7 +817,7 @@ discard block |
||
| 820 | 817 | $text = preg_replace_callback('{ |
| 821 | 818 | ( # wrap whole match in $1 |
| 822 | 819 | !\[ |
| 823 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 820 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 824 | 821 | \] |
| 825 | 822 | |
| 826 | 823 | [ ]? # one optional space |
@@ -841,7 +838,7 @@ discard block |
||
| 841 | 838 | $text = preg_replace_callback('{ |
| 842 | 839 | ( # wrap whole match in $1 |
| 843 | 840 | !\[ |
| 844 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 841 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 845 | 842 | \] |
| 846 | 843 | \s? # One optional whitespace character |
| 847 | 844 | \( # literal paren |
@@ -849,7 +846,7 @@ discard block |
||
| 849 | 846 | (?: |
| 850 | 847 | <(\S*)> # src url = $3 |
| 851 | 848 | | |
| 852 | - ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 849 | + ('.$this->nested_url_parenthesis_re . ') # src url = $4 |
|
| 853 | 850 | ) |
| 854 | 851 | [ \n]* |
| 855 | 852 | ( # $5 |
@@ -881,7 +878,7 @@ discard block |
||
| 881 | 878 | if (isset($this->titles[$link_id])) { |
| 882 | 879 | $title = $this->titles[$link_id]; |
| 883 | 880 | $title = $this->encodeAttribute($title); |
| 884 | - $result .= " title=\"$title\""; |
|
| 881 | + $result .= " title=\"$title\""; |
|
| 885 | 882 | } |
| 886 | 883 | $result .= $this->empty_element_suffix; |
| 887 | 884 | $result = $this->hashPart($result); |
@@ -894,17 +891,17 @@ discard block |
||
| 894 | 891 | return $result; |
| 895 | 892 | } |
| 896 | 893 | function _doImages_inline_callback($matches) { |
| 897 | - $whole_match = $matches[1]; |
|
| 898 | - $alt_text = $matches[2]; |
|
| 899 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 900 | - $title =& $matches[7]; |
|
| 894 | + $whole_match = $matches[1]; |
|
| 895 | + $alt_text = $matches[2]; |
|
| 896 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 897 | + $title = & $matches[7]; |
|
| 901 | 898 | |
| 902 | 899 | $alt_text = $this->encodeAttribute($alt_text); |
| 903 | 900 | $url = $this->encodeAttribute($url); |
| 904 | 901 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
| 905 | 902 | if (isset($title)) { |
| 906 | 903 | $title = $this->encodeAttribute($title); |
| 907 | - $result .= " title=\"$title\""; # $title already quoted |
|
| 904 | + $result .= " title=\"$title\""; # $title already quoted |
|
| 908 | 905 | } |
| 909 | 906 | $result .= $this->empty_element_suffix; |
| 910 | 907 | |
@@ -948,12 +945,12 @@ discard block |
||
| 948 | 945 | return $matches[0]; |
| 949 | 946 | |
| 950 | 947 | $level = $matches[2]{0} == '=' ? 1 : 2; |
| 951 | - $block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
| 948 | + $block = "<h$level>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
| 952 | 949 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 953 | 950 | } |
| 954 | 951 | function _doHeaders_callback_atx($matches) { |
| 955 | 952 | $level = strlen($matches[1]); |
| 956 | - $block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
| 953 | + $block = "<h$level>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
| 957 | 954 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 958 | 955 | } |
| 959 | 956 | |
@@ -979,8 +976,8 @@ discard block |
||
| 979 | 976 | $whole_list_re = ' |
| 980 | 977 | ( # $1 = whole list |
| 981 | 978 | ( # $2 |
| 982 | - ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces |
|
| 983 | - ('.$marker_re.') # $4 = first list item marker |
|
| 979 | + ([ ]{0,'.$less_than_tab . '}) # $3 = number of spaces |
|
| 980 | + ('.$marker_re . ') # $4 = first list item marker |
|
| 984 | 981 | [ ]+ |
| 985 | 982 | ) |
| 986 | 983 | (?s:.+?) |
@@ -991,13 +988,13 @@ discard block |
||
| 991 | 988 | (?=\S) |
| 992 | 989 | (?! # Negative lookahead for another list item marker |
| 993 | 990 | [ ]* |
| 994 | - '.$marker_re.'[ ]+ |
|
| 991 | + '.$marker_re . '[ ]+ |
|
| 995 | 992 | ) |
| 996 | 993 | | |
| 997 | 994 | (?= # Lookahead for another kind of list |
| 998 | 995 | \n |
| 999 | 996 | \3 # Must have the same indentation |
| 1000 | - '.$other_marker_re.'[ ]+ |
|
| 997 | + '.$other_marker_re . '[ ]+ |
|
| 1001 | 998 | ) |
| 1002 | 999 | ) |
| 1003 | 1000 | ) |
@@ -1009,14 +1006,14 @@ discard block |
||
| 1009 | 1006 | if ($this->list_level) { |
| 1010 | 1007 | $text = preg_replace_callback('{ |
| 1011 | 1008 | ^ |
| 1012 | - '.$whole_list_re.' |
|
| 1009 | + '.$whole_list_re . ' |
|
| 1013 | 1010 | }mx', |
| 1014 | 1011 | array(&$this, '_doLists_callback'), $text); |
| 1015 | 1012 | } |
| 1016 | 1013 | else { |
| 1017 | 1014 | $text = preg_replace_callback('{ |
| 1018 | 1015 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
| 1019 | - '.$whole_list_re.' |
|
| 1016 | + '.$whole_list_re . ' |
|
| 1020 | 1017 | }mx', |
| 1021 | 1018 | array(&$this, '_doLists_callback'), $text); |
| 1022 | 1019 | } |
@@ -1033,13 +1030,13 @@ discard block |
||
| 1033 | 1030 | $list = $matches[1]; |
| 1034 | 1031 | $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol"; |
| 1035 | 1032 | |
| 1036 | - $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re ); |
|
| 1033 | + $marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re); |
|
| 1037 | 1034 | |
| 1038 | 1035 | $list .= "\n"; |
| 1039 | 1036 | $result = $this->processListItems($list, $marker_any_re); |
| 1040 | 1037 | |
| 1041 | 1038 | $result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>"); |
| 1042 | - return "\n". $result ."\n\n"; |
|
| 1039 | + return "\n" . $result . "\n\n"; |
|
| 1043 | 1040 | } |
| 1044 | 1041 | |
| 1045 | 1042 | var $list_level = 0; |
@@ -1078,12 +1075,12 @@ discard block |
||
| 1078 | 1075 | $list_str = preg_replace_callback('{ |
| 1079 | 1076 | (\n)? # leading line = $1 |
| 1080 | 1077 | (^[ ]*) # leading whitespace = $2 |
| 1081 | - ('.$marker_any_re.' # list marker and space = $3 |
|
| 1078 | + ('.$marker_any_re . ' # list marker and space = $3 |
|
| 1082 | 1079 | (?:[ ]+|(?=\n)) # space only required if item is not empty |
| 1083 | 1080 | ) |
| 1084 | 1081 | ((?s:.*?)) # list item text = $4 |
| 1085 | 1082 | (?:(\n+(?=\n))|\n) # tailing blank line = $5 |
| 1086 | - (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n)))) |
|
| 1083 | + (?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n)))) |
|
| 1087 | 1084 | }xm', |
| 1088 | 1085 | array(&$this, '_processListItems_callback'), $list_str); |
| 1089 | 1086 | |
@@ -1092,17 +1089,17 @@ discard block |
||
| 1092 | 1089 | } |
| 1093 | 1090 | function _processListItems_callback($matches) { |
| 1094 | 1091 | $item = $matches[4]; |
| 1095 | - $leading_line =& $matches[1]; |
|
| 1096 | - $leading_space =& $matches[2]; |
|
| 1092 | + $leading_line = & $matches[1]; |
|
| 1093 | + $leading_space = & $matches[2]; |
|
| 1097 | 1094 | $marker_space = $matches[3]; |
| 1098 | - $tailing_blank_line =& $matches[5]; |
|
| 1095 | + $tailing_blank_line = & $matches[5]; |
|
| 1099 | 1096 | |
| 1100 | 1097 | if ($leading_line || $tailing_blank_line || |
| 1101 | 1098 | preg_match('/\n{2,}/', $item)) |
| 1102 | 1099 | { |
| 1103 | 1100 | # Replace marker with the appropriate whitespace indentation |
| 1104 | 1101 | $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
| 1105 | - $item = $this->runBlockGamut($this->outdent($item)."\n"); |
|
| 1102 | + $item = $this->runBlockGamut($this->outdent($item) . "\n"); |
|
| 1106 | 1103 | } |
| 1107 | 1104 | else { |
| 1108 | 1105 | # Recursion for sub-lists: |
@@ -1123,11 +1120,11 @@ discard block |
||
| 1123 | 1120 | (?:\n\n|\A\n?) |
| 1124 | 1121 | ( # $1 = the code block -- one or more lines, starting with a space/tab |
| 1125 | 1122 | (?> |
| 1126 | - [ ]{'.$this->tab_width.'} # Lines must start with a tab or a tab-width of spaces |
|
| 1123 | + [ ]{'.$this->tab_width . '} # Lines must start with a tab or a tab-width of spaces |
|
| 1127 | 1124 | .*\n+ |
| 1128 | 1125 | )+ |
| 1129 | 1126 | ) |
| 1130 | - ((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
| 1127 | + ((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
| 1131 | 1128 | }xm', |
| 1132 | 1129 | array(&$this, '_doCodeBlocks_callback'), $text); |
| 1133 | 1130 | |
@@ -1156,7 +1153,7 @@ discard block |
||
| 1156 | 1153 | } |
| 1157 | 1154 | |
| 1158 | 1155 | $codeblock = "<pre class=\"$class\"><code>$codeblock\n</code></pre>"; |
| 1159 | - return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
| 1156 | + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
| 1160 | 1157 | } |
| 1161 | 1158 | |
| 1162 | 1159 | /** |
@@ -1204,7 +1201,7 @@ discard block |
||
| 1204 | 1201 | $token_relist[] = $strong_re; |
| 1205 | 1202 | |
| 1206 | 1203 | # Construct master expression from list. |
| 1207 | - $token_re = '{('. implode('|', $token_relist) .')}'; |
|
| 1204 | + $token_re = '{(' . implode('|', $token_relist) . ')}'; |
|
| 1208 | 1205 | $this->em_strong_prepared_relist["$em$strong"] = $token_re; |
| 1209 | 1206 | } |
| 1210 | 1207 | } |
@@ -1230,8 +1227,8 @@ discard block |
||
| 1230 | 1227 | # |
| 1231 | 1228 | $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); |
| 1232 | 1229 | $text_stack[0] .= $parts[0]; |
| 1233 | - $token =& $parts[1]; |
|
| 1234 | - $text =& $parts[2]; |
|
| 1230 | + $token = & $parts[1]; |
|
| 1231 | + $text = & $parts[2]; |
|
| 1235 | 1232 | |
| 1236 | 1233 | if (empty($token)) { |
| 1237 | 1234 | # Reached end of text span: empty stack without emitting. |
@@ -1258,7 +1255,7 @@ discard block |
||
| 1258 | 1255 | } else { |
| 1259 | 1256 | # Other closing marker: close one em or strong and |
| 1260 | 1257 | # change current token state to match the other |
| 1261 | - $token_stack[0] = str_repeat($token{0}, 3-$token_len); |
|
| 1258 | + $token_stack[0] = str_repeat($token{0}, 3 - $token_len); |
|
| 1262 | 1259 | $tag = $token_len == 2 ? "strong" : "em"; |
| 1263 | 1260 | $span = $text_stack[0]; |
| 1264 | 1261 | $span = $this->runSpanGamut($span); |
@@ -1352,7 +1349,7 @@ discard block |
||
| 1352 | 1349 | $bq = $matches[1]; |
| 1353 | 1350 | # trim one level of quoting - trim whitespace-only lines |
| 1354 | 1351 | $bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq); |
| 1355 | - $bq = $this->runBlockGamut($bq); # recurse |
|
| 1352 | + $bq = $this->runBlockGamut($bq); # recurse |
|
| 1356 | 1353 | |
| 1357 | 1354 | $bq = preg_replace('/^/m', " ", $bq); |
| 1358 | 1355 | # These leading spaces cause problem with <pre> content, |
@@ -1360,7 +1357,7 @@ discard block |
||
| 1360 | 1357 | $bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx', |
| 1361 | 1358 | array(&$this, '_doBlockQuotes_callback2'), $bq); |
| 1362 | 1359 | |
| 1363 | - return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n"; |
|
| 1360 | + return "\n" . $this->hashBlock("<blockquote>\n$bq\n</blockquote>") . "\n\n"; |
|
| 1364 | 1361 | } |
| 1365 | 1362 | function _doBlockQuotes_callback2($matches) { |
| 1366 | 1363 | $pre = $matches[1]; |
@@ -1462,7 +1459,7 @@ discard block |
||
| 1462 | 1459 | # Ampersand-encoding based entirely on Nat Irons's Amputator |
| 1463 | 1460 | # MT plugin: <http://bumppo.net/projects/amputator/> |
| 1464 | 1461 | $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', |
| 1465 | - '&', $text);; |
|
| 1462 | + '&', $text); ; |
|
| 1466 | 1463 | } |
| 1467 | 1464 | # Encode remaining <'s |
| 1468 | 1465 | $text = str_replace('<', '<', $text); |
@@ -1528,7 +1525,7 @@ discard block |
||
| 1528 | 1525 | # |
| 1529 | 1526 | $addr = "mailto:" . $addr; |
| 1530 | 1527 | $chars = preg_split('/(?<!^)(?!$)/', $addr); |
| 1531 | - $seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed. |
|
| 1528 | + $seed = (int) abs(crc32($addr) / strlen($addr)); # Deterministic seed. |
|
| 1532 | 1529 | |
| 1533 | 1530 | foreach ($chars as $key => $char) { |
| 1534 | 1531 | $ord = ord($char); |
@@ -1538,8 +1535,8 @@ discard block |
||
| 1538 | 1535 | # roughly 10% raw, 45% hex, 45% dec |
| 1539 | 1536 | # '@' *must* be encoded. I insist. |
| 1540 | 1537 | if ($r > 90 && $char != '@') /* do nothing */; |
| 1541 | - else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1542 | - else $chars[$key] = '&#'.$ord.';'; |
|
| 1538 | + else if ($r < 45) $chars[$key] = '&#x' . dechex($ord) . ';'; |
|
| 1539 | + else $chars[$key] = '&#' . $ord . ';'; |
|
| 1543 | 1540 | } |
| 1544 | 1541 | } |
| 1545 | 1542 | |
@@ -1560,11 +1557,11 @@ discard block |
||
| 1560 | 1557 | |
| 1561 | 1558 | $span_re = '{ |
| 1562 | 1559 | ( |
| 1563 | - \\\\'.$this->escape_chars_re.' |
|
| 1560 | + \\\\'.$this->escape_chars_re . ' |
|
| 1564 | 1561 | | |
| 1565 | 1562 | (?<![`\\\\]) |
| 1566 | 1563 | `+ # code span marker |
| 1567 | - '.( $this->no_markup ? '' : ' |
|
| 1564 | + '.($this->no_markup ? '' : ' |
|
| 1568 | 1565 | | |
| 1569 | 1566 | <!-- .*? --> # comment |
| 1570 | 1567 | | |
@@ -1576,7 +1573,7 @@ discard block |
||
| 1576 | 1573 | (?>[^"\'>]+|"[^"]*"|\'[^\']*\')* |
| 1577 | 1574 | )? |
| 1578 | 1575 | > |
| 1579 | - ').' |
|
| 1576 | + ') . ' |
|
| 1580 | 1577 | ) |
| 1581 | 1578 | }xs'; |
| 1582 | 1579 | |
@@ -1615,10 +1612,10 @@ discard block |
||
| 1615 | 1612 | { |
| 1616 | 1613 | switch ($token{0}) { |
| 1617 | 1614 | case "\\": |
| 1618 | - return $this->hashPart("&#". ord($token{1}). ";"); |
|
| 1615 | + return $this->hashPart("&#" . ord($token{1}) . ";"); |
|
| 1619 | 1616 | case "`": |
| 1620 | 1617 | # Search for end marker in remaining text. |
| 1621 | - if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', |
|
| 1618 | + if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm', |
|
| 1622 | 1619 | $str, $matches)) |
| 1623 | 1620 | { |
| 1624 | 1621 | $str = $matches[2]; |
@@ -1636,7 +1633,7 @@ discard block |
||
| 1636 | 1633 | # |
| 1637 | 1634 | # Remove one level of line-leading tabs or spaces |
| 1638 | 1635 | # |
| 1639 | - return preg_replace('/^(\t|[ ]{1,'.$this->tab_width.'})/m', '', $text); |
|
| 1636 | + return preg_replace('/^(\t|[ ]{1,' . $this->tab_width . '})/m', '', $text); |
|
| 1640 | 1637 | } |
| 1641 | 1638 | |
| 1642 | 1639 | |
@@ -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);'); |
@@ -375,6 +375,12 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | return array($parsed, $text); |
| 377 | 377 | } |
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * @param string $text |
|
| 381 | + * @param string $hash_method |
|
| 382 | + * @param boolean $md_attr |
|
| 383 | + */ |
|
| 378 | 384 | function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
| 379 | 385 | # |
| 380 | 386 | # Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags. |
@@ -804,6 +810,9 @@ discard block |
||
| 804 | 810 | } |
| 805 | 811 | |
| 806 | 812 | |
| 813 | + /** |
|
| 814 | + * @return string |
|
| 815 | + */ |
|
| 807 | 816 | function processDefListItems($list_str) { |
| 808 | 817 | # |
| 809 | 818 | # Process the contents of a single definition list, splitting it |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | # |
| 143 | 143 | # Call the HTML-in-Markdown hasher. |
| 144 | 144 | # |
| 145 | - list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 145 | + list($text,) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 146 | 146 | |
| 147 | 147 | return $text; |
| 148 | 148 | } |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | ( # $2: Capture hole tag. |
| 192 | 192 | </? # Any opening or closing tag. |
| 193 | 193 | (?> # Tag name. |
| 194 | - '.$this->block_tags_re.' | |
|
| 195 | - '.$this->context_block_tags_re.' | |
|
| 196 | - '.$this->clean_tags_re.' | |
|
| 197 | - (?!\s)'.$enclosing_tag_re.' |
|
| 194 | + '.$this->block_tags_re . ' | |
|
| 195 | + '.$this->context_block_tags_re . ' | |
|
| 196 | + '.$this->clean_tags_re . ' | |
|
| 197 | + (?!\s)'.$enclosing_tag_re . ' |
|
| 198 | 198 | ) |
| 199 | 199 | (?: |
| 200 | 200 | (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name. |
@@ -214,25 +214,25 @@ discard block |
||
| 214 | 214 | | |
| 215 | 215 | # Code span marker |
| 216 | 216 | `+ |
| 217 | - '. ( !$span ? ' # If not in span. |
|
| 217 | + '. (!$span ? ' # If not in span. |
|
| 218 | 218 | | |
| 219 | 219 | # Indented code block |
| 220 | 220 | (?: ^[ ]*\n | ^ | \n[ ]*\n ) |
| 221 | - [ ]{'.($indent+4).'}[^\n]* \n |
|
| 221 | + [ ]{'.($indent + 4) . '}[^\n]* \n |
|
| 222 | 222 | (?> |
| 223 | - (?: [ ]{'.($indent+4).'}[^\n]* | [ ]* ) \n |
|
| 223 | + (?: [ ]{'.($indent + 4) . '}[^\n]* | [ ]* ) \n |
|
| 224 | 224 | )* |
| 225 | 225 | | |
| 226 | 226 | # Fenced code block marker |
| 227 | 227 | (?> ^ | \n ) |
| 228 | - [ ]{0,'.($indent).'}~~~+[ ]*\n |
|
| 229 | - ' : '' ). ' # End (if not is span). |
|
| 228 | + [ ]{0,'.($indent) . '}~~~+[ ]*\n |
|
| 229 | + ' : '') . ' # End (if not is span). |
|
| 230 | 230 | ) |
| 231 | 231 | }xs'; |
| 232 | 232 | |
| 233 | 233 | |
| 234 | - $depth = 0; # Current depth inside the tag tree. |
|
| 235 | - $parsed = ""; # Parsed text that will be returned. |
|
| 234 | + $depth = 0; # Current depth inside the tag tree. |
|
| 235 | + $parsed = ""; # Parsed text that will be returned. |
|
| 236 | 236 | |
| 237 | 237 | # |
| 238 | 238 | # Loop through every tag until we find the closing tag of the parent |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | if ($tag{0} == "`") { |
| 275 | 275 | # Find corresponding end marker. |
| 276 | 276 | $tag_re = preg_quote($tag); |
| 277 | - if (preg_match('{^(?>.+?|\n(?!\n))*?(?<!`)'.$tag_re.'(?!`)}', |
|
| 277 | + if (preg_match('{^(?>.+?|\n(?!\n))*?(?<!`)' . $tag_re . '(?!`)}', |
|
| 278 | 278 | $text, $matches)) |
| 279 | 279 | { |
| 280 | 280 | # End marker found: pass text unchanged until marker. |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | # |
| 290 | 290 | # Check for: Fenced code block marker. |
| 291 | 291 | # |
| 292 | - else if (preg_match('{^\n?[ ]{0,'.($indent+3).'}~}', $tag)) { |
|
| 292 | + else if (preg_match('{^\n?[ ]{0,' . ($indent + 3) . '}~}', $tag)) { |
|
| 293 | 293 | # Fenced code block marker: find matching end marker. |
| 294 | 294 | $tag_re = preg_quote(trim($tag)); |
| 295 | - if (preg_match('{^(?>.*\n)+?[ ]{0,'.($indent).'}'.$tag_re.'[ ]*\n}', $text, |
|
| 295 | + if (preg_match('{^(?>.*\n)+?[ ]{0,' . ($indent) . '}' . $tag_re . '[ ]*\n}', $text, |
|
| 296 | 296 | $matches)) |
| 297 | 297 | { |
| 298 | 298 | # End marker found: pass text unchanged until marker. |
@@ -317,10 +317,10 @@ discard block |
||
| 317 | 317 | # Opening Context Block tag (like ins and del) |
| 318 | 318 | # used as a block tag (tag is alone on it's line). |
| 319 | 319 | # |
| 320 | - else if (preg_match('{^<(?:'.$this->block_tags_re.')\b}', $tag) || |
|
| 321 | - ( preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) && |
|
| 320 | + else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) || |
|
| 321 | + (preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
| 322 | 322 | preg_match($newline_before_re, $parsed) && |
| 323 | - preg_match($newline_after_re, $text) ) |
|
| 323 | + preg_match($newline_after_re, $text)) |
|
| 324 | 324 | ) |
| 325 | 325 | { |
| 326 | 326 | # Need to parse tag and following text using the HTML parser. |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | # Check for: Clean tag (like script, math) |
| 335 | 335 | # HTML Comments, processing instructions. |
| 336 | 336 | # |
| 337 | - else if (preg_match('{^<(?:'.$this->clean_tags_re.')\b}', $tag) || |
|
| 337 | + else if (preg_match('{^<(?:' . $this->clean_tags_re . ')\b}', $tag) || |
|
| 338 | 338 | $tag{1} == '!' || $tag{1} == '?') |
| 339 | 339 | { |
| 340 | 340 | # Need to parse tag and following text using the HTML parser. |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | # |
| 350 | 350 | else if ($enclosing_tag_re !== '' && |
| 351 | 351 | # Same name as enclosing tag. |
| 352 | - preg_match('{^</?(?:'.$enclosing_tag_re.')\b}', $tag)) |
|
| 352 | + preg_match('{^</?(?:' . $enclosing_tag_re . ')\b}', $tag)) |
|
| 353 | 353 | { |
| 354 | 354 | # |
| 355 | 355 | # Increase/decrease nested tag count. |
| 356 | 356 | # |
| 357 | 357 | if ($tag{1} == '/') $depth--; |
| 358 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 358 | + else if ($tag{strlen($tag) - 2} != '/') $depth++; |
|
| 359 | 359 | |
| 360 | 360 | if ($depth < 0) { |
| 361 | 361 | # |
@@ -427,11 +427,11 @@ discard block |
||
| 427 | 427 | ) |
| 428 | 428 | }xs'; |
| 429 | 429 | |
| 430 | - $original_text = $text; # Save original text in case of faliure. |
|
| 430 | + $original_text = $text; # Save original text in case of faliure. |
|
| 431 | 431 | |
| 432 | - $depth = 0; # Current depth inside the tag tree. |
|
| 433 | - $block_text = ""; # Temporary text holder for current text. |
|
| 434 | - $parsed = ""; # Parsed text that will be returned. |
|
| 432 | + $depth = 0; # Current depth inside the tag tree. |
|
| 433 | + $block_text = ""; # Temporary text holder for current text. |
|
| 434 | + $parsed = ""; # Parsed text that will be returned. |
|
| 435 | 435 | |
| 436 | 436 | # |
| 437 | 437 | # Get the name of the starting tag. |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | # Check for: Auto-close tag (like <hr/>) |
| 471 | 471 | # Comments and Processing Instructions. |
| 472 | 472 | # |
| 473 | - if (preg_match('{^</?(?:'.$this->auto_close_tags_re.')\b}', $tag) || |
|
| 473 | + if (preg_match('{^</?(?:' . $this->auto_close_tags_re . ')\b}', $tag) || |
|
| 474 | 474 | $tag{1} == '!' || $tag{1} == '?') |
| 475 | 475 | { |
| 476 | 476 | # Just add the tag to the block as if it was text. |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | # Increase/decrease nested tag count. Only do so if |
| 482 | 482 | # the tag's name match base tag's. |
| 483 | 483 | # |
| 484 | - if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) { |
|
| 484 | + if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
|
| 485 | 485 | if ($tag{1} == '/') $depth--; |
| 486 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 486 | + else if ($tag{strlen($tag) - 2} != '/') $depth++; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | # |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | # Check if text inside this tag must be parsed in span mode. |
| 500 | 500 | $this->mode = $attr_m[2] . $attr_m[3]; |
| 501 | 501 | $span_mode = $this->mode == 'span' || $this->mode != 'block' && |
| 502 | - preg_match('{^<(?:'.$this->contain_span_tags_re.')\b}', $tag); |
|
| 502 | + preg_match('{^<(?:' . $this->contain_span_tags_re . ')\b}', $tag); |
|
| 503 | 503 | |
| 504 | 504 | # Calculate indent before tag. |
| 505 | 505 | if (preg_match('/(?:^|\n)( *?)(?! ).*?$/', $block_text, $matches)) { |
@@ -608,14 +608,14 @@ discard block |
||
| 608 | 608 | if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) |
| 609 | 609 | return $matches[0]; |
| 610 | 610 | $level = $matches[3]{0} == '=' ? 1 : 2; |
| 611 | - $attr = $this->_doHeaders_attr($id =& $matches[2]); |
|
| 612 | - $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
| 611 | + $attr = $this->_doHeaders_attr($id = & $matches[2]); |
|
| 612 | + $block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
| 613 | 613 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 614 | 614 | } |
| 615 | 615 | function _doHeaders_callback_atx($matches) { |
| 616 | 616 | $level = strlen($matches[1]); |
| 617 | - $attr = $this->_doHeaders_attr($id =& $matches[3]); |
|
| 618 | - $block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
| 617 | + $attr = $this->_doHeaders_attr($id = & $matches[3]); |
|
| 618 | + $block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
| 619 | 619 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 620 | 620 | } |
| 621 | 621 | |
@@ -636,11 +636,11 @@ discard block |
||
| 636 | 636 | $text = preg_replace_callback(' |
| 637 | 637 | { |
| 638 | 638 | ^ # Start of a line |
| 639 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 639 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 640 | 640 | [|] # Optional leading pipe (present) |
| 641 | 641 | (.+) \n # $1: Header row (at least one pipe) |
| 642 | 642 | |
| 643 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 643 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 644 | 644 | [|] ([ ]*[-:]+[-| :]*) \n # $2: Header underline |
| 645 | 645 | |
| 646 | 646 | ( # $3: Cells |
@@ -664,10 +664,10 @@ discard block |
||
| 664 | 664 | $text = preg_replace_callback(' |
| 665 | 665 | { |
| 666 | 666 | ^ # Start of a line |
| 667 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 667 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 668 | 668 | (\S.*[|].*) \n # $1: Header row (at least one pipe) |
| 669 | 669 | |
| 670 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 670 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 671 | 671 | ([-:]+[ ]*[|][-| :]*) \n # $2: Header underline |
| 672 | 672 | |
| 673 | 673 | ( # $3: Cells |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | return $text; |
| 683 | 683 | } |
| 684 | 684 | function _doTable_leadingPipe_callback($matches) { |
| 685 | - $head = $matches[1]; |
|
| 686 | - $underline = $matches[2]; |
|
| 685 | + $head = $matches[1]; |
|
| 686 | + $underline = $matches[2]; |
|
| 687 | 687 | $content = $matches[3]; |
| 688 | 688 | |
| 689 | 689 | # Remove leading pipe for each row. |
@@ -692,17 +692,17 @@ discard block |
||
| 692 | 692 | return $this->_doTable_callback(array($matches[0], $head, $underline, $content)); |
| 693 | 693 | } |
| 694 | 694 | function _doTable_callback($matches) { |
| 695 | - $head = $matches[1]; |
|
| 696 | - $underline = $matches[2]; |
|
| 697 | - $content = $matches[3]; |
|
| 695 | + $head = $matches[1]; |
|
| 696 | + $underline = $matches[2]; |
|
| 697 | + $content = $matches[3]; |
|
| 698 | 698 | |
| 699 | 699 | # Remove any tailing pipes for each line. |
| 700 | - $head = preg_replace('/[|] *$/m', '', $head); |
|
| 701 | - $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 702 | - $content = preg_replace('/[|] *$/m', '', $content); |
|
| 700 | + $head = preg_replace('/[|] *$/m', '', $head); |
|
| 701 | + $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 702 | + $content = preg_replace('/[|] *$/m', '', $content); |
|
| 703 | 703 | |
| 704 | 704 | # Reading alignement from header underline. |
| 705 | - $separators = preg_split('/ *[|] */', $underline); |
|
| 705 | + $separators = preg_split('/ *[|] */', $underline); |
|
| 706 | 706 | foreach ($separators as $n => $s) { |
| 707 | 707 | if (preg_match('/^ *-+: *$/', $s)) $attr[$n] = ' align="right"'; |
| 708 | 708 | else if (preg_match('/^ *:-+: *$/', $s))$attr[$n] = ' align="center"'; |
@@ -712,16 +712,16 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | # Parsing span elements, including code spans, character escapes, |
| 714 | 714 | # and inline HTML tags, so that pipes inside those gets ignored. |
| 715 | - $head = $this->parseSpan($head); |
|
| 716 | - $headers = preg_split('/ *[|] */', $head); |
|
| 717 | - $col_count = count($headers); |
|
| 715 | + $head = $this->parseSpan($head); |
|
| 716 | + $headers = preg_split('/ *[|] */', $head); |
|
| 717 | + $col_count = count($headers); |
|
| 718 | 718 | |
| 719 | 719 | # Write column headers. |
| 720 | 720 | $text = "<table>\n"; |
| 721 | 721 | $text .= "<thead>\n"; |
| 722 | 722 | $text .= "<tr>\n"; |
| 723 | 723 | foreach ($headers as $n => $header) |
| 724 | - $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n"; |
|
| 724 | + $text .= " <th$attr[$n]>" . $this->runSpanGamut(trim($header)) . "</th>\n"; |
|
| 725 | 725 | $text .= "</tr>\n"; |
| 726 | 726 | $text .= "</thead>\n"; |
| 727 | 727 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | |
| 741 | 741 | $text .= "<tr>\n"; |
| 742 | 742 | foreach ($row_cells as $n => $cell) |
| 743 | - $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n"; |
|
| 743 | + $text .= " <td$attr[$n]>" . $this->runSpanGamut(trim($cell)) . "</td>\n"; |
|
| 744 | 744 | $text .= "</tr>\n"; |
| 745 | 745 | } |
| 746 | 746 | $text .= "</tbody>\n"; |
@@ -760,10 +760,10 @@ discard block |
||
| 760 | 760 | $whole_list_re = '(?> |
| 761 | 761 | ( # $1 = whole list |
| 762 | 762 | ( # $2 |
| 763 | - [ ]{0,'.$less_than_tab.'} |
|
| 763 | + [ ]{0,'.$less_than_tab . '} |
|
| 764 | 764 | ((?>.*\S.*\n)+) # $3 = defined term |
| 765 | 765 | \n? |
| 766 | - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition |
|
| 766 | + [ ]{0,'.$less_than_tab . '}:[ ]+ # colon starting definition |
|
| 767 | 767 | ) |
| 768 | 768 | (?s:.+?) |
| 769 | 769 | ( # $4 |
@@ -772,13 +772,13 @@ discard block |
||
| 772 | 772 | \n{2,} |
| 773 | 773 | (?=\S) |
| 774 | 774 | (?! # Negative lookahead for another term |
| 775 | - [ ]{0,'.$less_than_tab.'} |
|
| 775 | + [ ]{0,'.$less_than_tab . '} |
|
| 776 | 776 | (?: \S.*\n )+? # defined term |
| 777 | 777 | \n? |
| 778 | - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition |
|
| 778 | + [ ]{0,'.$less_than_tab . '}:[ ]+ # colon starting definition |
|
| 779 | 779 | ) |
| 780 | 780 | (?! # Negative lookahead for another definition |
| 781 | - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition |
|
| 781 | + [ ]{0,'.$less_than_tab . '}:[ ]+ # colon starting definition |
|
| 782 | 782 | ) |
| 783 | 783 | ) |
| 784 | 784 | ) |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $text = preg_replace_callback('{ |
| 788 | 788 | (?>\A\n?|(?<=\n\n)) |
| 789 | - '.$whole_list_re.' |
|
| 789 | + '.$whole_list_re . ' |
|
| 790 | 790 | }mx', |
| 791 | 791 | array(&$this, '_doDefLists_callback'), $text); |
| 792 | 792 | |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | $list_str = preg_replace_callback('{ |
| 819 | 819 | (?>\A\n?|\n\n+) # leading line |
| 820 | 820 | ( # definition terms = $1 |
| 821 | - [ ]{0,'.$less_than_tab.'} # leading whitespace |
|
| 821 | + [ ]{0,'.$less_than_tab . '} # leading whitespace |
|
| 822 | 822 | (?![:][ ]|[ ]) # negative lookahead for a definition |
| 823 | 823 | # mark (colon) or more whitespace. |
| 824 | 824 | (?> \S.* \n)+? # actual term (not whitespace). |
@@ -832,13 +832,13 @@ discard block |
||
| 832 | 832 | $list_str = preg_replace_callback('{ |
| 833 | 833 | \n(\n+)? # leading line = $1 |
| 834 | 834 | ( # marker space = $2 |
| 835 | - [ ]{0,'.$less_than_tab.'} # whitespace before colon |
|
| 835 | + [ ]{0,'.$less_than_tab . '} # whitespace before colon |
|
| 836 | 836 | [:][ ]+ # definition mark (colon) |
| 837 | 837 | ) |
| 838 | 838 | ((?s:.+?)) # definition text = $3 |
| 839 | 839 | (?= \n+ # stop at next definition mark, |
| 840 | 840 | (?: # next term or end of text |
| 841 | - [ ]{0,'.$less_than_tab.'} [:][ ] | |
|
| 841 | + [ ]{0,'.$less_than_tab . '} [:][ ] | |
|
| 842 | 842 | <dt> | \z |
| 843 | 843 | ) |
| 844 | 844 | ) |
@@ -859,13 +859,13 @@ discard block |
||
| 859 | 859 | function _processDefListItems_callback_dd($matches) { |
| 860 | 860 | $leading_line = $matches[1]; |
| 861 | 861 | $marker_space = $matches[2]; |
| 862 | - $def = $matches[3]; |
|
| 862 | + $def = $matches[3]; |
|
| 863 | 863 | |
| 864 | 864 | if ($leading_line || preg_match('/\n{2,}/', $def)) { |
| 865 | 865 | # Replace marker with the appropriate whitespace indentation |
| 866 | 866 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 867 | 867 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 868 | - $def = "\n". $def ."\n"; |
|
| 868 | + $def = "\n" . $def . "\n"; |
|
| 869 | 869 | } |
| 870 | 870 | else { |
| 871 | 871 | $def = rtrim($def); |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | $codeblock = '<pre' . ($class ? ' class="' . $class . '"' : '') . '><code>' . $codeblock . '</code></pre>'; |
| 936 | 936 | |
| 937 | - return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
| 937 | + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | function _doFencedCodeBlocks_newlines($matches) |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | |
| 1012 | 1012 | # Link defs are in the form: [^id]: url "optional title" |
| 1013 | 1013 | $text = preg_replace_callback('{ |
| 1014 | - ^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1 |
|
| 1014 | + ^[ ]{0,'.$less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1 |
|
| 1015 | 1015 | [ ]* |
| 1016 | 1016 | \n? # maybe *one* newline |
| 1017 | 1017 | ( # text = $2 (no blank lines allowed) |
@@ -1058,7 +1058,7 @@ discard block |
||
| 1058 | 1058 | if (!empty($this->footnotes_ordered)) { |
| 1059 | 1059 | $text .= "\n\n"; |
| 1060 | 1060 | $text .= "<div class=\"footnotes\">\n"; |
| 1061 | - $text .= "<hr". $this->empty_element_suffix ."\n"; |
|
| 1061 | + $text .= "<hr" . $this->empty_element_suffix . "\n"; |
|
| 1062 | 1062 | $text .= "<ol>\n\n"; |
| 1063 | 1063 | |
| 1064 | 1064 | $attr = " rev=\"footnote\""; |
@@ -1132,12 +1132,12 @@ discard block |
||
| 1132 | 1132 | $node_id = $this->encodeAttribute($node_id); |
| 1133 | 1133 | |
| 1134 | 1134 | return |
| 1135 | - "<sup id=\"fnref:$node_id\">". |
|
| 1136 | - "<a href=\"#fn:$node_id\"$attr>$num</a>". |
|
| 1135 | + "<sup id=\"fnref:$node_id\">" . |
|
| 1136 | + "<a href=\"#fn:$node_id\"$attr>$num</a>" . |
|
| 1137 | 1137 | "</sup>"; |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - return "[^".$matches[1]."]"; |
|
| 1140 | + return "[^" . $matches[1] . "]"; |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | |
| 1152 | 1152 | # Link defs are in the form: [id]*: url "optional title" |
| 1153 | 1153 | $text = preg_replace_callback('{ |
| 1154 | - ^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
| 1154 | + ^[ ]{0,'.$less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
| 1155 | 1155 | (.*) # text = $2 (no blank lines allowed) |
| 1156 | 1156 | }xm', |
| 1157 | 1157 | array(&$this, '_stripAbbreviations_callback'), |
@@ -1176,10 +1176,10 @@ discard block |
||
| 1176 | 1176 | if ($this->abbr_word_re) { |
| 1177 | 1177 | // cannot use the /x modifier because abbr_word_re may |
| 1178 | 1178 | // contain significant spaces: |
| 1179 | - $text = preg_replace_callback('{'. |
|
| 1180 | - '(?<![\w\x1A])'. |
|
| 1181 | - '(?:'.$this->abbr_word_re.')'. |
|
| 1182 | - '(?![\w\x1A])'. |
|
| 1179 | + $text = preg_replace_callback('{' . |
|
| 1180 | + '(?<![\w\x1A])' . |
|
| 1181 | + '(?:' . $this->abbr_word_re . ')' . |
|
| 1182 | + '(?![\w\x1A])' . |
|
| 1183 | 1183 | '}', |
| 1184 | 1184 | array(&$this, '_doAbbreviations_callback'), $text); |
| 1185 | 1185 | } |
@@ -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 |
@@ -219,6 +219,9 @@ discard block |
||
| 219 | 219 | return $text; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | + /** |
|
| 223 | + * @param string $text |
|
| 224 | + */ |
|
| 222 | 225 | private function doSourcePublish($text) |
| 223 | 226 | { |
| 224 | 227 | return Patron($text); |
@@ -796,6 +799,9 @@ discard block |
||
| 796 | 799 | ** |
| 797 | 800 | */ |
| 798 | 801 | |
| 802 | + /** |
|
| 803 | + * @param string $markup |
|
| 804 | + */ |
|
| 799 | 805 | function createElement($markup, $attrs, $body=NULL) |
| 800 | 806 | { |
| 801 | 807 | $rc = array(); |
@@ -934,6 +940,10 @@ discard block |
||
| 934 | 940 | # PHP source highlighter |
| 935 | 941 | # |
| 936 | 942 | |
| 943 | + /** |
|
| 944 | + * @param string $text |
|
| 945 | + * @param string $marker |
|
| 946 | + */ |
|
| 937 | 947 | function doSourceCommentLine($text, $marker) |
| 938 | 948 | { |
| 939 | 949 | $lines = explode("\n", $text); |
@@ -983,6 +993,9 @@ discard block |
||
| 983 | 993 | const QUOTE_DOUBLE = '"'; |
| 984 | 994 | const ESCAPE = '\\'; |
| 985 | 995 | |
| 996 | + /** |
|
| 997 | + * @param string $text |
|
| 998 | + */ |
|
| 986 | 999 | function doSourceString($text) |
| 987 | 1000 | { |
| 988 | 1001 | $out = NULL; |
@@ -1124,7 +1124,7 @@ |
||
| 1124 | 1124 | 'break', |
| 1125 | 1125 | 'class', |
| 1126 | 1126 | 'const', |
| 1127 | - 'endif', |
|
| 1127 | + 'endif', |
|
| 1128 | 1128 | 'case', |
| 1129 | 1129 | 'true', |
| 1130 | 1130 | 'self', |
@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | @define('txt_registered', '®'); |
| 28 | 28 | @define('txt_copyright', '©'); |
| 29 | 29 | */ |
| 30 | -@define('txt_apostrophe', '\''); |
|
| 31 | -@define('txt_quote_double_open', '« '); |
|
| 30 | +@define('txt_apostrophe', '\''); |
|
| 31 | +@define('txt_quote_double_open', '« '); |
|
| 32 | 32 | @define('txt_quote_double_close', ' »'); |
| 33 | -@define('txt_prime', 'ʹ'); |
|
| 34 | -@define('txt_prime_double', 'ʺ'); |
|
| 35 | -@define('txt_ellipsis', '…'); |
|
| 36 | -@define('txt_emdash', '—'); |
|
| 37 | -@define('txt_endash', '–'); |
|
| 38 | -@define('txt_dimension', '×'); |
|
| 39 | -@define('txt_trademark', '™'); |
|
| 40 | -@define('txt_registered', '®'); |
|
| 41 | -@define('txt_copyright', '©'); |
|
| 33 | +@define('txt_prime', 'ʹ'); |
|
| 34 | +@define('txt_prime_double', 'ʺ'); |
|
| 35 | +@define('txt_ellipsis', '…'); |
|
| 36 | +@define('txt_emdash', '—'); |
|
| 37 | +@define('txt_endash', '–'); |
|
| 38 | +@define('txt_dimension', '×'); |
|
| 39 | +@define('txt_trademark', '™'); |
|
| 40 | +@define('txt_registered', '®'); |
|
| 41 | +@define('txt_copyright', '©'); |
|
| 42 | 42 | |
| 43 | 43 | class Textmark_Parser extends MarkdownExtra_Parser |
| 44 | 44 | { |
@@ -52,14 +52,12 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | function __construct() |
| 54 | 54 | { |
| 55 | - $this->early_gamut += array |
|
| 56 | - ( |
|
| 55 | + $this->early_gamut += array( |
|
| 57 | 56 | 'doShell' => 5, |
| 58 | 57 | 'doURL' => 6 |
| 59 | 58 | ); |
| 60 | 59 | |
| 61 | - $this->span_gamut += array |
|
| 62 | - ( |
|
| 60 | + $this->span_gamut += array( |
|
| 63 | 61 | 'doGlyphs' => 70, |
| 64 | 62 | 'doSpan' => 71 |
| 65 | 63 | ); |
@@ -69,8 +67,7 @@ discard block |
||
| 69 | 67 | |
| 70 | 68 | public function doShell($text) |
| 71 | 69 | { |
| 72 | - return preg_replace_callback |
|
| 73 | - ( |
|
| 70 | + return preg_replace_callback( |
|
| 74 | 71 | '{^\$\s+([^\n]+)\n}xm', array($this, 'doShell_callback'), $text |
| 75 | 72 | ); |
| 76 | 73 | |
@@ -269,8 +266,7 @@ discard block |
||
| 269 | 266 | |
| 270 | 267 | */ |
| 271 | 268 | |
| 272 | - $text = preg_replace_callback |
|
| 273 | - ( |
|
| 269 | + $text = preg_replace_callback( |
|
| 274 | 270 | '{ |
| 275 | 271 | ^h([1-6])\. # $1 = string of h? |
| 276 | 272 | [ ]* |
@@ -325,10 +321,10 @@ discard block |
||
| 325 | 321 | |
| 326 | 322 | $c = "(?:{$clas}|{$styl}|{$lnge}|{$hlgn})*"; |
| 327 | 323 | |
| 328 | - $qtags = array('\*\*','\*','\?\?','-','__','_','%','\+','~','\^'); |
|
| 324 | + $qtags = array('\*\*', '\*', '\?\?', '-', '__', '_', '%', '\+', '~', '\^'); |
|
| 329 | 325 | $pnct = ".,\"'?!;:"; |
| 330 | 326 | |
| 331 | - foreach($qtags as $f) { |
|
| 327 | + foreach ($qtags as $f) { |
|
| 332 | 328 | $text = preg_replace_callback("/ |
| 333 | 329 | (^|(?<=[\s>$pnct\(])|[{[]) |
| 334 | 330 | ($f)(?!$f) |
@@ -367,7 +363,7 @@ discard block |
||
| 367 | 363 | |
| 368 | 364 | if (($pre and !$tail) or ($tail and !$pre)) |
| 369 | 365 | { |
| 370 | - $out = $pre.$out.$tail; |
|
| 366 | + $out = $pre . $out . $tail; |
|
| 371 | 367 | } |
| 372 | 368 | |
| 373 | 369 | // $this->dump($out); |
@@ -380,23 +376,22 @@ discard block |
||
| 380 | 376 | { |
| 381 | 377 | // echo l('doGlyphs: "\1"<br />', \ICanBoogie\escape($text)); |
| 382 | 378 | |
| 383 | - $glyph_search = array |
|
| 384 | - ( |
|
| 379 | + $glyph_search = array( |
|
| 385 | 380 | // '/(\w)\'(\w)/', // apostrophe's |
| 386 | - '/(\s)\'(\d+\w?)\b(?!\')/u', // back in '88 |
|
| 381 | + '/(\s)\'(\d+\w?)\b(?!\')/u', // back in '88 |
|
| 387 | 382 | // '/(\S)\'(?=\s|[[:punct:]]|<|$)/', // single closing |
| 388 | 383 | // '/\'/', // single opening |
| 389 | - '/(\S)\"(?=\s|[[:punct:]]|<|$)/u', // double closing |
|
| 390 | - '/"/', // double opening |
|
| 391 | - '/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/u', // 3+ uppercase acronym |
|
| 392 | - '/(?<=\s|^|[>(;-])([A-Z]{3,})([a-z]*)(?=\s|[[:punct:]]|<|$)/u', // 3+ uppercase |
|
| 393 | - '/([^.]?)\.{3}/u', // ellipsis |
|
| 394 | - '/(\s?)--(\s?)/u', // em dash |
|
| 395 | - '/\s-(?:\s|$)/u', // en dash |
|
| 396 | - '/(\d+)( ?)x( ?)(?=\d+)/u', // dimension sign |
|
| 397 | - '/(\b ?|\s|^)[([]TM[])]/iu', // trademark |
|
| 398 | - '/(\b ?|\s|^)[([]R[])]/iu', // registered |
|
| 399 | - '/(\b ?|\s|^)[([]C[])]/iu', // copyright |
|
| 384 | + '/(\S)\"(?=\s|[[:punct:]]|<|$)/u', // double closing |
|
| 385 | + '/"/', // double opening |
|
| 386 | + '/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/u', // 3+ uppercase acronym |
|
| 387 | + '/(?<=\s|^|[>(;-])([A-Z]{3,})([a-z]*)(?=\s|[[:punct:]]|<|$)/u', // 3+ uppercase |
|
| 388 | + '/([^.]?)\.{3}/u', // ellipsis |
|
| 389 | + '/(\s?)--(\s?)/u', // em dash |
|
| 390 | + '/\s-(?:\s|$)/u', // en dash |
|
| 391 | + '/(\d+)( ?)x( ?)(?=\d+)/u', // dimension sign |
|
| 392 | + '/(\b ?|\s|^)[([]TM[])]/iu', // trademark |
|
| 393 | + '/(\b ?|\s|^)[([]R[])]/iu', // registered |
|
| 394 | + '/(\b ?|\s|^)[([]C[])]/iu', // copyright |
|
| 400 | 395 | |
| 401 | 396 | # |
| 402 | 397 | # the following is for french language |
@@ -405,23 +400,22 @@ discard block |
||
| 405 | 400 | '#\s(\!|\?|\:|\;|\-)#u', |
| 406 | 401 | ); |
| 407 | 402 | |
| 408 | - $glyph_replace = array |
|
| 409 | - ( |
|
| 403 | + $glyph_replace = array( |
|
| 410 | 404 | // '$1'.$txt_apostrophe.'$2', // apostrophe's |
| 411 | - '$1'.txt_apostrophe.'$2', // back in '88 |
|
| 405 | + '$1' . txt_apostrophe . '$2', // back in '88 |
|
| 412 | 406 | // '$1'.$txt_quote_single_close, // single closing |
| 413 | 407 | // $txt_quote_single_open, // single opening |
| 414 | - '$1'.txt_quote_double_close, // double closing |
|
| 415 | - txt_quote_double_open, // double opening |
|
| 416 | - '<acronym title="$2">$1</acronym>', // 3+ uppercase acronym |
|
| 417 | - '<span class="caps">$1</span>$2', // 3+ uppercase |
|
| 418 | - '$1'.txt_ellipsis, // ellipsis |
|
| 419 | - '$1'.txt_emdash.'$2', // em dash |
|
| 420 | - ' '.txt_endash.' ', // en dash |
|
| 421 | - '$1$2'.txt_dimension.'$3', // dimension sign |
|
| 422 | - '$1'.txt_trademark, // trademark |
|
| 423 | - '$1'.txt_registered, // registered |
|
| 424 | - '$1'.txt_copyright, // copyright |
|
| 408 | + '$1' . txt_quote_double_close, // double closing |
|
| 409 | + txt_quote_double_open, // double opening |
|
| 410 | + '<acronym title="$2">$1</acronym>', // 3+ uppercase acronym |
|
| 411 | + '<span class="caps">$1</span>$2', // 3+ uppercase |
|
| 412 | + '$1' . txt_ellipsis, // ellipsis |
|
| 413 | + '$1' . txt_emdash . '$2', // em dash |
|
| 414 | + ' ' . txt_endash . ' ', // en dash |
|
| 415 | + '$1$2' . txt_dimension . '$3', // dimension sign |
|
| 416 | + '$1' . txt_trademark, // trademark |
|
| 417 | + '$1' . txt_registered, // registered |
|
| 418 | + '$1' . txt_copyright, // copyright |
|
| 425 | 419 | |
| 426 | 420 | # |
| 427 | 421 | # the following is for french language |
@@ -465,8 +459,7 @@ discard block |
||
| 465 | 459 | |
| 466 | 460 | $style = NULL; |
| 467 | 461 | |
| 468 | - if (preg_match |
|
| 469 | - ( |
|
| 462 | + if (preg_match( |
|
| 470 | 463 | '{ |
| 471 | 464 | ( # the whole thing is saved in $1 |
| 472 | 465 | ^p # start |
@@ -581,14 +574,13 @@ discard block |
||
| 581 | 574 | # First, handle reference-style labeled images: ![alt text][id] |
| 582 | 575 | # |
| 583 | 576 | |
| 584 | - $text = preg_replace_callback |
|
| 585 | - ( |
|
| 577 | + $text = preg_replace_callback( |
|
| 586 | 578 | '{ |
| 587 | 579 | ( # wrap whole match in $1 |
| 588 | 580 | ! # start |
| 589 | 581 | (\<|\||\>|\=)? # alignment = $2 |
| 590 | 582 | \[ |
| 591 | - ('.$this->nested_brackets_re.') # alt text = $3 |
|
| 583 | + ('.$this->nested_brackets_re . ') # alt text = $3 |
|
| 592 | 584 | \] |
| 593 | 585 | |
| 594 | 586 | [ ]? # one optional space |
@@ -611,7 +603,7 @@ discard block |
||
| 611 | 603 | ! |
| 612 | 604 | (\<|\||\>|\=)? # alignment = $2 |
| 613 | 605 | \[ |
| 614 | - ('.$this->nested_brackets_re.') # alt text = $3 |
|
| 606 | + ('.$this->nested_brackets_re . ') # alt text = $3 |
|
| 615 | 607 | \] |
| 616 | 608 | \s? # One optional whitespace character |
| 617 | 609 | \( # literal paren |
@@ -619,7 +611,7 @@ discard block |
||
| 619 | 611 | (?: |
| 620 | 612 | <(\S*)> # src url = $4 |
| 621 | 613 | | |
| 622 | - ('.$this->nested_url_parenthesis_re.') # src url = $5 |
|
| 614 | + ('.$this->nested_url_parenthesis_re . ') # src url = $5 |
|
| 623 | 615 | ) |
| 624 | 616 | [ ]* |
| 625 | 617 | ( # $6 |
@@ -695,10 +687,8 @@ discard block |
||
| 695 | 687 | |
| 696 | 688 | if (isset($parts[1])) |
| 697 | 689 | { |
| 698 | - $entry = $module->model()->loadRange |
|
| 699 | - ( |
|
| 700 | - 0, 1, 'WHERE `' . $module->getConstant('TITLE') . '` = ? AND `' . $module->getConstant('ALBUM') . '` = ?', array |
|
| 701 | - ( |
|
| 690 | + $entry = $module->model()->loadRange( |
|
| 691 | + 0, 1, 'WHERE `' . $module->getConstant('TITLE') . '` = ? AND `' . $module->getConstant('ALBUM') . '` = ?', array( |
|
| 702 | 692 | $parts[1], $parts[0] |
| 703 | 693 | ) |
| 704 | 694 | ) |
@@ -707,10 +697,8 @@ discard block |
||
| 707 | 697 | } |
| 708 | 698 | else |
| 709 | 699 | { |
| 710 | - $entry = $module->model()->loadRange |
|
| 711 | - ( |
|
| 712 | - 0, 1, 'WHERE `slug` = ? OR `title` = ?', array |
|
| 713 | - ( |
|
| 700 | + $entry = $module->model()->loadRange( |
|
| 701 | + 0, 1, 'WHERE `slug` = ? OR `title` = ?', array( |
|
| 714 | 702 | $id, $id |
| 715 | 703 | ) |
| 716 | 704 | ) |
@@ -725,8 +713,7 @@ discard block |
||
| 725 | 713 | return parent::_doImages_reference_callback($matches); |
| 726 | 714 | } |
| 727 | 715 | |
| 728 | - $params = array |
|
| 729 | - ( |
|
| 716 | + $params = array( |
|
| 730 | 717 | 'src' => $entry->path, |
| 731 | 718 | 'alt' => \ICanBoogie\escape($alt), |
| 732 | 719 | 'width' => $entry->width, |
@@ -755,11 +742,11 @@ discard block |
||
| 755 | 742 | { |
| 756 | 743 | // \ICanBoogie\log('<pre>in \1: \2</pre>', __FUNCTION__, $matches); |
| 757 | 744 | |
| 758 | - $whole_match = $matches[1]; |
|
| 745 | + $whole_match = $matches[1]; |
|
| 759 | 746 | $align = $matches[2]; |
| 760 | - $alt_text = $matches[3]; |
|
| 747 | + $alt_text = $matches[3]; |
|
| 761 | 748 | $url = $matches[4] == '' ? $matches[5] : $matches[4]; |
| 762 | - $title =& $matches[8]; |
|
| 749 | + $title = & $matches[8]; |
|
| 763 | 750 | |
| 764 | 751 | $alt_text = str_replace('"', '"', $alt_text); |
| 765 | 752 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
@@ -780,7 +767,7 @@ discard block |
||
| 780 | 767 | if (isset($title)) |
| 781 | 768 | { |
| 782 | 769 | $title = str_replace('"', '"', $title); |
| 783 | - $result .= " title=\"$title\""; # $title already quoted |
|
| 770 | + $result .= " title=\"$title\""; # $title already quoted |
|
| 784 | 771 | } |
| 785 | 772 | |
| 786 | 773 | $result .= $this->empty_element_suffix; |
@@ -796,7 +783,7 @@ discard block |
||
| 796 | 783 | ** |
| 797 | 784 | */ |
| 798 | 785 | |
| 799 | - function createElement($markup, $attrs, $body=NULL) |
|
| 786 | + function createElement($markup, $attrs, $body = NULL) |
|
| 800 | 787 | { |
| 801 | 788 | $rc = array(); |
| 802 | 789 | |
@@ -845,8 +832,7 @@ discard block |
||
| 845 | 832 | # markup |
| 846 | 833 | # |
| 847 | 834 | |
| 848 | - $text = preg_replace_callback |
|
| 849 | - ( |
|
| 835 | + $text = preg_replace_callback( |
|
| 850 | 836 | '#(\<\!?[^\s^\>]+)(\s+[^\>]+)?(\/?\>)#m', array($this, '_do_html_markup'), $text |
| 851 | 837 | ); |
| 852 | 838 | |
@@ -858,8 +844,7 @@ discard block |
||
| 858 | 844 | |
| 859 | 845 | // \ICanBoogie\log('## \1 ## <pre>\2</pre>', __FUNCTION__, $text); |
| 860 | 846 | |
| 861 | - $text = preg_replace_callback |
|
| 862 | - ( |
|
| 847 | + $text = preg_replace_callback( |
|
| 863 | 848 | '#\<\/[a-zA-Z]+\>#m', array($this, '_do_html_markup_close'), $text |
| 864 | 849 | ); |
| 865 | 850 | |
@@ -900,8 +885,7 @@ discard block |
||
| 900 | 885 | # strings |
| 901 | 886 | # |
| 902 | 887 | |
| 903 | - $text = preg_replace_callback |
|
| 904 | - ( |
|
| 888 | + $text = preg_replace_callback( |
|
| 905 | 889 | '#\"[^\"]+\"#', array(&$this, '_do_html_string'), $text |
| 906 | 890 | ); |
| 907 | 891 | |
@@ -911,8 +895,7 @@ discard block |
||
| 911 | 895 | # attributes |
| 912 | 896 | # |
| 913 | 897 | |
| 914 | - $text = preg_replace_callback |
|
| 915 | - ( |
|
| 898 | + $text = preg_replace_callback( |
|
| 916 | 899 | '#[^\s\=]+#', array(&$this, '_do_html_attribute'), $text |
| 917 | 900 | ); |
| 918 | 901 | |
@@ -946,7 +929,7 @@ discard block |
||
| 946 | 929 | { |
| 947 | 930 | $in_quotes = NULL; |
| 948 | 931 | |
| 949 | - for ($i = 0 ; $i < strlen($line) ; $i++) |
|
| 932 | + for ($i = 0; $i < strlen($line); $i++) |
|
| 950 | 933 | { |
| 951 | 934 | $c = $line{$i}; |
| 952 | 935 | |
@@ -994,7 +977,7 @@ discard block |
||
| 994 | 977 | |
| 995 | 978 | $y = strlen($text); |
| 996 | 979 | |
| 997 | - for ($i = 0 ; $i < $y ; $i++) |
|
| 980 | + for ($i = 0; $i < $y; $i++) |
|
| 998 | 981 | { |
| 999 | 982 | $c = $text{$i}; |
| 1000 | 983 | |
@@ -1053,8 +1036,7 @@ discard block |
||
| 1053 | 1036 | # comment block |
| 1054 | 1037 | # |
| 1055 | 1038 | |
| 1056 | - $text = preg_replace_callback |
|
| 1057 | - ( |
|
| 1039 | + $text = preg_replace_callback( |
|
| 1058 | 1040 | '#/\*.*?\*/#ms', array(&$this, '_do_php_comment'), $text |
| 1059 | 1041 | ); |
| 1060 | 1042 | |
@@ -1064,8 +1046,7 @@ discard block |
||
| 1064 | 1046 | # functions |
| 1065 | 1047 | # |
| 1066 | 1048 | |
| 1067 | - $text = preg_replace_callback |
|
| 1068 | - ( |
|
| 1049 | + $text = preg_replace_callback( |
|
| 1069 | 1050 | '#(\$?[a-zA-z0-9_]+)\(#', array(&$this, '_do_php_function'), $text |
| 1070 | 1051 | ); |
| 1071 | 1052 | |
@@ -1075,8 +1056,7 @@ discard block |
||
| 1075 | 1056 | |
| 1076 | 1057 | // \ICanBoogie\log('## \1 ## <pre>\2</pre>', __FUNCTION__, \ICanBoogie\escape($text)); |
| 1077 | 1058 | |
| 1078 | - $text = preg_replace_callback |
|
| 1079 | - ( |
|
| 1059 | + $text = preg_replace_callback( |
|
| 1080 | 1060 | '#(\$|\-\>)([a-zA-z0-9_]+)(?!\x1A)#', array(&$this, '_do_php_variable'), $text |
| 1081 | 1061 | ); |
| 1082 | 1062 | |
@@ -1084,13 +1064,11 @@ discard block |
||
| 1084 | 1064 | # numbers |
| 1085 | 1065 | # |
| 1086 | 1066 | |
| 1087 | - $text = preg_replace_callback |
|
| 1088 | - ( |
|
| 1067 | + $text = preg_replace_callback( |
|
| 1089 | 1068 | '#0x[0-9a-fA-F]{1,8}#u', array(&$this, '_do_php_number'), $text |
| 1090 | 1069 | ); |
| 1091 | 1070 | |
| 1092 | - $text = preg_replace_callback |
|
| 1093 | - ( |
|
| 1071 | + $text = preg_replace_callback( |
|
| 1094 | 1072 | '#(?<!\x1A)\d+(?![\w])#u', array(&$this, '_do_php_number'), $text |
| 1095 | 1073 | ); |
| 1096 | 1074 | |
@@ -1098,8 +1076,7 @@ discard block |
||
| 1098 | 1076 | # reserved keywords |
| 1099 | 1077 | # |
| 1100 | 1078 | |
| 1101 | - $reserved = array |
|
| 1102 | - ( |
|
| 1079 | + $reserved = array( |
|
| 1103 | 1080 | 'include_once', |
| 1104 | 1081 | 'require_once', |
| 1105 | 1082 | 'endswitch', |
@@ -1146,8 +1123,7 @@ discard block |
||
| 1146 | 1123 | |
| 1147 | 1124 | foreach ($reserved as $k) |
| 1148 | 1125 | { |
| 1149 | - $text = preg_replace_callback |
|
| 1150 | - ( |
|
| 1126 | + $text = preg_replace_callback( |
|
| 1151 | 1127 | '#' . $k . '#', array(&$this, '_do_php_reserved'), $text |
| 1152 | 1128 | ); |
| 1153 | 1129 | } |
@@ -1156,8 +1132,7 @@ discard block |
||
| 1156 | 1132 | # symbols |
| 1157 | 1133 | # |
| 1158 | 1134 | |
| 1159 | - $text = preg_replace_callback |
|
| 1160 | - ( |
|
| 1135 | + $text = preg_replace_callback( |
|
| 1161 | 1136 | '#[\(\)\[\]\{\}\!\@\%\&\*\|\/\<\>\-\+\=]+#', array(&$this, '_do_php_symbol'), $text |
| 1162 | 1137 | ); |
| 1163 | 1138 | |
@@ -1219,8 +1194,7 @@ discard block |
||
| 1219 | 1194 | |
| 1220 | 1195 | // \ICanBoogie\log('## \1 ## \2', __FUNCTION__, $matches); |
| 1221 | 1196 | |
| 1222 | - return $this->hashPart |
|
| 1223 | - ( |
|
| 1197 | + return $this->hashPart( |
|
| 1224 | 1198 | '<span class="comment">' . |
| 1225 | 1199 | $this->_do_codeentities($matches[0]) . |
| 1226 | 1200 | '</span>' |
@@ -1263,7 +1237,7 @@ discard block |
||
| 1263 | 1237 | return $matches[0]; |
| 1264 | 1238 | } |
| 1265 | 1239 | |
| 1266 | - return $this->hashPart('<span class="function">' . $matches[1] . '</span>', 'F'). '('; |
|
| 1240 | + return $this->hashPart('<span class="function">' . $matches[1] . '</span>', 'F') . '('; |
|
| 1267 | 1241 | } |
| 1268 | 1242 | |
| 1269 | 1243 | function _do_php_symbol($matches) |
@@ -1289,10 +1263,10 @@ discard block |
||
| 1289 | 1263 | |
| 1290 | 1264 | function _doAnchors_inline_callback($matches) |
| 1291 | 1265 | { |
| 1292 | - $whole_match = $matches[1]; |
|
| 1293 | - $link_text = $this->runSpanGamut($matches[2]); |
|
| 1294 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 1295 | - $title =& $matches[7]; |
|
| 1266 | + $whole_match = $matches[1]; |
|
| 1267 | + $link_text = $this->runSpanGamut($matches[2]); |
|
| 1268 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 1269 | + $title = & $matches[7]; |
|
| 1296 | 1270 | |
| 1297 | 1271 | $url = $this->encodeAmpsAndAngles($url); |
| 1298 | 1272 | |
@@ -1300,7 +1274,7 @@ discard block |
||
| 1300 | 1274 | if (isset($title)) { |
| 1301 | 1275 | $title = str_replace('"', '"', $title); |
| 1302 | 1276 | $title = $this->encodeAmpsAndAngles($title); |
| 1303 | - $result .= " title=\"$title\""; |
|
| 1277 | + $result .= " title=\"$title\""; |
|
| 1304 | 1278 | } |
| 1305 | 1279 | |
| 1306 | 1280 | if (substr($url, 0, 7) == 'http://') |
@@ -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 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $hooks . 'markup_template', [ |
| 16 | 16 | |
| 17 | - 'name' => [ 'required' => true ] |
|
| 17 | + 'name' => ['required' => true] |
|
| 18 | 18 | |
| 19 | 19 | ], |
| 20 | 20 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | $hooks . 'markup_call_template', [ |
| 28 | 28 | |
| 29 | - 'name' => [ 'required' => true ] |
|
| 29 | + 'name' => ['required' => true] |
|
| 30 | 30 | |
| 31 | 31 | ], |
| 32 | 32 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $hooks . 'markup_decorate', [ |
| 40 | 40 | |
| 41 | - 'with' => [ 'required' => true ] |
|
| 41 | + 'with' => ['required' => true] |
|
| 42 | 42 | |
| 43 | 43 | ] |
| 44 | 44 | ], |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $hooks . 'markup_foreach', [ |
| 49 | 49 | |
| 50 | - 'in' => [ 'default' => 'this', 'expression' => true ], |
|
| 50 | + 'in' => ['default' => 'this', 'expression' => true], |
|
| 51 | 51 | 'as' => null |
| 52 | 52 | |
| 53 | 53 | ] |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $hooks . 'markup_variable', [ |
| 59 | 59 | |
| 60 | - 'name' => [ 'required' => true ], |
|
| 61 | - 'select' => [ 'expression' => true ] |
|
| 60 | + 'name' => ['required' => true], |
|
| 61 | + 'select' => ['expression' => true] |
|
| 62 | 62 | |
| 63 | 63 | ], |
| 64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $hooks . 'markup_with', [ |
| 71 | 71 | |
| 72 | - 'select' => [ 'expression' => true ] |
|
| 72 | + 'select' => ['expression' => true] |
|
| 73 | 73 | |
| 74 | 74 | ] |
| 75 | 75 | ], |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $hooks . 'markup_if', [ |
| 91 | 91 | |
| 92 | - 'test' => [ 'expression' => [ 'silent' => true ] ], |
|
| 93 | - 'select' => [ 'expression' => [ 'silent' => true ] ], |
|
| 92 | + 'test' => ['expression' => ['silent' => true]], |
|
| 93 | + 'select' => ['expression' => ['silent' => true]], |
|
| 94 | 94 | 'equals' => null |
| 95 | 95 | |
| 96 | 96 | ], |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $hooks . 'markup_translate', [ |
| 105 | 105 | |
| 106 | - 'native' => [ 'required' => true ] |
|
| 106 | + 'native' => ['required' => true] |
|
| 107 | 107 | |
| 108 | 108 | ] |
| 109 | 109 | ], |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | 'page' => null, |
| 121 | 121 | 'limit' => null, |
| 122 | 122 | 'with' => null, |
| 123 | - 'range' => [ 'expression' => true ], |
|
| 123 | + 'range' => ['expression' => true], |
|
| 124 | 124 | 'noarrows' => false |
| 125 | 125 | |
| 126 | 126 | ] |
@@ -136,11 +136,11 @@ |
||
| 136 | 136 | # call hook |
| 137 | 137 | # |
| 138 | 138 | |
| 139 | - $engine->trace_enter([ 'markup', $name ]); |
|
| 139 | + $engine->trace_enter(['markup', $name]); |
|
| 140 | 140 | |
| 141 | 141 | if ($binding) |
| 142 | 142 | { |
| 143 | - array_push($engine->context_markup, [ $engine->context['self'], $engine->context['this'] ]); |
|
| 143 | + array_push($engine->context_markup, [$engine->context['self'], $engine->context['this']]); |
|
| 144 | 144 | |
| 145 | 145 | $engine->context['self'] = [ |
| 146 | 146 | |
@@ -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 | } |