1 | <?php |
||
21 | class BaseMarkdown |
||
22 | { |
||
23 | /** |
||
24 | * @var array a map of markdown flavor names to corresponding parser class configurations. |
||
25 | */ |
||
26 | public static $flavors = [ |
||
27 | 'original' => [ |
||
28 | 'class' => \cebe\markdown\Markdown::class, |
||
29 | 'html5' => true, |
||
30 | ], |
||
31 | 'gfm' => [ |
||
32 | 'class' => \cebe\markdown\GithubMarkdown::class, |
||
33 | 'html5' => true, |
||
34 | ], |
||
35 | 'gfm-comment' => [ |
||
36 | 'class' => \cebe\markdown\GithubMarkdown::class, |
||
37 | 'html5' => true, |
||
38 | 'enableNewlines' => true, |
||
39 | ], |
||
40 | 'extra' => [ |
||
41 | 'class' => \cebe\markdown\MarkdownExtra::class, |
||
42 | 'html5' => true, |
||
43 | ], |
||
44 | ]; |
||
45 | /** |
||
46 | * @var string the markdown flavor to use when none is specified explicitly. |
||
47 | * Defaults to `original`. |
||
48 | * @see $flavors |
||
49 | */ |
||
50 | public static $defaultFlavor = 'original'; |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Converts markdown into HTML. |
||
55 | * |
||
56 | * @param string $markdown the markdown text to parse |
||
57 | * @param string $flavor the markdown flavor to use. See [[$flavors]] for available values. |
||
58 | * Defaults to [[$defaultFlavor]], if not set. |
||
59 | * @return string the parsed HTML output |
||
60 | * @throws \yii\base\InvalidArgumentException when an undefined flavor is given. |
||
61 | */ |
||
62 | 2 | public static function process($markdown, $flavor = null) |
|
68 | |||
69 | /** |
||
70 | * Converts markdown into HTML but only parses inline elements. |
||
71 | * |
||
72 | * This can be useful for parsing small comments or description lines. |
||
73 | * |
||
74 | * @param string $markdown the markdown text to parse |
||
75 | * @param string $flavor the markdown flavor to use. See [[$flavors]] for available values. |
||
76 | * Defaults to [[$defaultFlavor]], if not set. |
||
77 | * @return string the parsed HTML output |
||
78 | * @throws \yii\base\InvalidArgumentException when an undefined flavor is given. |
||
79 | */ |
||
80 | 1 | public static function processParagraph($markdown, $flavor = null) |
|
86 | |||
87 | /** |
||
88 | * @param string $flavor the markdown flavor to use. See [[$flavors]] for available values. |
||
89 | * Defaults to [[$defaultFlavor]], if not set. |
||
90 | * @return \cebe\markdown\Parser |
||
91 | * @throws \yii\base\InvalidArgumentException when an undefined flavor is given. |
||
92 | */ |
||
93 | 3 | protected static function getParser($flavor) |
|
107 | } |
||
108 |