| @@ -1,8 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentSupport\App\Services\Parser; |
| 4 | 4 | |
| 5 | +// Check if another version of Parsedown is already loaded | |
| 6 | +if (class_exists('Parsedown')) { | |
| 7 | + // If the global Parsedown class exists, check version compatibility | |
| 8 | + if (version_compare(Parsedown::version, '1.8.0', '>=')) { | |
| 9 | + // Use the existing Parsedown class as an alias | |
| 10 | + class_alias('Parsedown', 'FluentSupport\App\Services\Parser\Parsedown'); | |
| 11 | + return; | |
| 12 | + } | |
| 13 | +} | |
| 14 | + | |
| 5 | 15 | # |
| 6 | 16 | # |
| 7 | 17 | # Parsedown |
| 8 | 18 | # http://parsedown.org |
| @@ -18,9 +28,9 @@ | ||
| 18 | 28 | class Parsedown |
| 19 | 29 | { |
| 20 | 30 | # ~ |
| 21 | 31 | |
| 22 | - const version = '1.8.0-beta-7'; | |
| 32 | + const version = '1.8.0'; | |
| 23 | 33 | |
| 24 | 34 | # ~ |
| 25 | 35 | |
| 26 | 36 | function text($text) |
| @@ -40,9 +50,8 @@ | ||
| 40 | 50 | { |
| 41 | 51 | # make sure no definitions are set |
| 42 | 52 | $this->DefinitionData = array(); |
| 43 | 53 | |
| 44 | - | |
| 45 | 54 | # standardize line breaks |
| 46 | 55 | $text = str_replace(array("\r\n", "\r"), "\n", $text); |
| 47 | 56 | |
| 48 | 57 | # remove surrounding line breaks |
| @@ -573,9 +582,9 @@ | ||
| 573 | 582 | |
| 574 | 583 | # |
| 575 | 584 | # List |
| 576 | 585 | |
| 577 | - protected function blockList($Line, array $CurrentBlock = null) | |
| 586 | + protected function blockList($Line, ?array $CurrentBlock = null) | |
| 578 | 587 | { |
| 579 | 588 | list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]{1,9}+[.\)]'); |
| 580 | 589 | |
| 581 | 590 | if (preg_match('/^('.$pattern.'([ ]++|$))(.*+)/', $Line['text'], $matches)) |
| @@ -810,9 +819,9 @@ | ||
| 810 | 819 | |
| 811 | 820 | # |
| 812 | 821 | # Setext |
| 813 | 822 | |
| 814 | - protected function blockSetextHeader($Line, array $Block = null) | |
| 823 | + protected function blockSetextHeader($Line, ?array $Block = null) | |
| 815 | 824 | { |
| 816 | 825 | if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) |
| 817 | 826 | { |
| 818 | 827 | return; |
| @@ -896,9 +905,9 @@ | ||
| 896 | 905 | |
| 897 | 906 | # |
| 898 | 907 | # Table |
| 899 | 908 | |
| 900 | - protected function blockTable($Line, array $Block = null) | |
| 909 | + protected function blockTable($Line, ?array $Block = null) | |
| 901 | 910 | { |
| 902 | 911 | if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) |
| 903 | 912 | { |
| 904 | 913 | return; |