redcarpet 3.5.1 → 3.6.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.
@@ -1,232 +0,0 @@
1
- Download
2
- --------
3
-
4
- [Markdown 1.0.1][dl] (18 KB) -- 17 Dec 2004
5
-
6
- [dl]: http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip
7
-
8
-
9
- Introduction
10
- ------------
11
-
12
- Markdown is a text-to-HTML conversion tool for web writers. Markdown
13
- allows you to write using an easy-to-read, easy-to-write plain text
14
- format, then convert it to structurally valid XHTML (or HTML).
15
-
16
- Thus, "Markdown" is two things: (1) a plain text formatting syntax;
17
- and (2) a software tool, written in Perl, that converts the plain text
18
- formatting to HTML. See the [Syntax][] page for details pertaining to
19
- Markdown's formatting syntax. You can try it out, right now, using the
20
- online [Dingus][].
21
-
22
- [syntax]: /projects/markdown/syntax
23
- [dingus]: /projects/markdown/dingus
24
-
25
- The overriding design goal for Markdown's formatting syntax is to make
26
- it as readable as possible. The idea is that a Markdown-formatted
27
- document should be publishable as-is, as plain text, without looking
28
- like it's been marked up with tags or formatting instructions. While
29
- Markdown's syntax has been influenced by several existing text-to-HTML
30
- filters, the single biggest source of inspiration for Markdown's
31
- syntax is the format of plain text email.
32
-
33
- The best way to get a feel for Markdown's formatting syntax is simply
34
- to look at a Markdown-formatted document. For example, you can view
35
- the Markdown source for the article text on this page here:
36
- <http://daringfireball.net/projects/markdown/index.text>
37
-
38
- (You can use this '.text' suffix trick to view the Markdown source for
39
- the content of each of the pages in this section, e.g. the
40
- [Syntax][s_src] and [License][l_src] pages.)
41
-
42
- [s_src]: /projects/markdown/syntax.text
43
- [l_src]: /projects/markdown/license.text
44
-
45
- Markdown is free software, available under a BSD-style open source
46
- license. See the [License] [pl] page for more information.
47
-
48
- [pl]: /projects/markdown/license
49
-
50
-
51
- Discussion List <a id="discussion-list" />
52
- ---------------
53
-
54
- I've set up a public [mailing list for discussion about Markdown] [ml].
55
- Any topic related to Markdown -- both its formatting syntax and
56
- its software -- is fair game for discussion. Anyone who is interested
57
- is welcome to join.
58
-
59
- It's my hope that the mailing list will lead to good ideas for future
60
- improvements to Markdown.
61
-
62
- [ml]: http://six.pairlist.net/mailman/listinfo/markdown-discuss
63
-
64
-
65
- Installation and Requirements <a id="install" />
66
- -----------------------------
67
-
68
- Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century.
69
- Markdown also requires the standard Perl library module [Digest::MD5]
70
- [md5], which is probably already installed on your server.
71
-
72
- [md5]: http://search.cpan.org/dist/Digest-MD5/MD5.pm
73
-
74
-
75
- ### Movable Type ###
76
-
77
- Markdown works with Movable Type version 2.6 or later (including
78
- Movable Type 3.0).
79
-
80
- 1. Copy the "Markdown.pl" file into your Movable Type "plugins"
81
- directory. The "plugins" directory should be in the same directory
82
- as "mt.cgi"; if the "plugins" directory doesn't already exist, use
83
- your FTP program to create it. Your installation should look like
84
- this:
85
-
86
- (mt home)/plugins/Markdown.pl
87
-
88
- 2. Once installed, Markdown will appear as an option in Movable Type's
89
- Text Formatting pop-up menu. This is selectable on a per-post basis:
90
-
91
- ![Screenshot of Movable Type 'Text Formatting' Menu][tfmenu]
92
-
93
- Markdown translates your posts to HTML when you publish; the posts
94
- themselves are stored in your MT database in Markdown format.
95
-
96
- 3. If you also install SmartyPants 1.5 (or later), Markdown will
97
- offer a second text formatting option: "Markdown With
98
- SmartyPants". This option is the same as the regular "Markdown"
99
- formatter, except that it automatically uses SmartyPants to create
100
- typographically correct curly quotes, em-dashes, and ellipses. See
101
- the [SmartyPants web page][sp] for more information.
102
-
103
- 4. To make Markdown (or "Markdown With SmartyPants") your default
104
- text formatting option for new posts, go to Weblog Config:
105
- Preferences.
106
-
107
- Note that by default, Markdown produces XHTML output. To configure
108
- Markdown to produce HTML 4 output, see "Configuration", below.
109
-
110
- [sp]: http://daringfireball.net/projects/smartypants/
111
-
112
-
113
-
114
- ### Blosxom ###
115
-
116
- Markdown works with Blosxom version 2.0 or later.
117
-
118
- 1. Rename the "Markdown.pl" plug-in to "Markdown" (case is
119
- important). Movable Type requires plug-ins to have a ".pl"
120
- extension; Blosxom forbids it.
121
-
122
- 2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder.
123
- If you're not sure where your Blosxom plug-ins folder is, see the
124
- Blosxom documentation for information.
125
-
126
- 3. That's it. The entries in your weblog will now automatically be
127
- processed by Markdown.
128
-
129
- 4. If you'd like to apply Markdown formatting only to certain
130
- posts, rather than all of them, Markdown can optionally be used in
131
- conjunction with Blosxom's [Meta][] plug-in. First, install the
132
- Meta plug-in. Next, open the Markdown plug-in file in a text
133
- editor, and set the configuration variable `$g_blosxom_use_meta`
134
- to 1. Then, simply include a "`meta-markup: Markdown`" header line
135
- at the top of each post you compose using Markdown.
136
-
137
- [meta]: http://www.blosxom.com/plugins/meta/meta.htm
138
-
139
-
140
- ### BBEdit ###
141
-
142
- Markdown works with BBEdit 6.1 or later on Mac OS X. It also works
143
- with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later. If
144
- you're running Mac OS X 10.2 (Jaguar), you may need to install the
145
- Perl module [Digest::MD5] [md5] from CPAN; Digest::MD5 comes
146
- pre-installed on Mac OS X 10.3 (Panther).
147
-
148
- 1. Copy the "Markdown.pl" file to appropriate filters folder in your
149
- "BBEdit Support" folder. On Mac OS X, this should be:
150
-
151
- BBEdit Support/Unix Support/Unix Filters/
152
-
153
- See the BBEdit documentation for more details on the location of
154
- these folders.
155
-
156
- You can rename "Markdown.pl" to whatever you wish.
157
-
158
- 2. That's it. To use Markdown, select some text in a BBEdit document,
159
- then choose Markdown from the Filters sub-menu in the "#!" menu, or
160
- the Filters floating palette
161
-
162
-
163
-
164
- Configuration <a id="configuration"></a>
165
- -------------
166
-
167
- By default, Markdown produces XHTML output for tags with empty elements.
168
- E.g.:
169
-
170
- <br />
171
-
172
- Markdown can be configured to produce HTML-style tags; e.g.:
173
-
174
- <br>
175
-
176
-
177
- ### Movable Type ###
178
-
179
- You need to use a special `MTMarkdownOptions` container tag in each
180
- Movable Type template where you want HTML 4-style output:
181
-
182
- <MTMarkdownOptions output='html4'>
183
- ... put your entry content here ...
184
- </MTMarkdownOptions>
185
-
186
- The easiest way to use MTMarkdownOptions is probably to put the
187
- opening tag right after your `<body>` tag, and the closing tag right
188
- before `</body>`.
189
-
190
- To suppress Markdown processing in a particular template, i.e. to
191
- publish the raw Markdown-formatted text without translation into
192
- (X)HTML, set the `output` attribute to 'raw':
193
-
194
- <MTMarkdownOptions output='raw'>
195
- ... put your entry content here ...
196
- </MTMarkdownOptions>
197
-
198
-
199
- ### Command-Line ###
200
-
201
- Use the `--html4tags` command-line switch to produce HTML output from a
202
- Unix-style command line. E.g.:
203
-
204
- % perl Markdown.pl --html4tags foo.text
205
-
206
- Type `perldoc Markdown.pl`, or read the POD documentation within the
207
- Markdown.pl source code for more information.
208
-
209
-
210
- Acknowledgements <a id="acknowledgements" />
211
- ----------------
212
-
213
- [Aaron Swartz][] deserves a tremendous amount of credit for his feedback on the
214
- design of Markdown's formatting syntax. Markdown is *much* better thanks
215
- to Aaron's ideas, feedback, and testing. Also, Aaron's [html2text][]
216
- is a very handy (and free) utility for turning HTML into
217
- Markdown-formatted plain text.
218
-
219
- [Nathaniel Irons][], [Dan Benjamin][], [Daniel Bogan][], and [Jason Perkins][]
220
- also deserve thanks for their feedback.
221
-
222
- [Michel Fortin][] has ported Markdown to PHP; it's a splendid port, and highly recommended for anyone looking for a PHP implementation of Markdown.
223
-
224
- [Aaron Swartz]: http://www.aaronsw.com/
225
- [Nathaniel Irons]: http://bumppo.net/
226
- [Dan Benjamin]: http://hivelogic.com/
227
- [Daniel Bogan]: http://waferbaby.com/
228
- [Jason Perkins]: http://pressedpants.com/
229
- [Michel Fortin]: http://www.michelf.com/projects/php-markdown/
230
- [html2text]: http://www.aaronsw.com/2002/html2text/
231
-
232
- [tfmenu]: /graphics/markdown/mt_textformat_menu.png
data/test/html5_test.rb DELETED
@@ -1,82 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HTML5Test < Redcarpet::TestCase
4
- def test_that_html5_works
5
- section = <<-HTML.chomp.strip_heredoc
6
- <section>
7
- <p>The quick brown fox jumps over the lazy dog.</p>
8
- </section>
9
- HTML
10
-
11
- figure = <<-HTML.chomp.strip_heredoc
12
- <figure>
13
- <img src="http://example.org/image.jpg" alt="">
14
- <figcaption>
15
- <p>Hello world!</p>
16
- </figcaption>
17
- </figure>
18
- HTML
19
-
20
- assert_renders section, section
21
- assert_renders figure, figure
22
- end
23
-
24
- def test_that_html5_works_with_code_blocks
25
- section = <<-HTML
26
- \t<section>
27
- \t\t<p>The quick brown fox jumps over the lazy dog.</p>
28
- \t</section>
29
- HTML
30
-
31
- section_expected = <<-HTML.chomp.strip_heredoc
32
- <pre><code>&lt;section&gt;
33
- &lt;p&gt;The quick brown fox jumps over the lazy dog.&lt;/p&gt;
34
- &lt;/section&gt;
35
- </code></pre>
36
- HTML
37
-
38
- header = <<-HTML
39
- <header>
40
- <hgroup>
41
- <h1>Section heading</h1>
42
- <h2>Subhead</h2>
43
- </hgroup>
44
- </header>
45
- HTML
46
-
47
- header_expected = <<-HTML.chomp.strip_heredoc
48
- <pre><code>&lt;header&gt;
49
- &lt;hgroup&gt;
50
- &lt;h1&gt;Section heading&lt;/h1&gt;
51
- &lt;h2&gt;Subhead&lt;/h2&gt;
52
- &lt;/hgroup&gt;
53
- &lt;/header&gt;
54
- </code></pre>
55
- HTML
56
-
57
- assert_renders section_expected, section
58
- assert_renders header_expected, header
59
- end
60
-
61
- def test_script_tag_recognition
62
- html = <<-HTML.chomp.strip_heredoc
63
- <script type="text/javascript">
64
- alert('Foo!');
65
- </script>
66
- HTML
67
-
68
- assert_renders html, html
69
- end
70
-
71
- def test_new_html5_tags_not_escaped
72
- details = <<-HTML.chomp.strip_heredoc
73
- <details>
74
- log:
75
-
76
- </details>
77
- HTML
78
-
79
- assert_renders details, details
80
- end
81
-
82
- end
@@ -1,274 +0,0 @@
1
- # coding: UTF-8
2
- require 'test_helper'
3
-
4
- class HTMLRenderTest < Redcarpet::TestCase
5
- def setup
6
- @renderer = Redcarpet::Render::HTML
7
- end
8
-
9
- # Hint: overrides filter_html, no_images and no_links
10
- def test_that_escape_html_works
11
- source = <<-HTML.strip_heredoc
12
- Through <em>NO</em> <script>DOUBLE NO</script>
13
-
14
- <script>BAD</script>
15
-
16
- <img src="/favicon.ico" />
17
- HTML
18
- expected = <<-HTML.chomp.strip_heredoc
19
- <p>Through &lt;em&gt;NO&lt;/em&gt; &lt;script&gt;DOUBLE NO&lt;/script&gt;</p>
20
-
21
- <p>&lt;script&gt;BAD&lt;/script&gt;</p>
22
-
23
- <p>&lt;img src=&quot;/favicon.ico&quot; /&gt;</p>
24
- HTML
25
-
26
- assert_equal expected, render(source, with: [:escape_html])
27
- end
28
-
29
- def test_that_filter_html_works
30
- markdown = 'Through <em>NO</em> <script>DOUBLE NO</script>'
31
- output = render(markdown, with: [:filter_html])
32
-
33
- assert_equal "<p>Through NO DOUBLE NO</p>", output
34
- end
35
-
36
- def test_filter_html_doesnt_break_two_space_hard_break
37
- markdown = "Lorem, \nipsum\n"
38
- output = render(markdown, with: [:filter_html])
39
-
40
- assert_equal "<p>Lorem,<br>\nipsum</p>", output
41
- end
42
-
43
- def test_that_no_image_flag_works
44
- markdown = %(![dust mite](http://dust.mite/image.png) <img src="image.png" />)
45
- output = render(markdown, with: [:no_images])
46
-
47
- assert_no_match %r{<img}, output
48
- end
49
-
50
- def test_that_links_with_ampersands_work
51
- markdown = %([/?a=b&c=d](/?a=b&c=d))
52
- output = render(markdown)
53
- assert_equal "<p><a href=\"/?a=b&c=d\">/?a=b&amp;c=d</a></p>", output
54
- end
55
-
56
- def test_that_no_links_flag_works
57
- markdown = %([This link](http://example.net/) <a href="links.html">links</a>)
58
- output = render(markdown, with: [:no_links])
59
-
60
- assert_no_match %r{<a }, output
61
- end
62
-
63
- def test_that_safelink_flag_works
64
- markdown = "[IRC](irc://chat.freenode.org/#freenode)"
65
- output = render(markdown, with: [:safe_links_only])
66
-
67
- assert_equal "<p>[IRC](irc://chat.freenode.org/#freenode)</p>", output
68
- end
69
-
70
- def test_that_hard_wrap_works
71
- markdown = <<-Markdown.strip_heredoc
72
- Hello world,
73
- this is just a simple test
74
-
75
- With hard wraps
76
- and other *things*.
77
- Markdown
78
- output = render(markdown, with: [:hard_wrap])
79
-
80
- assert_match %r{<br>}, output
81
- end
82
-
83
- def test_that_link_attributes_work
84
- rndr = Redcarpet::Render::HTML.new(:link_attributes => {:rel => 'blank'})
85
- md = Redcarpet::Markdown.new(rndr)
86
- assert md.render('This is a [simple](http://test.com) test.').include?('rel="blank"')
87
- end
88
-
89
- def test_that_link_works_with_quotes
90
- markdown = %([This'link"is](http://example.net/))
91
- expected = %(<p><a href="http://example.net/">This&#39;link&quot;is</a></p>)
92
-
93
- assert_equal expected, render(markdown)
94
- assert_equal expected, render(markdown, with: [:escape_html])
95
- end
96
-
97
- def test_that_code_emphasis_work
98
- markdown = <<-Markdown.strip_heredoc
99
- This should be **`a bold codespan`**
100
- However, this should be *`an emphasised codespan`*
101
-
102
- * **`ABC`** or **`DEF`**
103
- * Foo bar
104
- Markdown
105
-
106
- html = <<-HTML.chomp.strip_heredoc
107
- <p>This should be <strong><code>a bold codespan</code></strong>
108
- However, this should be <em><code>an emphasised codespan</code></em></p>
109
-
110
- <ul>
111
- <li><strong><code>ABC</code></strong> or <strong><code>DEF</code></strong></li>
112
- <li>Foo bar</li>
113
- </ul>
114
- HTML
115
-
116
- assert_equal html, render(markdown)
117
- end
118
-
119
- def test_that_parenthesis_are_handled_into_links
120
- markdown = %(The [bash man page](man:bash(1))!)
121
- expected = %(<p>The <a href="man:bash(1)">bash man page</a>!</p>)
122
-
123
- assert_equal expected, render(markdown)
124
- end
125
-
126
- def test_autolinking_works_as_expected
127
- markdown = "Uri ftp://user:pass@example.com/. Email foo@bar.com and link http://bar.com"
128
- output = render(markdown, with: [:autolink])
129
-
130
- assert output.include? '<a href="ftp://user:pass@example.com/">ftp://user:pass@example.com/</a>'
131
- assert output.include? 'mailto:foo@bar.com'
132
- assert output.include? '<a href="http://bar.com">'
133
- end
134
-
135
- def test_that_footnotes_work
136
- markdown = <<-Markdown.strip_heredoc
137
- This is a footnote.[^1]
138
-
139
- [^1]: It provides additional information.
140
- Markdown
141
-
142
- html = <<-HTML.chomp.strip_heredoc
143
- <p>This is a footnote.<sup id="fnref1"><a href="#fn1">1</a></sup></p>
144
-
145
- <div class="footnotes">
146
- <hr>
147
- <ol>
148
-
149
- <li id="fn1">
150
- <p>It provides additional information.&nbsp;<a href="#fnref1">&#8617;</a></p>
151
- </li>
152
-
153
- </ol>
154
- </div>
155
- HTML
156
-
157
- output = render(markdown, with: [:footnotes])
158
- assert_equal html, output
159
- end
160
-
161
- def test_footnotes_enabled_but_missing_marker
162
- markdown = <<-Markdown.strip_heredoc
163
- Some text without a marker
164
-
165
- [^1] And a trailing definition
166
- Markdown
167
- html = <<-HTML.chomp.strip_heredoc
168
- <p>Some text without a marker</p>
169
-
170
- <p>[^1] And a trailing definition</p>
171
- HTML
172
-
173
- output = render(markdown, with: [:footnotes])
174
- assert_equal html, output
175
- end
176
-
177
- def test_footnotes_enabled_but_missing_definition
178
- markdown = "Some text with a marker[^1] but no definition."
179
- expected = "<p>Some text with a marker[^1] but no definition.</p>"
180
-
181
- output = render(markdown, with: [:footnotes])
182
- assert_equal expected, output
183
- end
184
-
185
- def test_autolink_short_domains
186
- markdown = "Example of uri ftp://auto/short/domains. Email auto@l.n and link http://a/u/t/o/s/h/o/r/t"
187
- output = render(markdown, with: [:autolink])
188
-
189
- assert output.include? '<a href="ftp://auto/short/domains">ftp://auto/short/domains</a>'
190
- assert output.include? 'mailto:auto@l.n'
191
- assert output.include? '<a href="http://a/u/t/o/s/h/o/r/t">http://a/u/t/o/s/h/o/r/t</a>'
192
- end
193
-
194
- def test_that_prettify_works
195
- markdown = "\tclass Foo\nend"
196
- output = render(markdown, with: [:prettify])
197
-
198
- assert output.include?("<pre><code class=\"prettyprint\">")
199
-
200
- markdown = "`class`"
201
- output = render(markdown, with: [:prettify])
202
-
203
- assert output.include?("<code class=\"prettyprint\">")
204
- end
205
-
206
- def test_prettify_with_fenced_code_blocks
207
- markdown = "~~~ruby\ncode\n~~~"
208
- output = render(markdown, with: [:fenced_code_blocks, :prettify])
209
-
210
- assert output.include?("<code class=\"prettyprint lang-ruby\">")
211
- end
212
-
213
- def test_safe_links_only_with_anchors
214
- markdown = "An [anchor link](#anchor) on a page."
215
- output = render(markdown, with: [:safe_links_only])
216
-
217
- assert_match %r{<a href="#anchor">anchor link</a>}, output
218
- end
219
-
220
- def test_autolink_with_link_attributes
221
- options = { autolink: true, link_attributes: {rel: "nofollow"} }
222
- output = render("https://github.com/", with: options)
223
-
224
- assert_match %r{rel="nofollow"}, output
225
- end
226
-
227
- def test_image_unsafe_src_with_safe_links_only
228
- markdown = "![foo](javascript:while(1);)"
229
- output = render(markdown, with: [:safe_links_only])
230
-
231
- assert_not_match %r{img src}, output
232
- end
233
-
234
- def test_no_styles_option_inside_a_paragraph
235
- markdown = "Hello <style> foo { bar: baz; } </style> !"
236
- output = render(markdown, with: [:no_styles])
237
-
238
- assert_no_match %r{<style>}, output
239
- end
240
-
241
- def test_no_styles_inside_html_block_rendering
242
- markdown = "<style> foo { bar: baz; } </style>"
243
- output = render(markdown, with: [:no_styles])
244
-
245
- assert_no_match %r{<style>}, output
246
- end
247
-
248
- def test_non_ascii_removal_in_header_anchors
249
- markdown = "# Glühlampe"
250
- html = "<h1 id=\"gl-hlampe\">Glühlampe</h1>"
251
-
252
- assert_equal html, render(markdown, with: [:with_toc_data])
253
- end
254
-
255
- def test_utf8_only_header_anchors
256
- markdown = "# 見出し"
257
- if 1.size == 4 # 32-bit architecture
258
- html = "<h1 id=\"part-a194139f\">見出し</h1>"
259
- elsif 1.size == 8 # 64-bit architecture
260
- html = "<h1 id=\"part-37870bfa194139f\">見出し</h1>"
261
- else
262
- raise "unknown integer size"
263
- end
264
-
265
- assert_equal html, render(markdown, with: [:with_toc_data])
266
- end
267
-
268
- def test_escape_entities_removal_from_anchor
269
- output = render("# Foo's & Bar's", with: [:with_toc_data])
270
- result = %(<h1 id="foos-bars">Foo&#39;s &amp; Bar&#39;s</h1>)
271
-
272
- assert_equal result, output
273
- end
274
- end
@@ -1,112 +0,0 @@
1
- # coding: UTF-8
2
- require 'test_helper'
3
-
4
- class HTMLTOCRenderTest < Redcarpet::TestCase
5
- def setup
6
- @renderer = Redcarpet::Render::HTML_TOC
7
- @markdown = <<-Markdown.strip_heredoc
8
- # A title
9
- ## A __nice__ subtitle
10
- ## Another one
11
- ### A sub-sub-title
12
- ### 見出し
13
- Markdown
14
- end
15
-
16
- def test_simple_toc_render
17
- output = render(@markdown)
18
-
19
- assert output.start_with?("<ul>")
20
- assert output.end_with?("</ul>")
21
-
22
- assert_equal 3, output.scan("<ul>").length
23
- assert_equal 5, output.scan("<li>").length
24
- end
25
-
26
- def test_granular_toc_render
27
- output = render(@markdown, with: { nesting_level: 2 })
28
-
29
- assert output.start_with?("<ul>")
30
- assert output.end_with?("</ul>")
31
-
32
- assert_equal 3, output.scan("<li>").length
33
- assert !output.include?("A sub-sub title")
34
- end
35
-
36
- def test_granular_toc_render_with_range
37
- output = render(@markdown, with: { nesting_level: 2..5 }).strip
38
-
39
- assert output.start_with?("<ul>")
40
- assert output.end_with?("</ul>")
41
-
42
- assert output.match("Another one")
43
- assert output.match("A sub-sub-title")
44
- assert output.match("見出し")
45
-
46
- refute output.match("A title")
47
- refute output.match("A really tiny title")
48
- end
49
-
50
- def test_toc_heading_id
51
- output = render(@markdown)
52
-
53
- assert_match /a-title/, output
54
- assert_match /a-nice-subtitle/, output
55
- assert_match /another-one/, output
56
- assert_match /a-sub-sub-title/, output
57
- # the part number length varies depending on architecture (32b or 64b)
58
- assert_match /part-(37870bf)?a194139f/, output
59
- end
60
-
61
- def test_toc_heading_with_hyphen_and_equal
62
- output = render("# Hello World\n\n-\n\n=")
63
-
64
- assert_equal 1, output.scan("<li>").length
65
- assert !output.include?('<a href=\"#\"></a>')
66
- end
67
-
68
- def test_anchor_generation_with_edge_cases
69
- # Imported from ActiveSupport::Inflector#parameterize's tests
70
- titles = {
71
- "Donald E. Knuth" => "donald-e-knuth",
72
- "Random text with *(bad)* characters" => "random-text-with-bad-characters",
73
- "!@#Surrounding bad characters!@#" => "surrounding-bad-characters",
74
- "Squeeze separators" => "squeeze-separators",
75
- "Test with + sign" => "test-with-sign",
76
- "Test with a Namespaced::Class" => "test-with-a-namespaced-class"
77
- }
78
-
79
- titles.each do |title, anchor|
80
- assert_match %("##{anchor}"), render("# #{title}")
81
- end
82
- end
83
-
84
- def test_inline_markup_is_not_escaped
85
- output = render(@markdown)
86
-
87
- assert_match "A <strong>nice</strong> subtitle", output
88
- assert_no_match %r{&lt;}, output
89
- end
90
-
91
- def test_inline_markup_escaping
92
- output = render(@markdown, with: [:escape_html])
93
-
94
- assert_match "&lt;strong&gt;", output
95
- assert_no_match %r{<strong>}, output
96
- end
97
-
98
- def test_ignoring_fenced_code_blocks_comments
99
- markdown = <<-Markdown.strip_heredoc
100
- # Hello world !
101
-
102
- ~~~ruby
103
- # This is a comment
104
- ~~~
105
- Markdown
106
-
107
- output = render(markdown)
108
-
109
- assert output.match("Hello world")
110
- refute output.match("This is a comment")
111
- end
112
- end