@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | // some normalisations |
| 25 | 25 | $this->Lines = |
| 26 | - explode("\n", // the lines ! |
|
| 26 | + explode("\n", // the lines ! |
|
| 27 | 27 | trim( // trim trailing \n |
| 28 | - str_replace(["\r\n", "\r"], "\n", // use standard newline |
|
| 28 | + str_replace(["\r\n", "\r"], "\n", // use standard newline |
|
| 29 | 29 | str_replace("\t", ' ', $markdown) // use 4 spaces for tab |
| 30 | 30 | ), "\n" |
| 31 | 31 | ) |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $markup = ''; |
| 55 | 55 | $nestLevel = $quoteLevel = 0; |
| 56 | - $indent = $nextIndent = 0; |
|
| 57 | - $stackList = $stackBlock = $stackTable = []; |
|
| 56 | + $indent = $nextIndent = 0; |
|
| 57 | + $stackList = $stackBlock = $stackTable = []; |
|
| 58 | 58 | $lastPointer = count($this->Lines) - 1; |
| 59 | 59 | |
| 60 | 60 | while (isset($this->Lines[++$this->Pointer])) { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $markup .= "\n"; |
| 77 | 77 | |
| 78 | - $inList = $inQuote = $inPara = $inHtml = null; |
|
| 78 | + $inList = $inQuote = $inPara = $inHtml = null; |
|
| 79 | 79 | $nestLevel = $quoteLevel = 0; |
| 80 | 80 | continue; |
| 81 | 81 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | if ($mark1 === '#') { |
| 124 | 124 | $level = strlen($trimmedLine) - strlen(ltrim($trimmedLine, '#')); |
| 125 | 125 | if ($level < 7) { |
| 126 | - $markup .= "\n<h{$level}>" . ltrim($trimmedLine, '# ') . "</h{$level}>"; |
|
| 126 | + $markup .= "\n<h{$level}>".ltrim($trimmedLine, '# ')."</h{$level}>"; |
|
| 127 | 127 | continue; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | ++$nestLevel; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $markup .= '<li>' . ltrim($trimmedLine, '-*0123456789. '); |
|
| 185 | + $markup .= '<li>'.ltrim($trimmedLine, '-*0123456789. '); |
|
| 186 | 186 | |
| 187 | 187 | if ($ul = in_array($nextMark12, ['- ', '* ', '+ ']) or |
| 188 | 188 | preg_match('/^\d+\. /', $trimmedNextLine) |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | 288 | // images |
| 289 | - $markup = preg_replace_callback('~!\[(.+?)\]\s*\((.+?)\s*(".+?")?\)~', function ($img) { |
|
| 289 | + $markup = preg_replace_callback('~!\[(.+?)\]\s*\((.+?)\s*(".+?")?\)~', function($img) { |
|
| 290 | 290 | $title = isset($img[3]) ? " title={$img[3]} " : ''; |
| 291 | 291 | $alt = $img[1] ? " alt=\"{$img[1]}\" " : ''; |
| 292 | 292 | |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | }, $markup); |
| 295 | 295 | |
| 296 | 296 | // anchors |
| 297 | - $markup = preg_replace_callback('~\[(.+?)\]\s*\((.+?)\s*(".+?")?\)~', function ($a) { |
|
| 297 | + $markup = preg_replace_callback('~\[(.+?)\]\s*\((.+?)\s*(".+?")?\)~', function($a) { |
|
| 298 | 298 | $title = isset($a[3]) ? " title={$a[3]} " : ''; |
| 299 | 299 | |
| 300 | 300 | return "<a href=\"{$a[2]}\"{$title}>{$a[1]}</a>"; |
| 301 | 301 | }, $markup); |
| 302 | 302 | |
| 303 | 303 | // em/code/strong/del |
| 304 | - $markup = preg_replace_callback('!(\*{1,2}|_{1,2}|`|~~)(.+?)\\1!', function ($em) { |
|
| 304 | + $markup = preg_replace_callback('!(\*{1,2}|_{1,2}|`|~~)(.+?)\\1!', function($em) { |
|
| 305 | 305 | switch (true) { |
| 306 | 306 | case substr($em[1], 0, 2) === '**': |
| 307 | 307 | case substr($em[1], 0, 2) === '__': |
@@ -2,9 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Ahc\HtmlUp; |
| 4 | 4 | |
| 5 | -require dirname(__DIR__) . '/vendor/autoload.php'; |
|
| 5 | +require dirname(__DIR__).'/vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | -$markdown = file_get_contents(dirname(__DIR__) . '/readme.md'); |
|
| 7 | +$markdown = file_get_contents(dirname(__DIR__).'/readme.md'); |
|
| 8 | 8 | |
| 9 | 9 | /* You can use any of the three usage methods below */ |
| 10 | 10 | |