1 | <?php |
||
15 | class Markdown extends Parser |
||
16 | { |
||
17 | // include block element parsing using traits |
||
18 | use block\CodeTrait; |
||
19 | use block\HeadlineTrait; |
||
20 | use block\HtmlTrait { |
||
21 | parseInlineHtml as private; |
||
22 | } |
||
23 | use block\ListTrait { |
||
24 | // Check Ul List before headline |
||
25 | identifyUl as protected identifyBUl; |
||
26 | consumeUl as protected consumeBUl; |
||
27 | } |
||
28 | use block\QuoteTrait; |
||
29 | use block\RuleTrait { |
||
30 | // Check Hr before checking lists |
||
31 | identifyHr as protected identifyAHr; |
||
32 | consumeHr as protected consumeAHr; |
||
33 | } |
||
34 | |||
35 | // include inline element parsing using traits |
||
36 | use inline\CodeTrait; |
||
37 | use inline\EmphStrongTrait; |
||
38 | use inline\LinkTrait; |
||
39 | |||
40 | /** |
||
41 | * @var boolean whether to format markup according to HTML5 spec. |
||
42 | * Defaults to `false` which means that markup is formatted as HTML4. |
||
43 | */ |
||
44 | public $html5 = false; |
||
45 | |||
46 | /** |
||
47 | * @var array these are "escapeable" characters. When using one of these prefixed with a |
||
48 | * backslash, the character will be outputted without the backslash and is not interpreted |
||
49 | * as markdown. |
||
50 | */ |
||
51 | protected $escapeCharacters = [ |
||
52 | '\\', // backslash |
||
53 | '`', // backtick |
||
54 | '*', // asterisk |
||
55 | '_', // underscore |
||
56 | '{', '}', // curly braces |
||
57 | '[', ']', // square brackets |
||
58 | '(', ')', // parentheses |
||
59 | '#', // hash mark |
||
60 | '+', // plus sign |
||
61 | '-', // minus sign (hyphen) |
||
62 | '.', // dot |
||
63 | '!', // exclamation mark |
||
64 | '<', '>', |
||
65 | ]; |
||
66 | |||
67 | |||
68 | /** |
||
69 | * @inheritDoc |
||
70 | */ |
||
71 | 201 | protected function prepare() |
|
76 | |||
77 | /** |
||
78 | * Consume lines for a paragraph |
||
79 | * |
||
80 | * Allow headlines and code to break paragraphs |
||
81 | */ |
||
82 | 128 | protected function consumeParagraph($lines, $current) |
|
117 | |||
118 | |||
119 | /** |
||
120 | * @inheritdocs |
||
121 | * |
||
122 | * Parses a newline indicated by two spaces on the end of a markdown line. |
||
123 | */ |
||
124 | 200 | protected function renderText($text) |
|
128 | } |
||
129 |