greenmat 3.2.0.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 (44) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +14 -0
  3. data/Gemfile +9 -0
  4. data/README.md +36 -0
  5. data/Rakefile +62 -0
  6. data/bin/greenmat +7 -0
  7. data/ext/greenmat/autolink.c +296 -0
  8. data/ext/greenmat/autolink.h +49 -0
  9. data/ext/greenmat/buffer.c +196 -0
  10. data/ext/greenmat/buffer.h +83 -0
  11. data/ext/greenmat/extconf.rb +6 -0
  12. data/ext/greenmat/gm_markdown.c +161 -0
  13. data/ext/greenmat/gm_render.c +534 -0
  14. data/ext/greenmat/greenmat.h +30 -0
  15. data/ext/greenmat/houdini.h +29 -0
  16. data/ext/greenmat/houdini_href_e.c +108 -0
  17. data/ext/greenmat/houdini_html_e.c +83 -0
  18. data/ext/greenmat/html.c +826 -0
  19. data/ext/greenmat/html.h +84 -0
  20. data/ext/greenmat/html_blocks.h +229 -0
  21. data/ext/greenmat/html_smartypants.c +445 -0
  22. data/ext/greenmat/markdown.c +2912 -0
  23. data/ext/greenmat/markdown.h +138 -0
  24. data/ext/greenmat/stack.c +62 -0
  25. data/ext/greenmat/stack.h +26 -0
  26. data/greenmat.gemspec +72 -0
  27. data/lib/greenmat.rb +92 -0
  28. data/lib/greenmat/compat.rb +73 -0
  29. data/lib/greenmat/render_man.rb +65 -0
  30. data/lib/greenmat/render_strip.rb +48 -0
  31. data/test/benchmark.rb +24 -0
  32. data/test/custom_render_test.rb +28 -0
  33. data/test/greenmat_compat_test.rb +38 -0
  34. data/test/html5_test.rb +69 -0
  35. data/test/html_render_test.rb +241 -0
  36. data/test/html_toc_render_test.rb +76 -0
  37. data/test/markdown_test.rb +337 -0
  38. data/test/pathological_inputs_test.rb +34 -0
  39. data/test/safe_render_test.rb +36 -0
  40. data/test/smarty_html_test.rb +45 -0
  41. data/test/smarty_pants_test.rb +48 -0
  42. data/test/stripdown_render_test.rb +40 -0
  43. data/test/test_helper.rb +33 -0
  44. metadata +158 -0
@@ -0,0 +1,45 @@
1
+ # coding: UTF-8
2
+ require 'test_helper'
3
+
4
+ class SmartyHTMLTest < Greenmat::TestCase
5
+ def setup
6
+ @smarty_markdown = Greenmat::Markdown.new(Greenmat::Render::SmartyHTML)
7
+ end
8
+
9
+ def test_that_smartyhtml_converts_single_quotes
10
+ markdown = @smarty_markdown.render("They're not for sale.")
11
+ assert_equal "<p>They&rsquo;re not for sale.</p>\n", markdown
12
+ end
13
+
14
+ def test_that_smartyhtml_converts_double_quotes
15
+ rd = @smarty_markdown.render(%("Quoted text"))
16
+ assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>\n), rd
17
+ end
18
+
19
+ def test_that_smartyhtml_converts_double_hyphen
20
+ rd = @smarty_markdown.render("double hyphen -- ndash")
21
+ assert_equal "<p>double hyphen &ndash; ndash</p>\n", rd
22
+ end
23
+
24
+ def test_that_smartyhtml_converts_triple_hyphen
25
+ rd = @smarty_markdown.render("triple hyphen --- mdash")
26
+ assert_equal "<p>triple hyphen &mdash; mdash</p>\n", rd
27
+ end
28
+
29
+ def test_that_smartyhtml_ignores_double_hyphen_in_code
30
+ rd = @smarty_markdown.render("double hyphen in `--option`")
31
+ assert_equal "<p>double hyphen in <code>--option</code></p>\n", rd
32
+ end
33
+
34
+ def test_that_smartyhtml_ignores_pre
35
+ rd = @smarty_markdown.render(" It's a test of \"pre\"\n")
36
+ expected = "It&#39;s a test of &quot;pre&quot;"
37
+ assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
38
+ end
39
+
40
+ def test_that_smartyhtml_ignores_code
41
+ rd = @smarty_markdown.render("`It's a test of \"code\"`\n")
42
+ expected = "It&#39;s a test of &quot;code&quot;"
43
+ assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
44
+ end
45
+ end
@@ -0,0 +1,48 @@
1
+ # coding: UTF-8
2
+ require 'test_helper'
3
+
4
+ class SmartyPantsTest < Greenmat::TestCase
5
+ def setup
6
+ @pants = Greenmat::Render::SmartyPants
7
+ end
8
+
9
+ def test_that_smart_converts_single_quotes_in_words_that_end_in_re
10
+ markdown = @pants.render("<p>They're not for sale.</p>")
11
+ assert_equal "<p>They&rsquo;re not for sale.</p>", markdown
12
+ end
13
+
14
+ def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
15
+ markdown = @pants.render("<p>Well that'll be the day</p>")
16
+ assert_equal "<p>Well that&rsquo;ll be the day</p>", markdown
17
+ end
18
+
19
+ def test_that_smart_converts_double_quotes_to_curly_quotes
20
+ rd = @pants.render(%(<p>"Quoted text"</p>))
21
+ assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>), rd
22
+ end
23
+
24
+ def test_that_smart_gives_ve_suffix_a_rsquo
25
+ rd = @pants.render("<p>I've been meaning to tell you ..</p>")
26
+ assert_equal "<p>I&rsquo;ve been meaning to tell you ..</p>", rd
27
+ end
28
+
29
+ def test_that_smart_gives_m_suffix_a_rsquo
30
+ rd = @pants.render("<p>I'm not kidding</p>")
31
+ assert_equal "<p>I&rsquo;m not kidding</p>", rd
32
+ end
33
+
34
+ def test_that_smart_gives_d_suffix_a_rsquo
35
+ rd = @pants.render("<p>what'd you say?</p>")
36
+ assert_equal "<p>what&rsquo;d you say?</p>", rd
37
+ end
38
+
39
+ def test_that_backticks_are_preserved
40
+ rd = @pants.render("<p>single `backticks` in HTML should be preserved</p>")
41
+ assert_equal "<p>single `backticks` in HTML should be preserved</p>", rd
42
+ end
43
+
44
+ def test_that_smart_converts_trailing_single_quotes_to_curly_quotes
45
+ rd = @pants.render("<p>Hopin' that this bug gets some fixin'.</p>")
46
+ assert_equal "<p>Hopin&rsquo; that this bug gets some fixin&rsquo;.</p>", rd
47
+ end
48
+ end
@@ -0,0 +1,40 @@
1
+ # coding: UTF-8
2
+ require 'test_helper'
3
+
4
+ class StripDownRender < Greenmat::TestCase
5
+ def setup
6
+ @parser = Greenmat::Markdown.new(Greenmat::Render::StripDown)
7
+ end
8
+
9
+ def test_titles
10
+ markdown = "# Foo bar"
11
+ output = @parser.render(markdown)
12
+
13
+ assert_equal "Foo bar\n", output
14
+ end
15
+
16
+ def test_code_blocks
17
+ markdown = "\tclass Foo\n\tend"
18
+ output = @parser.render(markdown)
19
+
20
+ assert_equal "class Foo\nend\n", output
21
+ end
22
+
23
+ def test_images
24
+ markdown = "Look at this ![picture](http://example.org/picture.png)\n" \
25
+ "And this: ![](http://example.org/image.jpg)"
26
+ expected = "Look at this picture http://example.org/picture.png\n" \
27
+ "And this: http://example.org/image.jpg\n"
28
+ output = @parser.render(markdown)
29
+
30
+ assert_equal expected, output
31
+ end
32
+
33
+ def test_links
34
+ markdown = "Here's an [example](https://github.com)"
35
+ expected = "Here's an example (https://github.com)\n"
36
+ output = @parser.render(markdown)
37
+
38
+ assert_equal expected, output
39
+ end
40
+ end
@@ -0,0 +1,33 @@
1
+ # coding: UTF-8
2
+ Encoding.default_internal = 'UTF-8' if defined? Encoding
3
+
4
+ require 'test/unit'
5
+
6
+ require 'greenmat'
7
+ require 'greenmat/render_strip'
8
+ require 'greenmat/render_man'
9
+
10
+ class Greenmat::TestCase < Test::Unit::TestCase
11
+ def assert_renders(html, markdown)
12
+ assert_equal html, render(markdown)
13
+ end
14
+
15
+ def render(markdown, options = {})
16
+ options = options.fetch(:with, {})
17
+
18
+ if options.kind_of?(Array)
19
+ options = Hash[options.map {|o| [o, true]}]
20
+ end
21
+
22
+ render = renderer.new(options)
23
+ parser = Greenmat::Markdown.new(render, options)
24
+
25
+ parser.render(markdown)
26
+ end
27
+
28
+ private
29
+
30
+ def renderer
31
+ @renderer ||= Greenmat::Render::HTML
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: greenmat
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Natacha Porté
8
+ - Vicent Martí
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-03-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake-compiler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.8.3
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.8.3
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.2'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.2'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rubygems-xcodeproj_generator
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.1'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.1'
56
+ - !ruby/object:Gem::Dependency
57
+ name: test-unit
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 3.0.9
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 3.0.9
70
+ description: A Markdown parser for Qiita, based on Redcarpet.
71
+ email: nkymyj@gmail.com
72
+ executables:
73
+ - greenmat
74
+ extensions:
75
+ - ext/greenmat/extconf.rb
76
+ extra_rdoc_files:
77
+ - COPYING
78
+ files:
79
+ - COPYING
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/greenmat
84
+ - ext/greenmat/autolink.c
85
+ - ext/greenmat/autolink.h
86
+ - ext/greenmat/buffer.c
87
+ - ext/greenmat/buffer.h
88
+ - ext/greenmat/extconf.rb
89
+ - ext/greenmat/gm_markdown.c
90
+ - ext/greenmat/gm_render.c
91
+ - ext/greenmat/greenmat.h
92
+ - ext/greenmat/houdini.h
93
+ - ext/greenmat/houdini_href_e.c
94
+ - ext/greenmat/houdini_html_e.c
95
+ - ext/greenmat/html.c
96
+ - ext/greenmat/html.h
97
+ - ext/greenmat/html_blocks.h
98
+ - ext/greenmat/html_smartypants.c
99
+ - ext/greenmat/markdown.c
100
+ - ext/greenmat/markdown.h
101
+ - ext/greenmat/stack.c
102
+ - ext/greenmat/stack.h
103
+ - greenmat.gemspec
104
+ - lib/greenmat.rb
105
+ - lib/greenmat/compat.rb
106
+ - lib/greenmat/render_man.rb
107
+ - lib/greenmat/render_strip.rb
108
+ - test/benchmark.rb
109
+ - test/custom_render_test.rb
110
+ - test/greenmat_compat_test.rb
111
+ - test/html5_test.rb
112
+ - test/html_render_test.rb
113
+ - test/html_toc_render_test.rb
114
+ - test/markdown_test.rb
115
+ - test/pathological_inputs_test.rb
116
+ - test/safe_render_test.rb
117
+ - test/smarty_html_test.rb
118
+ - test/smarty_pants_test.rb
119
+ - test/stripdown_render_test.rb
120
+ - test/test_helper.rb
121
+ homepage: https://github.com/increments/greenmat
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 2.0.0
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.4.6
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: A Markdown parser for Qiita, based on Redcarpet.
145
+ test_files:
146
+ - test/benchmark.rb
147
+ - test/custom_render_test.rb
148
+ - test/greenmat_compat_test.rb
149
+ - test/html5_test.rb
150
+ - test/html_render_test.rb
151
+ - test/html_toc_render_test.rb
152
+ - test/markdown_test.rb
153
+ - test/pathological_inputs_test.rb
154
+ - test/safe_render_test.rb
155
+ - test/smarty_html_test.rb
156
+ - test/smarty_pants_test.rb
157
+ - test/stripdown_render_test.rb
158
+ - test/test_helper.rb