@@ -12,23 +12,23 @@ discard block |
||
12 | 12 | * Supported filters. |
13 | 13 | */ |
14 | 14 | private $standardFilters = [ |
15 | - 'yamlfrontmatter', |
|
16 | - 'bbcode', |
|
17 | - 'clickable', |
|
18 | - 'markdown', |
|
19 | - 'nl2br', |
|
20 | - 'shortcode', |
|
21 | - 'purify', |
|
22 | - 'titlefromh1', |
|
23 | - ]; |
|
24 | - |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * Test. |
|
29 | - * |
|
30 | - * @return void |
|
31 | - */ |
|
15 | + 'yamlfrontmatter', |
|
16 | + 'bbcode', |
|
17 | + 'clickable', |
|
18 | + 'markdown', |
|
19 | + 'nl2br', |
|
20 | + 'shortcode', |
|
21 | + 'purify', |
|
22 | + 'titlefromh1', |
|
23 | + ]; |
|
24 | + |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * Test. |
|
29 | + * |
|
30 | + * @return void |
|
31 | + */ |
|
32 | 32 | public function testTitleFromFirstH1() |
33 | 33 | { |
34 | 34 | $filter = new CTextFilter(); |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | |
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Test. |
|
64 | - * |
|
65 | - * @expectedException /Mos/TextFilter/Exception |
|
66 | - * |
|
67 | - * @return void |
|
68 | - */ |
|
62 | + /** |
|
63 | + * Test. |
|
64 | + * |
|
65 | + * @expectedException /Mos/TextFilter/Exception |
|
66 | + * |
|
67 | + * @return void |
|
68 | + */ |
|
69 | 69 | public function testJsonFrontMatterException() |
70 | 70 | { |
71 | 71 | $filter = new CTextFilter(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | |
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Test. |
|
85 | - * |
|
86 | - * @return void |
|
87 | - */ |
|
83 | + /** |
|
84 | + * Test. |
|
85 | + * |
|
86 | + * @return void |
|
87 | + */ |
|
88 | 88 | public function testJsonFrontMatter() |
89 | 89 | { |
90 | 90 | $filter = new CTextFilter(); |
@@ -34,26 +34,26 @@ discard block |
||
34 | 34 | $filter = new CTextFilter(); |
35 | 35 | |
36 | 36 | $text = ""; |
37 | - $res = $filter->parse($text, ["titlefromh1"]); |
|
38 | - $title = $res->frontmatter["title"]; |
|
37 | + $res = $filter->parse($text, [ "titlefromh1" ]); |
|
38 | + $title = $res->frontmatter[ "title" ]; |
|
39 | 39 | $this->assertNull($title, "Title should be null"); |
40 | 40 | |
41 | 41 | $text = "<h1>My title</h1>"; |
42 | 42 | $exp = "My title"; |
43 | - $res = $filter->parse($text, ["titlefromh1"]); |
|
44 | - $title = $res->frontmatter["title"]; |
|
43 | + $res = $filter->parse($text, [ "titlefromh1" ]); |
|
44 | + $title = $res->frontmatter[ "title" ]; |
|
45 | 45 | $this->assertEquals($exp, $title, "Title missmatch"); |
46 | 46 | |
47 | 47 | $text = "<h1><a href=''>My title</a></h1>"; |
48 | 48 | $exp = "My title"; |
49 | - $res = $filter->parse($text, ["titlefromh1"]); |
|
50 | - $title = $res->frontmatter["title"]; |
|
49 | + $res = $filter->parse($text, [ "titlefromh1" ]); |
|
50 | + $title = $res->frontmatter[ "title" ]; |
|
51 | 51 | $this->assertEquals($exp, $title, "Title missmatch"); |
52 | 52 | |
53 | 53 | $text = "<h1 class=''>My title</h1>"; |
54 | 54 | $exp = "My title"; |
55 | - $res = $filter->parse($text, ["titlefromh1"]); |
|
56 | - $title = $res->frontmatter["title"]; |
|
55 | + $res = $filter->parse($text, [ "titlefromh1" ]); |
|
56 | + $title = $res->frontmatter[ "title" ]; |
|
57 | 57 | $this->assertEquals($exp, $title, "Title missmatch"); |
58 | 58 | } |
59 | 59 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | }}} |
77 | 77 | EOD; |
78 | - $filter->parse($text, ["jsonfrontmatter"]); |
|
78 | + $filter->parse($text, [ "jsonfrontmatter" ]); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $filter = new CTextFilter(); |
91 | 91 | |
92 | 92 | $text = ""; |
93 | - $res = $filter->parse($text, ["jsonfrontmatter"]); |
|
93 | + $res = $filter->parse($text, [ "jsonfrontmatter" ]); |
|
94 | 94 | $this->assertNull($res->frontmatter, "Frontmatter should be null"); |
95 | 95 | $this->assertEmpty($res->text, "Text should be empty"); |
96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | }}} |
100 | 100 | |
101 | 101 | EOD; |
102 | - $res = $filter->parse($text, ["jsonfrontmatter"]); |
|
102 | + $res = $filter->parse($text, [ "jsonfrontmatter" ]); |
|
103 | 103 | $this->assertEmpty($res->frontmatter, "Frontmatter should be empty"); |
104 | 104 | $this->assertEmpty($res->text, "Text should be empty"); |
105 | 105 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | }}} |
113 | 113 | $txt |
114 | 114 | EOD; |
115 | - $res = $filter->parse($text, ["jsonfrontmatter"]); |
|
115 | + $res = $filter->parse($text, [ "jsonfrontmatter" ]); |
|
116 | 116 | $this->assertEquals( |
117 | 117 | $res->frontmatter, |
118 | 118 | [ |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | --- |
147 | 147 | EOD; |
148 | - $filter->parse($text, ["yamlfrontmatter"]); |
|
148 | + $filter->parse($text, [ "yamlfrontmatter" ]); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $filter = new CTextFilter(); |
165 | 165 | |
166 | 166 | $text = ""; |
167 | - $res = $filter->parse($text, ["yamlfrontmatter"]); |
|
167 | + $res = $filter->parse($text, [ "yamlfrontmatter" ]); |
|
168 | 168 | $this->assertNull($res->frontmatter, "Frontmatter should be null"); |
169 | 169 | $this->assertEmpty($res->text, "Text should be empty"); |
170 | 170 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | --- |
174 | 174 | |
175 | 175 | EOD; |
176 | - $res = $filter->parse($text, ["yamlfrontmatter"]); |
|
176 | + $res = $filter->parse($text, [ "yamlfrontmatter" ]); |
|
177 | 177 | $this->assertEmpty($res->frontmatter, "Frontmatter should be empty"); |
178 | 178 | $this->assertEmpty($res->text, "Text should be empty"); |
179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | --- |
185 | 185 | $txt |
186 | 186 | EOD; |
187 | - $res = $filter->parse($text, ["yamlfrontmatter"]); |
|
187 | + $res = $filter->parse($text, [ "yamlfrontmatter" ]); |
|
188 | 188 | $this->assertEquals( |
189 | 189 | $res->frontmatter, |
190 | 190 | [ |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | This is an example on writing text and adding a YAML frontmatter. |
206 | 206 | |
207 | 207 | EOD; |
208 | - $res = $filter->parse($text, ["yamlfrontmatter", "markdown"]); |
|
208 | + $res = $filter->parse($text, [ "yamlfrontmatter", "markdown" ]); |
|
209 | 209 | //var_dump($res); |
210 | 210 | $this->assertEquals( |
211 | 211 | $res->frontmatter, |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | $text = "Header\n========="; |
283 | 283 | $exp = "<h1>Header</h1>\n"; |
284 | - $res = $filter->parse($text, ["markdown", "purify"]); |
|
284 | + $res = $filter->parse($text, [ "markdown", "purify" ]); |
|
285 | 285 | $this->assertEquals($exp, $res->text, "Purify failed"); |
286 | 286 | } |
287 | 287 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | $html = "Header[b]text[/b]\n========="; |
334 | 334 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
335 | - $res = $filter->doFilter($html, ["markdown", "bbcode"]); |
|
335 | + $res = $filter->doFilter($html, [ "markdown", "bbcode" ]); |
|
336 | 336 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
337 | 337 | } |
338 | 338 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | $html = "Header\n========="; |
351 | 351 | $exp = "<h1>Header</h1>\n"; |
352 | - $res = $filter->doFilter($html, ["markdown"]); |
|
352 | + $res = $filter->doFilter($html, [ "markdown" ]); |
|
353 | 353 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
354 | 354 | } |
355 | 355 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | [FIGURE src=$src caption="$caption"] |
440 | 440 | EOD; |
441 | 441 | |
442 | - $exp = <<<EOD |
|
442 | + $exp = <<<EOD |
|
443 | 443 | <figure class='figure'> |
444 | 444 | <a href='$src'><img src='$src' alt='$caption'/></a> |
445 | 445 | <figcaption markdown=1>$caption</figcaption> |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | // Filter the content |
26 | 26 | $filter = new \Mos\TextFilter\CTextFilter(); |
27 | -$page = $filter->parse($text, ["yamlfrontmatter", "markdown"]); |
|
27 | +$page = $filter->parse($text, [ "yamlfrontmatter", "markdown" ]); |
|
28 | 28 | ?> |
29 | 29 | |
30 | 30 | <!doctype html> |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | // Filter the content |
47 | 47 | $filter = new \Mos\TextFilter\CTextFilter(); |
48 | -$document = $filter->parse($text, ["markdown", "shortcode", "clickable", "bbcode"]); |
|
48 | +$document = $filter->parse($text, [ "markdown", "shortcode", "clickable", "bbcode" ]); |
|
49 | 49 | ?> |
50 | 50 | |
51 | 51 | <!doctype html> |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | // Filter the content |
29 | 29 | $filter = new \Mos\TextFilter\CTextFilter(); |
30 | -$page = $filter->parse($text, ["jsonfrontmatter", "markdown"]); |
|
30 | +$page = $filter->parse($text, [ "jsonfrontmatter", "markdown" ]); |
|
31 | 31 | ?> |
32 | 32 | |
33 | 33 | <!doctype html> |
@@ -6,5 +6,5 @@ |
||
6 | 6 | # Take a look at the PSR-0-compatible class autoloading implementation |
7 | 7 | # in the Readme.php file if you want a simple autoloader setup. |
8 | 8 | |
9 | -require_once dirname(__FILE__) . '/MarkdownInterface.php'; |
|
10 | -require_once dirname(__FILE__) . '/Markdown.php'; |
|
9 | +require_once dirname(__FILE__).'/MarkdownInterface.php'; |
|
10 | +require_once dirname(__FILE__).'/Markdown.php'; |
@@ -6,6 +6,6 @@ |
||
6 | 6 | # Take a look at the PSR-0-compatible class autoloading implementation |
7 | 7 | # in the Readme.php file if you want a simple autoloader setup. |
8 | 8 | |
9 | -require_once dirname(__FILE__) . '/MarkdownInterface.php'; |
|
10 | -require_once dirname(__FILE__) . '/Markdown.php'; |
|
11 | -require_once dirname(__FILE__) . '/MarkdownExtra.php'; |
|
9 | +require_once dirname(__FILE__).'/MarkdownInterface.php'; |
|
10 | +require_once dirname(__FILE__).'/Markdown.php'; |
|
11 | +require_once dirname(__FILE__).'/MarkdownExtra.php'; |
@@ -6,4 +6,4 @@ |
||
6 | 6 | # Take a look at the PSR-0-compatible class autoloading implementation |
7 | 7 | # in the Readme.php file if you want a simple autoloader setup. |
8 | 8 | |
9 | -require_once dirname(__FILE__) . '/MarkdownInterface.php'; |
|
9 | +require_once dirname(__FILE__).'/MarkdownInterface.php'; |
@@ -19,16 +19,16 @@ |
||
19 | 19 | |
20 | 20 | interface MarkdownInterface { |
21 | 21 | |
22 | - # |
|
23 | - # Initialize the parser and return the result of its transform method. |
|
24 | - # This will work fine for derived classes too. |
|
25 | - # |
|
26 | - public static function defaultTransform($text); |
|
22 | + # |
|
23 | + # Initialize the parser and return the result of its transform method. |
|
24 | + # This will work fine for derived classes too. |
|
25 | + # |
|
26 | + public static function defaultTransform($text); |
|
27 | 27 | |
28 | - # |
|
29 | - # Main function. Performs some preprocessing on the input text |
|
30 | - # and pass it through the document gamut. |
|
31 | - # |
|
32 | - public function transform($text); |
|
28 | + # |
|
29 | + # Main function. Performs some preprocessing on the input text |
|
30 | + # and pass it through the document gamut. |
|
31 | + # |
|
32 | + public function transform($text); |
|
33 | 33 | |
34 | 34 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | # Install PSR-0-compatible class autoloader |
8 | 8 | spl_autoload_register(function($class){ |
9 | - require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php'; |
|
9 | + require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php'; |
|
10 | 10 | }); |
11 | 11 | |
12 | 12 | # Get Markdown class |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | </head> |
25 | 25 | <body> |
26 | 26 | <?php |
27 | - # Put HTML content in the document |
|
28 | - echo $html; |
|
29 | - ?> |
|
27 | + # Put HTML content in the document |
|
28 | + echo $html; |
|
29 | + ?> |
|
30 | 30 | </body> |
31 | 31 | </html> |
@@ -5,7 +5,7 @@ |
||
5 | 5 | # you like. |
6 | 6 | |
7 | 7 | # Install PSR-0-compatible class autoloader |
8 | -spl_autoload_register(function($class){ |
|
8 | +spl_autoload_register(function($class) { |
|
9 | 9 | require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php'; |
10 | 10 | }); |
11 | 11 |