guard-mthaml 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/lib/guard/mthaml/version.rb +1 -1
  4. data/vendor/autoload.php +1 -1
  5. data/vendor/composer/autoload_real.php +4 -4
  6. data/vendor/composer/installed.json +68 -60
  7. data/vendor/michelf/php-markdown/License.md +2 -2
  8. data/vendor/michelf/php-markdown/Michelf/Markdown.php +130 -1638
  9. data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php +1592 -16
  10. data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php +2 -5
  11. data/vendor/michelf/php-markdown/Readme.md +32 -10
  12. data/vendor/michelf/php-markdown/composer.json +2 -2
  13. data/vendor/mthaml/mthaml/CHANGELOG +6 -0
  14. data/vendor/mthaml/mthaml/composer.json +11 -3
  15. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown.php +1 -52
  16. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/CommonMark.php +25 -0
  17. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/FluxBBMarkdown.php +25 -0
  18. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/OptimizableFilter.php +58 -0
  19. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/ReST.php +21 -0
  20. data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCase.php +1 -1
  21. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_commonmark.test +33 -0
  22. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_fluxbb.test +32 -0
  23. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/rest_filter.test +42 -0
  24. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/rest_optimization_filter.test +39 -0
  25. metadata +11 -2
@@ -3,8 +3,8 @@
3
3
  # Markdown - A text-to-HTML conversion tool for web writers
4
4
  #
5
5
  # PHP Markdown
6
- # Copyright (c) 2004-2014 Michel Fortin
7
- # <http://michelf.com/projects/php-markdown/>
6
+ # Copyright (c) 2004-2015 Michel Fortin
7
+ # <https://michelf.ca/projects/php-markdown/>
8
8
  #
9
9
  # Original Markdown
10
10
  # Copyright (c) 2004-2006 John Gruber
@@ -32,6 +32,3 @@ interface MarkdownInterface {
32
32
  public function transform($text);
33
33
 
34
34
  }
35
-
36
-
37
- ?>
@@ -1,10 +1,10 @@
1
1
  PHP Markdown
2
2
  ============
3
3
 
4
- PHP Markdown Lib 1.4.1 - 4 May 2013
4
+ PHP Markdown Lib 1.5.0 - 1 Mar 2015
5
5
 
6
6
  by Michel Fortin
7
- <http://michelf.ca/>
7
+ <https://michelf.ca/>
8
8
 
9
9
  based on Markdown by John Gruber
10
10
  <http://daringfireball.net/>
@@ -25,10 +25,10 @@ software tool, originally written in Perl, that converts the plain text
25
25
  markup to HTML. PHP Markdown is a port to PHP of the original Markdown
26
26
  program by John Gruber.
27
27
 
28
- * [Full documentation of the Markdown syntax](<http://daringfireball.net/projects/markdown/>)
29
- - Daring Fireball (John Gruber)
30
- * [Markdown Extra syntax additions](<http://michelf.ca/projects/php-markdown/extra/>)
31
- - Michel Fortin
28
+ * [Full documentation of the Markdown syntax](<http://daringfireball.net/projects/markdown/>)
29
+ Daring Fireball (John Gruber)
30
+ * [Markdown Extra syntax additions](<https://michelf.ca/projects/php-markdown/extra/>)
31
+ Michel Fortin
32
32
 
33
33
 
34
34
  Requirement
@@ -83,7 +83,7 @@ configuration variables:
83
83
 
84
84
  To learn more, see the full list of [configuration variables].
85
85
 
86
- [configuration variables]: http://michelf.ca/projects/php-markdown/configuration/
86
+ [configuration variables]: https://michelf.ca/projects/php-markdown/configuration/
87
87
 
88
88
 
89
89
  ### Usage without an autoloader
@@ -174,6 +174,28 @@ PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to
174
174
  Version History
175
175
  ---------------
176
176
 
177
+ PHP Markdown Lib 1.5.0 (1 Mar 2015)
178
+
179
+ * Added the ability start ordered lists with a number different from 1 and
180
+ and have that reflected in the HTML output. This can be enabled with
181
+ the `enhanced_ordered_lists` configuration variable for the Markdown
182
+ parser; it is enabled by default for Markdown Extra.
183
+ Credits to Matt Gorle for providing the implementation.
184
+
185
+ * Added the ability to insert custom HTML attributes with simple values
186
+ everywhere an extra attribute block is allowed (links, images, headers).
187
+ The value must be unquoted, cannot contains spaces and is limited to
188
+ alphanumeric ASCII characters.
189
+ Credits to Peter Droogmans for providing the implementation.
190
+
191
+ * Added a `header_id_func` configuration variable which takes a function
192
+ that can generate an `id` attribute value from the header text.
193
+ Credits to Evert Pot for providing the implementation.
194
+
195
+ * Added a `url_filter_func` configuration variable which takes a function
196
+ that can rewrite any link or image URL to something different.
197
+
198
+
177
199
  PHP Markdown Lib 1.4.1 (4 May 2014)
178
200
 
179
201
  * The HTML block parser will now treat `<figure>` as a block-level element
@@ -229,7 +251,7 @@ PHP Markdown Extra 1.2.6:
229
251
 
230
252
  * Plugin interface for WordPress and other systems is no longer present in
231
253
  the Lib package. The classic package is still available if you need it:
232
- <http://michelf.ca/projects/php-markdown/classic/>
254
+ <https://michelf.ca/projects/php-markdown/classic/>
233
255
 
234
256
  * Added `public` and `protected` protection attributes, plus a section about
235
257
  what is "public API" and what isn't in the Readme file.
@@ -267,8 +289,8 @@ Copyright and License
267
289
  ---------------------
268
290
 
269
291
  PHP Markdown Lib
270
- Copyright (c) 2004-2014 Michel Fortin
271
- <http://michelf.ca/>
292
+ Copyright (c) 2004-2015 Michel Fortin
293
+ <https://michelf.ca/>
272
294
  All rights reserved.
273
295
 
274
296
  Based on Markdown
@@ -2,14 +2,14 @@
2
2
  "name": "michelf/php-markdown",
3
3
  "type": "library",
4
4
  "description": "PHP Markdown",
5
- "homepage": "http://michelf.ca/projects/php-markdown/",
5
+ "homepage": "https://michelf.ca/projects/php-markdown/",
6
6
  "keywords": ["markdown"],
7
7
  "license": "BSD-3-Clause",
8
8
  "authors": [
9
9
  {
10
10
  "name": "Michel Fortin",
11
11
  "email": "michel.fortin@michelf.ca",
12
- "homepage": "http://michelf.ca/",
12
+ "homepage": "https://michelf.ca/",
13
13
  "role": "Developer"
14
14
  },
15
15
  {
@@ -1,3 +1,9 @@
1
+ * 1.7.0 (2015-01-23)
2
+
3
+ * Dropped PHP 5.3 support
4
+ * Added Ruby 1.9 style attributes support
5
+ * Added new filters (hason)
6
+
1
7
  * 1.6.0 (2014-08-16)
2
8
 
3
9
  * Code statements continue on the next line when the current one is terminated by
@@ -12,7 +12,7 @@
12
12
  }
13
13
  ],
14
14
  "require": {
15
- "php": ">=5.3.0"
15
+ "php": ">=5.4.0"
16
16
  },
17
17
  "require-dev": {
18
18
  "twig/twig": "~1.11",
@@ -21,7 +21,12 @@
21
21
  "leafo/scssphp": "*",
22
22
  "coffeescript/coffeescript": "~1",
23
23
  "michelf/php-markdown": "~1.3",
24
- "erusev/parsedown": "*"
24
+ "erusev/parsedown": "*",
25
+ "league/commonmark": ">=0.5",
26
+ "cebe/markdown": "~1",
27
+ "kzykhys/ciconia": "~1",
28
+ "fluxbb/commonmark": "~1@dev",
29
+ "gregwar/rst": "~1"
25
30
  },
26
31
  "suggest": {
27
32
  "twig/twig": "If you want to use Twig templating engine",
@@ -32,7 +37,10 @@
32
37
  "michelf/php-markdown": "If you want to use :markdown filter",
33
38
  "erusev/parsedown": "If you want to use :markdown filter",
34
39
  "cebe/markdown": "If you want to use :markdown filter",
35
- "kzykhys/ciconia": "If you want to use :markdown filter"
40
+ "kzykhys/ciconia": "If you want to use :markdown filter",
41
+ "league/commonmark": "If you want to use :markdown filter",
42
+ "fluxbb/commonmark": "If you want to use :markdown filter",
43
+ "gregwar/rst": "If you want to use :rest filter"
36
44
  },
37
45
  "conflict": {
38
46
  "mthaml/mthaml-bundle": "<1.1.0"
@@ -2,57 +2,6 @@
2
2
 
3
3
  namespace MtHaml\Filter;
4
4
 
5
- use MtHaml\Node\InterpolatedString;
6
- use MtHaml\NodeVisitor\RendererAbstract as Renderer;
7
- use MtHaml\Node\Filter;
8
- use MtHaml\Node\Text;
9
-
10
- abstract class Markdown extends AbstractFilter
5
+ abstract class Markdown extends OptimizableFilter
11
6
  {
12
- private $forceOptimization;
13
-
14
- public function __construct($forceOptimization = false)
15
- {
16
- $this->forceOptimization = $forceOptimization;
17
- }
18
-
19
- public function isOptimizable(Renderer $renderer, Filter $node, $options)
20
- {
21
- if ($this->forceOptimization) {
22
- return true;
23
- }
24
-
25
- return parent::isOptimizable($renderer, $node, $options);
26
- }
27
-
28
- public function optimize(Renderer $renderer, Filter $node, $options)
29
- {
30
- $inserts = array();
31
- $content = '';
32
- foreach ($node->getChilds() as $child) {
33
- foreach ($child->getContent()->getChilds() as $item) {
34
- if ($item instanceof Text) {
35
- $content .= $item->getContent();
36
- } else {
37
- $hash = md5(mt_rand());
38
- $inserts[$hash] = $item;
39
- $content .= $hash;
40
- }
41
- }
42
- $content .= "\n";
43
- }
44
-
45
- $string = new InterpolatedString(array());
46
- $result = $this->filter($content, array(), array());
47
- foreach ($inserts as $hash => $insert) {
48
- $parts = explode($hash, $result, 2);
49
- $string->addChild(new Text(array(), $parts[0]));
50
- $string->addChild($insert);
51
- $result = $parts[1];
52
- }
53
- $string->addChild(new Text(array(), $result));
54
- $string->accept($renderer);
55
- }
56
-
57
- abstract public function filter($content, array $context, $options);
58
7
  }
@@ -0,0 +1,25 @@
1
+ <?php
2
+
3
+ namespace MtHaml\Filter\Markdown;
4
+
5
+ use League\CommonMark\DocParser;
6
+ use League\CommonMark\HtmlRenderer;
7
+ use MtHaml\Filter\Markdown;
8
+
9
+ class CommonMark extends Markdown
10
+ {
11
+ private $parser;
12
+ private $renderer;
13
+
14
+ public function __construct(DocParser $parser, HtmlRenderer $renderer, $forceOptimization = false)
15
+ {
16
+ parent::__construct($forceOptimization);
17
+ $this->parser = $parser;
18
+ $this->renderer = $renderer;
19
+ }
20
+
21
+ public function filter($content, array $context, $options)
22
+ {
23
+ return $this->renderer->renderBlock($this->parser->parse($content));
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ <?php
2
+
3
+ namespace MtHaml\Filter\Markdown;
4
+
5
+ use FluxBB\CommonMark\DocumentParser;
6
+ use FluxBB\CommonMark\Renderer;
7
+ use MtHaml\Filter\Markdown;
8
+
9
+ class FluxBBMarkdown extends Markdown
10
+ {
11
+ private $parser;
12
+ private $renderer;
13
+
14
+ public function __construct(DocumentParser $parser, Renderer $renderer, $forceOptimization = false)
15
+ {
16
+ parent::__construct($forceOptimization);
17
+ $this->parser = $parser;
18
+ $this->renderer = $renderer;
19
+ }
20
+
21
+ public function filter($content, array $context, $options)
22
+ {
23
+ return $this->renderer->render($this->parser->convert($content));
24
+ }
25
+ }
@@ -0,0 +1,58 @@
1
+ <?php
2
+
3
+ namespace MtHaml\Filter;
4
+
5
+ use MtHaml\Node\InterpolatedString;
6
+ use MtHaml\NodeVisitor\RendererAbstract as Renderer;
7
+ use MtHaml\Node\Filter;
8
+ use MtHaml\Node\Text;
9
+
10
+ abstract class OptimizableFilter extends AbstractFilter
11
+ {
12
+ private $forceOptimization;
13
+
14
+ public function __construct($forceOptimization = false)
15
+ {
16
+ $this->forceOptimization = $forceOptimization;
17
+ }
18
+
19
+ public function isOptimizable(Renderer $renderer, Filter $node, $options)
20
+ {
21
+ if ($this->forceOptimization) {
22
+ return true;
23
+ }
24
+
25
+ return parent::isOptimizable($renderer, $node, $options);
26
+ }
27
+
28
+ public function optimize(Renderer $renderer, Filter $node, $options)
29
+ {
30
+ $inserts = array();
31
+ $content = '';
32
+ foreach ($node->getChilds() as $child) {
33
+ foreach ($child->getContent()->getChilds() as $item) {
34
+ if ($item instanceof Text) {
35
+ $content .= $item->getContent();
36
+ } else {
37
+ $hash = md5(mt_rand());
38
+ $inserts[$hash] = $item;
39
+ $content .= $hash;
40
+ }
41
+ }
42
+ $content .= "\n";
43
+ }
44
+
45
+ $string = new InterpolatedString(array());
46
+ $result = $this->filter($content, array(), array());
47
+ foreach ($inserts as $hash => $insert) {
48
+ $parts = explode($hash, $result, 2);
49
+ $string->addChild(new Text(array(), $parts[0]));
50
+ $string->addChild($insert);
51
+ $result = $parts[1];
52
+ }
53
+ $string->addChild(new Text(array(), $result));
54
+ $string->accept($renderer);
55
+ }
56
+
57
+ abstract public function filter($content, array $context, $options);
58
+ }
@@ -0,0 +1,21 @@
1
+ <?php
2
+
3
+ namespace MtHaml\Filter;
4
+
5
+ use Gregwar\RST\Parser;
6
+
7
+ class ReST extends OptimizableFilter
8
+ {
9
+ private $parser;
10
+
11
+ public function __construct(Parser $parser, $forceOptimization = false)
12
+ {
13
+ parent::__construct($forceOptimization);
14
+ $this->parser = $parser;
15
+ }
16
+
17
+ public function filter($content, array $context, $options)
18
+ {
19
+ return $this->parser->parse($content);
20
+ }
21
+ }
@@ -37,7 +37,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
37
37
  public function parseTestFile($file)
38
38
  {
39
39
  $contents = file_get_contents($file);
40
- $splits = preg_split('#^--(.*)--$#m', $contents, -1, PREG_SPLIT_DELIM_CAPTURE);
40
+ $splits = preg_split('#^--([^-]*)--$#m', $contents, -1, PREG_SPLIT_DELIM_CAPTURE);
41
41
  $parts = array();
42
42
 
43
43
  while (false !== $key = next($splits)) {
@@ -0,0 +1,33 @@
1
+ --FILE--
2
+ <?php
3
+ $cmEnv = League\CommonMark\Environment::createCommonMarkEnvironment();
4
+ $filter = new MtHaml\Filter\Markdown\CommonMark(new League\CommonMark\DocParser($cmEnv), new League\CommonMark\HtmlRenderer($cmEnv));
5
+ $env = new MtHaml\Environment('twig', array('enable_escaper' => false), array('markdown' => $filter));
6
+ echo $env->compileString($parts['HAML'], "$file.haml");
7
+
8
+ --HAML--
9
+ :markdown
10
+ ## Header
11
+
12
+ Foo *c*
13
+
14
+ * list
15
+ :markdown
16
+ ## #{header}
17
+
18
+ Foo *c*
19
+
20
+ * list
21
+ --EXPECT--
22
+ <h2>Header</h2>
23
+ <p>Foo <em>c</em></p>
24
+ <ul>
25
+ <li>list</li>
26
+ </ul>
27
+ {% filter mthaml_markdown %}## {% line 8 %}{{ header }}
28
+
29
+ Foo *c*
30
+
31
+ * list
32
+ {% endfilter %}
33
+
@@ -0,0 +1,32 @@
1
+ --FILE--
2
+ <?php
3
+ $filter = new MtHaml\Filter\Markdown\FluxBBMarkdown(new FluxBB\CommonMark\DocumentParser(), new FluxBB\CommonMark\Renderer());
4
+ $env = new MtHaml\Environment('twig', array('enable_escaper' => false), array('markdown' => $filter));
5
+ echo $env->compileString($parts['HAML'], "$file.haml");
6
+
7
+ --HAML--
8
+ :markdown
9
+ ## Header
10
+
11
+ Foo *c*
12
+
13
+ * list
14
+ :markdown
15
+ ## #{header}
16
+
17
+ Foo *c*
18
+
19
+ * list
20
+ --EXPECT--
21
+ <h2>Header</h2>
22
+ <p>Foo <em>c</em></p>
23
+ <ul>
24
+ <li>list</li>
25
+ </ul>
26
+ {% filter mthaml_markdown %}## {% line 8 %}{{ header }}
27
+
28
+ Foo *c*
29
+
30
+ * list
31
+ {% endfilter %}
32
+
@@ -0,0 +1,42 @@
1
+ --FILE--
2
+ <?php
3
+ $filter = new MtHaml\Filter\ReST(new Gregwar\RST\Parser());
4
+ $env = new MtHaml\Environment('twig', array('enable_escaper' => false), array('rest' => $filter));
5
+ echo $env->compileString($parts['HAML'], "$file.haml");
6
+
7
+ --HAML--
8
+ :rest
9
+ Hello world
10
+ ===========
11
+
12
+ What is it?
13
+ ----------
14
+ This is a **RST** document!
15
+
16
+ * list
17
+ :rest
18
+ #{header}
19
+ =========
20
+
21
+ What is it?
22
+ ----------
23
+ This is a **RST** document!
24
+
25
+ * list
26
+ --EXPECT--
27
+ <a id="title.1"></a><h1>Hello world</h1>
28
+ <a id="title.1.1"></a><h2>What is it?</h2>
29
+ <p>This is a <strong>RST</strong> document!</p>
30
+ <ul><li>list</li>
31
+ </ul>
32
+
33
+ {% filter mthaml_rest %}{% line 11 %}{{ header }}
34
+ =========
35
+
36
+ What is it?
37
+ ----------
38
+ This is a **RST** document!
39
+
40
+ * list
41
+ {% endfilter %}
42
+