├── test ├── MarkdownTest_1.0.3 │ ├── Tests │ │ ├── Nested blockquotes.text │ │ ├── Tidyness.text │ │ ├── Strong and em together.text │ │ ├── Literal quotes in titles.text │ │ ├── Nested blockquotes.html │ │ ├── Tidyness.html │ │ ├── Code Spans.text │ │ ├── Literal quotes in titles.html │ │ ├── Blockquotes with code blocks.text │ │ ├── Inline HTML (Advanced).text │ │ ├── Inline HTML comments.text │ │ ├── Code Spans.html │ │ ├── Inline HTML (Advanced).html │ │ ├── Strong and em together.html │ │ ├── Hard-wrapped paragraphs with list-like lines.text │ │ ├── Code Blocks.text │ │ ├── Inline HTML comments.html │ │ ├── Hard-wrapped paragraphs with list-like lines.html │ │ ├── Blockquotes with code blocks.html │ │ ├── Links, inline style.text │ │ ├── Links, shortcut references.html │ │ ├── Auto links.text │ │ ├── Links, shortcut references.text │ │ ├── Code Blocks.html │ │ ├── Tabs.text │ │ ├── Links, inline style.html │ │ ├── Amps and angle encoding.text │ │ ├── Tabs.html │ │ ├── Amps and angle encoding.html │ │ ├── Horizontal rules.text │ │ ├── Auto links.html │ │ ├── Horizontal rules.html │ │ ├── Inline HTML (Simple).text │ │ ├── Inline HTML (Simple).html │ │ ├── Links, reference style.text │ │ ├── Links, reference style.html │ │ ├── Ordered and unordered lists.text │ │ ├── Backslash escapes.text │ │ ├── Backslash escapes.html │ │ ├── Ordered and unordered lists.html │ │ ├── Markdown Documentation - Basics.text │ │ └── Markdown Documentation - Basics.html │ └── MarkdownTest.pl ├── MarkdownTest_1.0 │ ├── Tests │ │ ├── Nested blockquotes.text │ │ ├── Tidyness.text │ │ ├── Literal quotes in titles.text │ │ ├── Strong and em together.text │ │ ├── Nested blockquotes.html │ │ ├── Tidyness.html │ │ ├── Literal quotes in titles.html │ │ ├── Blockquotes with code blocks.text │ │ ├── Inline HTML (Advanced).text │ │ ├── Links, inline style.text │ │ ├── Inline HTML (Advanced).html │ │ ├── Inline HTML comments.text │ │ ├── Strong and em together.html │ │ ├── Hard-wrapped paragraphs with list-like lines.text │ │ ├── Inline HTML comments.html │ │ ├── Blockquotes with code blocks.html │ │ ├── Hard-wrapped paragraphs with list-like lines.html │ │ ├── Auto links.text │ │ ├── Links, inline style.html │ │ ├── Tabs.text │ │ ├── Links, reference style.text │ │ ├── Amps and angle encoding.text │ │ ├── Links, reference style.html │ │ ├── Tabs.html │ │ ├── Amps and angle encoding.html │ │ ├── Horizontal rules.text │ │ ├── Auto links.html │ │ ├── Horizontal rules.html │ │ ├── Inline HTML (Simple).text │ │ ├── Inline HTML (Simple).html │ │ ├── Backslash escapes.text │ │ ├── Ordered and unordered lists.text │ │ ├── Backslash escapes.html │ │ ├── Ordered and unordered lists.html │ │ ├── Markdown Documentation - Basics.text │ │ └── Markdown Documentation - Basics.html │ └── MarkdownTest.pl ├── benchmark.rb ├── custom_render_test.rb ├── pathological_inputs_test.rb ├── test_helper.rb ├── safe_render_test.rb ├── redcarpet_compat_test.rb ├── smarty_html_test.rb ├── html5_test.rb ├── stripdown_render_test.rb ├── redcarpet_bin_test.rb ├── smarty_pants_test.rb ├── html_toc_render_test.rb ├── html_render_test.rb └── fixtures │ └── benchmark.md ├── .gitignore ├── ext └── redcarpet │ ├── extconf.rb │ ├── stack.h │ ├── redcarpet.h │ ├── autolink.h │ ├── houdini.h │ ├── stack.c │ ├── html.h │ ├── buffer.h │ ├── houdini_html_e.c │ ├── houdini_href_e.c │ ├── buffer.c │ ├── rc_markdown.c │ ├── markdown.h │ ├── autolink.c │ └── html_blocks.h ├── bin └── redcarpet ├── Gemfile ├── .travis.yml ├── COPYING ├── lib ├── redcarpet │ ├── render_man.rb │ ├── render_strip.rb │ ├── compat.rb │ └── cli.rb └── redcarpet.rb ├── CONTRIBUTING.md ├── Rakefile ├── redcarpet.gemspec └── CHANGELOG.md /test/MarkdownTest_1.0.3/Tests/Nested blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Nested blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.bundle 2 | *.o 3 | *.so 4 | *.swp 5 | /ext/redcarpet/Makefile 6 | /tmp 7 | Gemfile.lock 8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /ext/redcarpet/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | $CFLAGS << ' -fvisibility=hidden' 4 | 5 | dir_config('redcarpet') 6 | create_makefile('redcarpet') 7 | -------------------------------------------------------------------------------- /bin/redcarpet: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | lib_path = File.expand_path('../../lib', __FILE__) 3 | $:.unshift(lib_path) 4 | 5 | require 'redcarpet/cli' 6 | 7 | Redcarpet::CLI.process(ARGV) 8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Strong and em together.text: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Literal quotes in titles.text: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Strong and em together.text: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Nested blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Nested blockquotes.html: -------------------------------------------------------------------------------- 1 |foo
3 | 4 |5 |7 | 8 |bar
6 |foo
9 |
2 |10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Tidyness.html: -------------------------------------------------------------------------------- 1 |foo
3 | 4 |5 |7 | 8 |bar
6 |foo
9 |
2 |9 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Tidyness.html: -------------------------------------------------------------------------------- 1 |A list within a blockquote:
3 |4 |
8 |- asterisk 1
5 |- asterisk 2
6 |- asterisk 3
7 |
2 |9 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org/" 2 | 3 | gemspec 4 | 5 | group :benchmark do 6 | gem "benchmark-ips", "~> 2.3.0" 7 | gem "bluecloth", "~> 2.2.0" 8 | gem "kramdown", "~> 1.8.0" 9 | end 10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Literal quotes in titles.html: -------------------------------------------------------------------------------- 1 |A list within a blockquote:
3 |4 |
8 |- asterisk 1
5 |- asterisk 2
6 |- asterisk 3
7 |
Foo bar.
2 | 3 |Foo bar.
4 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Code Spans.text: -------------------------------------------------------------------------------- 1 | `Foo bar.
2 | 3 |Foo bar.
4 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.text: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).text: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |Simple block on one line:
2 | 3 |And nested without indentation:
6 | 7 |<test a=" content of attribute ">
Fix for backticks within HTML tag: like this
4 | 5 |Here's how you put `backticks` in a code span.
Simple block on one line:
2 | 3 |And nested without indentation:
6 | 7 |This is strong and em.
2 | 3 |So is this word.
4 | 5 |This is strong and em.
6 | 7 |So is this word.
8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Strong and em together.html: -------------------------------------------------------------------------------- 1 |This is strong and em.
2 | 3 |So is this word.
4 | 5 |This is strong and em.
6 | 7 |So is this word.
8 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Inline HTML comments.html: -------------------------------------------------------------------------------- 1 |Paragraph one.
2 | 3 | 4 | 5 | 8 | 9 |Paragraph two.
10 | 11 | 12 | 13 |The end.
14 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Code Blocks.text: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Inline HTML comments.html: -------------------------------------------------------------------------------- 1 |Paragraph one.
2 | 3 | 4 | 5 | 8 | 9 |Paragraph two.
10 | 11 | 12 | 13 |The end.
14 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html: -------------------------------------------------------------------------------- 1 |In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.
6 | 7 |Here's one with a bullet. 8 | * criminey.
9 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.html: -------------------------------------------------------------------------------- 1 |2 |16 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.html: -------------------------------------------------------------------------------- 1 |Example:
3 | 4 |8 | 9 |sub status { 5 | print "working"; 6 | } 7 |Or:
10 | 11 |15 |sub status { 12 | return "working"; 13 | } 14 |
In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.
6 | 7 |Here's one with a bullet. 8 | * criminey.
9 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html: -------------------------------------------------------------------------------- 1 |2 |16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | addons: 4 | apt: 5 | packages: 6 | - tidy 7 | 8 | install: travis_retry bundle install --without=benchmark 9 | 10 | rvm: 11 | - 1.9.2 12 | - 1.9.3 13 | - 2.0.0 14 | - 2.1 15 | - 2.2 16 | - rbx-2 17 | - ruby-head 18 | 19 | notifications: 20 | email: false 21 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Links, inline style.text: -------------------------------------------------------------------------------- 1 | Just a [URL](/url/). 2 | 3 | [URL and title](/url/ "title"). 4 | 5 | [URL and title](/url/ "title preceded by two spaces"). 6 | 7 | [URL and title](/url/ "title preceded by a tab"). 8 | 9 | [URL and title](/url/ "title has spaces afterward" ). 10 | 11 | 12 | [Empty](). 13 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Links, shortcut references.html: -------------------------------------------------------------------------------- 1 |Example:
3 | 4 |8 | 9 |sub status { 5 | print "working"; 6 | } 7 |Or:
10 | 11 |15 |sub status { 12 | return "working"; 13 | } 14 |
This is the simple case.
2 | 3 |This one has a line 4 | break.
5 | 6 |This one has a line 7 | break with a line-ending space.
8 | 9 | 10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Auto links.text: -------------------------------------------------------------------------------- 1 | Link:Just a URL.
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Links, shortcut references.text: -------------------------------------------------------------------------------- 1 | This is the [simple case]. 2 | 3 | [simple case]: /simple 4 | 5 | 6 | 7 | This one has a [line 8 | break]. 9 | 10 | This one has a [line 11 | break] with a line-ending space. 12 | 13 | [line break]: /foo 14 | 15 | 16 | [this] [that] and the [other] 17 | 18 | [this]: /this 19 | [that]: /that 20 | [other]: /other 21 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Code Blocks.html: -------------------------------------------------------------------------------- 1 |code block on the first line
2 |
3 |
4 | Regular text.
5 | 6 |code block indented by spaces
7 |
8 |
9 | Regular text.
10 | 11 |the lines in this block
12 | all contain trailing spaces
13 |
14 |
15 | Regular Text.
16 | 17 |code block on the last line
18 |
19 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0.3/Tests/Tabs.text:
--------------------------------------------------------------------------------
1 | + this is a list item
2 | indented with tabs
3 |
4 | + this is a list item
5 | indented with spaces
6 |
7 | Code:
8 |
9 | this code block is indented by one tab
10 |
11 | And:
12 |
13 | this code block is indented by two tabs
14 |
15 | And:
16 |
17 | + this is an example list item
18 | indented with tabs
19 |
20 | + this is an example list item
21 | indented with spaces
22 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0/Tests/Tabs.text:
--------------------------------------------------------------------------------
1 | + this is a list item
2 | indented with tabs
3 |
4 | + this is a list item
5 | indented with spaces
6 |
7 | Code:
8 |
9 | this code block is indented by one tab
10 |
11 | And:
12 |
13 | this code block is indented by two tabs
14 |
15 | And:
16 |
17 | + this is an example list item
18 | indented with tabs
19 |
20 | + this is an example list item
21 | indented with spaces
22 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0.3/Tests/Links, inline style.html:
--------------------------------------------------------------------------------
1 | Just a URL.
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Links, reference style.text: -------------------------------------------------------------------------------- 1 | Foo [bar] [1]. 2 | 3 | Foo [bar][1]. 4 | 5 | Foo [bar] 6 | [1]. 7 | 8 | [1]: /url/ "Title" 9 | 10 | 11 | With [embedded [brackets]] [b]. 12 | 13 | 14 | Indented [once][]. 15 | 16 | Indented [twice][]. 17 | 18 | Indented [thrice][]. 19 | 20 | Indented [four][] times. 21 | 22 | [once]: /url 23 | 24 | [twice]: /url 25 | 26 | [thrice]: /url 27 | 28 | [four]: /url 29 | 30 | 31 | [b]: /url/ 32 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Amps and angle encoding.text: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Links, reference style.html: -------------------------------------------------------------------------------- 1 |Foo bar.
2 | 3 |Foo bar.
4 | 5 |Foo bar.
6 | 7 |With embedded [brackets].
8 | 9 |Indented once.
10 | 11 |Indented twice.
12 | 13 |Indented thrice.
14 | 15 |Indented [four][] times.
16 | 17 |[four]: /url
18 |
19 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0/Tests/Tabs.html:
--------------------------------------------------------------------------------
1 | this is a list item 3 | indented with tabs
this is a list item 5 | indented with spaces
Code:
9 | 10 |this code block is indented by one tab
11 |
12 |
13 | And:
14 | 15 | this code block is indented by two tabs
16 |
17 |
18 | And:
19 | 20 |+ this is an example list item
21 | indented with tabs
22 |
23 | + this is an example list item
24 | indented with spaces
25 |
26 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0.3/Tests/Tabs.html:
--------------------------------------------------------------------------------
1 | this is a list item 3 | indented with tabs
this is a list item 5 | indented with spaces
Code:
9 | 10 |this code block is indented by one tab
11 |
12 |
13 | And:
14 | 15 | this code block is indented by two tabs
16 |
17 |
18 | And:
19 | 20 |+ this is an example list item
21 | indented with tabs
22 |
23 | + this is an example list item
24 | indented with spaces
25 |
26 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0/Tests/Amps and angle encoding.html:
--------------------------------------------------------------------------------
1 | AT&T has an ampersand in their name.
2 | 3 |AT&T is another way to write it.
4 | 5 |This & that.
6 | 7 |4 < 5.
8 | 9 |6 > 5.
10 | 11 |Here's a link with an ampersand in the URL.
12 | 13 |Here's a link with an amersand in the link text: AT&T.
14 | 15 |Here's an inline link.
16 | 17 |Here's an inline link.
18 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html: -------------------------------------------------------------------------------- 1 |AT&T has an ampersand in their name.
2 | 3 |AT&T is another way to write it.
4 | 5 |This & that.
6 | 7 |4 < 5.
8 | 9 |6 > 5.
10 | 11 |Here's a link with an ampersand in the URL.
12 | 13 |Here's a link with an amersand in the link text: AT&T.
14 | 15 |Here's an inline link.
16 | 17 |Here's an inline link.
18 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Horizontal rules.text: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Horizontal rules.text: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /test/benchmark.rb: -------------------------------------------------------------------------------- 1 | # coding: UTF-8 2 | # Thanks Kramdown for the inspiration! 3 | require 'benchmark/ips' 4 | 5 | require 'redcarpet' 6 | require 'bluecloth' 7 | require 'kramdown' 8 | 9 | markdown = File.read(File.join(File.dirname(__FILE__), "fixtures/benchmark.md")) 10 | 11 | # Let's bench! 12 | Benchmark.ips do |bench| 13 | bench.report("Redcarpet") do 14 | Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(markdown) 15 | end 16 | 17 | bench.report("BlueCloth") do 18 | BlueCloth.new(markdown).to_html 19 | end 20 | 21 | bench.report("Kramdown") do 22 | Kramdown::Document.new(markdown).to_html 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Auto links.html: -------------------------------------------------------------------------------- 1 |Link: http://example.com/.
2 | 3 |With an ampersand: http://example.com/?foo=1&bar=2
4 | 5 |12 |14 | 15 |Blockquoted: http://example.com/
13 |
Auto-links should not occur here: <http://example.com/>
or here: <http://example.com/>
18 |
19 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0/Tests/Auto links.html:
--------------------------------------------------------------------------------
1 | Link: http://example.com/.
2 | 3 |With an ampersand: http://example.com/?foo=1&bar=2
4 | 5 |12 |14 | 15 |Blockquoted: http://example.com/
13 |
Auto-links should not occur here: <http://example.com/>
or here: <http://example.com/>
18 |
19 |
--------------------------------------------------------------------------------
/test/custom_render_test.rb:
--------------------------------------------------------------------------------
1 | # coding: UTF-8
2 | require 'test_helper'
3 |
4 | class CustomRenderTest < Redcarpet::TestCase
5 | class SimpleRender < Redcarpet::Render::HTML
6 | def emphasis(text)
7 | "#{text}"
8 | end
9 | end
10 |
11 | def test_simple_overload
12 | md = Redcarpet::Markdown.new(SimpleRender)
13 | assert_equal "This is just a test
\n", 14 | md.render("This is *just* a test") 15 | end 16 | 17 | class NilPreprocessRenderer < Redcarpet::Render::HTML 18 | def preprocess(fulldoc) 19 | nil 20 | end 21 | end 22 | 23 | def test_preprocess_returning_nil 24 | md = Redcarpet::Markdown.new(NilPreprocessRenderer) 25 | assert_equal(nil,md.render("Anything")) 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Horizontal rules.html: -------------------------------------------------------------------------------- 1 |Dashes:
2 | 3 |---
12 |
13 |
14 | - - -
23 |
24 |
25 | Asterisks:
26 | 27 |***
36 |
37 |
38 | * * *
47 |
48 |
49 | Underscores:
50 | 51 |___
60 |
61 |
62 | _ _ _
71 |
72 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0.3/Tests/Horizontal rules.html:
--------------------------------------------------------------------------------
1 | Dashes:
2 | 3 |---
12 |
13 |
14 | - - -
23 |
24 |
25 | Asterisks:
26 | 27 |***
36 |
37 |
38 | * * *
47 |
48 |
49 | Underscores:
50 | 51 |___
60 |
61 |
62 | _ _ _
71 |
72 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0/Tests/Inline HTML (Simple).text:
--------------------------------------------------------------------------------
1 | Here's a simple block:
2 |
3 | Hello world!
" 17 | output = render(markdown) 18 | 19 | assert_match %r{<}, output 20 | end 21 | 22 | def test_html_escaping_in_code_blocks 23 | markdown = "~~~\nHello!
\n~~~" 24 | output = render(markdown) 25 | 26 | assert_match %r{<p>}, output 27 | end 28 | 29 | def test_lang_class_is_removed 30 | markdown = "~~~ruby\nclass Foo; end\n~~~" 31 | output = render(markdown, with: [:fenced_code_blocks]) 32 | 33 | assert_not_match %r{ruby}, output 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Inline HTML (Simple).html: -------------------------------------------------------------------------------- 1 |Here's a simple block:
2 | 3 |This should be a code block, though:
8 | 9 |<div>
10 | foo
11 | </div>
12 |
13 |
14 | As should this:
15 | 16 |<div>foo</div>
17 |
18 |
19 | Now, nested:
20 | 21 |This should just be an HTML comment:
30 | 31 | 32 | 33 |Multiline:
34 | 35 | 39 | 40 |Code block:
41 | 42 |<!-- Comment -->
43 |
44 |
45 | Just plain comment, with trailing spaces on the line:
46 | 47 | 48 | 49 |Code:
50 | 51 |<hr />
52 |
53 |
54 | Hr's:
55 | 56 |Here's a simple block:
2 | 3 |This should be a code block, though:
8 | 9 |<div>
10 | foo
11 | </div>
12 |
13 |
14 | As should this:
15 | 16 |<div>foo</div>
17 |
18 |
19 | Now, nested:
20 | 21 |This should just be an HTML comment:
30 | 31 | 32 | 33 |Multiline:
34 | 35 | 39 | 40 |Code block:
41 | 42 |<!-- Comment -->
43 |
44 |
45 | Just plain comment, with trailing spaces on the line:
46 | 47 | 48 | 49 |Code:
50 | 51 |<hr />
52 |
53 |
54 | Hr's:
55 | 56 |Foo bar.
2 | 3 |Foo bar.
4 | 5 |Foo bar.
6 | 7 |With embedded [brackets].
8 | 9 |Indented once.
10 | 11 |Indented twice.
12 | 13 |Indented thrice.
14 | 15 |Indented [four][] times.
16 | 17 |[four]: /url
18 |
19 |
20 | this should work
23 | 24 |So should this.
25 | 26 |And this.
27 | 28 |And this.
29 | 30 |And this.
31 | 32 |But not [that] [].
33 | 34 |Nor [that][].
35 | 36 |Nor [that].
37 | 38 |[Something in brackets like this should work]
39 | 40 |[Same with this.]
41 | 42 |In this case, this points to something else.
43 | 44 |Backslashing should suppress [this] and [this].
45 | 46 |Here's one where the link 49 | breaks across lines.
50 | 51 |Here's another where the link 52 | breaks across lines, but with a line-ending space.
53 | -------------------------------------------------------------------------------- /lib/redcarpet/render_man.rb: -------------------------------------------------------------------------------- 1 | module Redcarpet 2 | module Render 3 | class ManPage < Base 4 | 5 | def normal_text(text) 6 | text.gsub('-', '\\-').strip 7 | end 8 | 9 | def block_code(code, language) 10 | "\n.nf\n#{normal_text(code)}\n.fi\n" 11 | end 12 | 13 | def codespan(code) 14 | block_code(code, nil) 15 | end 16 | 17 | def header(title, level) 18 | case level 19 | when 1 20 | "\n.TH #{title}\n" 21 | 22 | when 2 23 | "\n.SH #{title}\n" 24 | 25 | when 3 26 | "\n.SS #{title}\n" 27 | end 28 | end 29 | 30 | def double_emphasis(text) 31 | "\\fB#{text}\\fP" 32 | end 33 | 34 | def emphasis(text) 35 | "\\fI#{text}\\fP" 36 | end 37 | 38 | def linebreak 39 | "\n.LP\n" 40 | end 41 | 42 | def paragraph(text) 43 | "\n.TP\n#{text}\n" 44 | end 45 | 46 | def list(content, list_type) 47 | case list_type 48 | when :ordered 49 | "\n\n.nr step 0 1\n#{content}\n" 50 | when :unordered 51 | "\n.\n#{content}\n" 52 | end 53 | end 54 | 55 | def list_item(content, list_type) 56 | case list_type 57 | when :ordered 58 | ".IP \\n+[step]\n#{content.strip}\n" 59 | when :unordered 60 | ".IP \\[bu] 2 \n#{content.strip}\n" 61 | end 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Backslash escapes.text: -------------------------------------------------------------------------------- 1 | These should all get escaped: 2 | 3 | Backslash: \\ 4 | 5 | Backtick: \` 6 | 7 | Asterisk: \* 8 | 9 | Underscore: \_ 10 | 11 | Left brace: \{ 12 | 13 | Right brace: \} 14 | 15 | Left bracket: \[ 16 | 17 | Right bracket: \] 18 | 19 | Left paren: \( 20 | 21 | Right paren: \) 22 | 23 | Greater-than: \> 24 | 25 | Hash: \# 26 | 27 | Period: \. 28 | 29 | Bang: \! 30 | 31 | Plus: \+ 32 | 33 | Minus: \- 34 | 35 | 36 | 37 | These should not, because they occur within a code block: 38 | 39 | Backslash: \\ 40 | 41 | Backtick: \` 42 | 43 | Asterisk: \* 44 | 45 | Underscore: \_ 46 | 47 | Left brace: \{ 48 | 49 | Right brace: \} 50 | 51 | Left bracket: \[ 52 | 53 | Right bracket: \] 54 | 55 | Left paren: \( 56 | 57 | Right paren: \) 58 | 59 | Greater-than: \> 60 | 61 | Hash: \# 62 | 63 | Period: \. 64 | 65 | Bang: \! 66 | 67 | Plus: \+ 68 | 69 | Minus: \- 70 | 71 | 72 | Nor should these, which occur in code spans: 73 | 74 | Backslash: `\\` 75 | 76 | Backtick: `` \` `` 77 | 78 | Asterisk: `\*` 79 | 80 | Underscore: `\_` 81 | 82 | Left brace: `\{` 83 | 84 | Right brace: `\}` 85 | 86 | Left bracket: `\[` 87 | 88 | Right bracket: `\]` 89 | 90 | Left paren: `\(` 91 | 92 | Right paren: `\)` 93 | 94 | Greater-than: `\>` 95 | 96 | Hash: `\#` 97 | 98 | Period: `\.` 99 | 100 | Bang: `\!` 101 | 102 | Plus: `\+` 103 | 104 | Minus: `\-` 105 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Submitting a Pull Request 2 | 3 | 1. [Fork the repository.][fork] 4 | 2. [Create a topic branch.][branch] 5 | 3. Check which version of Ruby is installed on your machine with `ruby -v`. 6 | The list of supported Ruby versions is listed in [.travis.yml][travis_yml]. 7 | Set up one of these versions; use of [RVM][rvm] is recommended to switch 8 | easily between different versions. 9 | 4. [Install bundler.][bundler] 10 | 5. Make sure to have the `tidy` command on your system: 11 | 12 | * `apt-get install tidy` 13 | * `yum install tidy` 14 | * `pacman -S tidyhtml` 15 | 16 | 6. Check that unit tests pass with `rake test`. 17 | 7. Write a failing test to capture existing bug or lack of feature. 18 | 8. Run `rake test` to verify that test fails. 19 | 9. Implement your feature or bug fix. 20 | 10. Ensure tests pass. 21 | 11. If it's a new feature or a bug fix, please add an entry to the changelog file. 22 | 12. Add, commit, and push your changes. 23 | 13. [Submit a pull request.][pr] 24 | 14. You will get some feedback and may need to push additional commits 25 | with more fixes to the same branch; this will update your pull request 26 | automatically. 27 | 28 | [branch]: http://git-scm.com/book/en/Git-Branching-Branching-Workflows#Topic-Branches 29 | [bundler]: http://bundler.io 30 | [fork]: https://help.github.com/articles/fork-a-repo 31 | [pr]: https://help.github.com/articles/using-pull-requests 32 | [rvm]: https://rvm.io 33 | [travis_yml]: https://github.com/vmg/redcarpet/blob/master/.travis.yml 34 | -------------------------------------------------------------------------------- /test/redcarpet_compat_test.rb: -------------------------------------------------------------------------------- 1 | # coding: UTF-8 2 | require 'test_helper' 3 | 4 | class RedcarpetCompatTest < Redcarpet::TestCase 5 | def test_simple_compat_api 6 | html = RedcarpetCompat.new("This is_just_a test").to_html 7 | assert_equal "This isjusta test
\n", html 8 | end 9 | 10 | def test_compat_api_enables_extensions 11 | html = RedcarpetCompat.new("This is_just_a test", :no_intra_emphasis).to_html 12 | assert_equal "This is_just_a test
\n", html 13 | end 14 | 15 | def test_compat_api_knows_fenced_code_extension 16 | text = "```ruby\nx = 'foo'\n```" 17 | html = RedcarpetCompat.new(text, :fenced_code).to_html 18 | assert_equal "x = 'foo'\n\n", html
19 | end
20 |
21 | def test_compat_api_ignores_gh_blockcode_extension
22 | text = "```ruby\nx = 'foo'\n```"
23 | html = RedcarpetCompat.new(text, :fenced_code, :gh_blockcode).to_html
24 | assert_equal "x = 'foo'\n\n", html
25 | end
26 |
27 | def test_compat_api_knows_no_intraemphasis_extension
28 | html = RedcarpetCompat.new("This is_just_a test", :no_intraemphasis).to_html
29 | assert_equal "This is_just_a test
\n", html 30 | end 31 | 32 | def test_translate_outdated_extensions 33 | # these extensions are no longer used 34 | exts = [:gh_blockcode, :no_tables, :smart, :strict] 35 | html = RedcarpetCompat.new('"TEST"', *exts).to_html 36 | assert_equal ""TEST"
\n", html 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Ordered and unordered lists.text: -------------------------------------------------------------------------------- 1 | ## Unordered 2 | 3 | Asterisks tight: 4 | 5 | * asterisk 1 6 | * asterisk 2 7 | * asterisk 3 8 | 9 | 10 | Asterisks loose: 11 | 12 | * asterisk 1 13 | 14 | * asterisk 2 15 | 16 | * asterisk 3 17 | 18 | * * * 19 | 20 | Pluses tight: 21 | 22 | + Plus 1 23 | + Plus 2 24 | + Plus 3 25 | 26 | 27 | Pluses loose: 28 | 29 | + Plus 1 30 | 31 | + Plus 2 32 | 33 | + Plus 3 34 | 35 | * * * 36 | 37 | 38 | Minuses tight: 39 | 40 | - Minus 1 41 | - Minus 2 42 | - Minus 3 43 | 44 | 45 | Minuses loose: 46 | 47 | - Minus 1 48 | 49 | - Minus 2 50 | 51 | - Minus 3 52 | 53 | 54 | ## Ordered 55 | 56 | Tight: 57 | 58 | 1. First 59 | 2. Second 60 | 3. Third 61 | 62 | and: 63 | 64 | 1. One 65 | 2. Two 66 | 3. Three 67 | 68 | 69 | Loose using tabs: 70 | 71 | 1. First 72 | 73 | 2. Second 74 | 75 | 3. Third 76 | 77 | and using spaces: 78 | 79 | 1. One 80 | 81 | 2. Two 82 | 83 | 3. Three 84 | 85 | Multiple paragraphs: 86 | 87 | 1. Item 1, graf one. 88 | 89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's 90 | back. 91 | 92 | 2. Item 2. 93 | 94 | 3. Item 3. 95 | 96 | 97 | 98 | ## Nested 99 | 100 | * Tab 101 | * Tab 102 | * Tab 103 | 104 | Here's another: 105 | 106 | 1. First 107 | 2. Second: 108 | * Fee 109 | * Fie 110 | * Foe 111 | 3. Third 112 | 113 | Same thing but with paragraphs: 114 | 115 | 1. First 116 | 117 | 2. Second: 118 | * Fee 119 | * Fie 120 | * Foe 121 | 122 | 3. Third 123 | -------------------------------------------------------------------------------- /test/smarty_html_test.rb: -------------------------------------------------------------------------------- 1 | # coding: UTF-8 2 | require 'test_helper' 3 | 4 | class SmartyHTMLTest < Redcarpet::TestCase 5 | def setup 6 | @renderer = Redcarpet::Render::SmartyHTML 7 | end 8 | 9 | def test_that_smartyhtml_converts_single_quotes 10 | markdown = render("They're not for sale.") 11 | assert_equal "They’re not for sale.
\n", markdown 12 | end 13 | 14 | def test_that_smartyhtml_converts_double_quotes 15 | rd = render(%("Quoted text")) 16 | assert_equal %(“Quoted text”
\n), rd 17 | end 18 | 19 | def test_that_smartyhtml_converts_double_hyphen 20 | rd = render("double hyphen -- ndash") 21 | assert_equal "double hyphen – ndash
\n", rd 22 | end 23 | 24 | def test_that_smartyhtml_converts_triple_hyphen 25 | rd = render("triple hyphen --- mdash") 26 | assert_equal "triple hyphen — mdash
\n", rd 27 | end 28 | 29 | def test_that_smartyhtml_ignores_double_hyphen_in_code 30 | rd = render("double hyphen in `--option`") 31 | assert_equal "double hyphen in --option
The quick brown fox jumps over the lazy dog.
8 | 9 | EOS 10 | 11 | figure = <
14 | Hello world!
16 |The quick brown fox jumps over the lazy dog.
28 | \t 29 | EOS 30 | 31 | section_expected = <<section>
33 | <p>The quick brown fox jumps over the lazy dog.</p>
34 | </section>
35 |
36 | EOE
37 |
38 | header = <<header>
49 | <hgroup>
50 | <h1>Section heading</h1>
51 | <h2>Subhead</h2>
52 | </hgroup>
53 | </header>
54 |
55 | EOE
56 |
57 | assert_renders section_expected, section
58 | assert_renders header_expected, header
59 | end
60 |
61 | def test_script_tag_recognition
62 | markdown = <<-Md
63 |
66 | Md
67 | assert_renders markdown, markdown
68 | end
69 | end
70 |
--------------------------------------------------------------------------------
/test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text:
--------------------------------------------------------------------------------
1 | ## Unordered
2 |
3 | Asterisks tight:
4 |
5 | * asterisk 1
6 | * asterisk 2
7 | * asterisk 3
8 |
9 |
10 | Asterisks loose:
11 |
12 | * asterisk 1
13 |
14 | * asterisk 2
15 |
16 | * asterisk 3
17 |
18 | * * *
19 |
20 | Pluses tight:
21 |
22 | + Plus 1
23 | + Plus 2
24 | + Plus 3
25 |
26 |
27 | Pluses loose:
28 |
29 | + Plus 1
30 |
31 | + Plus 2
32 |
33 | + Plus 3
34 |
35 | * * *
36 |
37 |
38 | Minuses tight:
39 |
40 | - Minus 1
41 | - Minus 2
42 | - Minus 3
43 |
44 |
45 | Minuses loose:
46 |
47 | - Minus 1
48 |
49 | - Minus 2
50 |
51 | - Minus 3
52 |
53 |
54 | ## Ordered
55 |
56 | Tight:
57 |
58 | 1. First
59 | 2. Second
60 | 3. Third
61 |
62 | and:
63 |
64 | 1. One
65 | 2. Two
66 | 3. Three
67 |
68 |
69 | Loose using tabs:
70 |
71 | 1. First
72 |
73 | 2. Second
74 |
75 | 3. Third
76 |
77 | and using spaces:
78 |
79 | 1. One
80 |
81 | 2. Two
82 |
83 | 3. Three
84 |
85 | Multiple paragraphs:
86 |
87 | 1. Item 1, graf one.
88 |
89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's
90 | back.
91 |
92 | 2. Item 2.
93 |
94 | 3. Item 3.
95 |
96 |
97 |
98 | ## Nested
99 |
100 | * Tab
101 | * Tab
102 | * Tab
103 |
104 | Here's another:
105 |
106 | 1. First
107 | 2. Second:
108 | * Fee
109 | * Fie
110 | * Foe
111 | 3. Third
112 |
113 | Same thing but with paragraphs:
114 |
115 | 1. First
116 |
117 | 2. Second:
118 | * Fee
119 | * Fie
120 | * Foe
121 |
122 | 3. Third
123 |
124 |
125 | This was an error in Markdown 1.0.1:
126 |
127 | * this
128 |
129 | * sub
130 |
131 | that
132 |
--------------------------------------------------------------------------------
/ext/redcarpet/stack.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Vicent Marti
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | #ifndef STACK_H__
24 | #define STACK_H__
25 |
26 | #include These should all get escaped:
2 | 3 |Backslash: \
4 | 5 |Backtick: `
6 | 7 |Asterisk: *
8 | 9 |Underscore: _
10 | 11 |Left brace: {
12 | 13 |Right brace: }
14 | 15 |Left bracket: [
16 | 17 |Right bracket: ]
18 | 19 |Left paren: (
20 | 21 |Right paren: )
22 | 23 |Greater-than: >
24 | 25 |Hash: #
26 | 27 |Period: .
28 | 29 |Bang: !
30 | 31 |Plus: +
32 | 33 |Minus: -
34 | 35 |These should not, because they occur within a code block:
36 | 37 |Backslash: \\
38 |
39 | Backtick: \`
40 |
41 | Asterisk: \*
42 |
43 | Underscore: \_
44 |
45 | Left brace: \{
46 |
47 | Right brace: \}
48 |
49 | Left bracket: \[
50 |
51 | Right bracket: \]
52 |
53 | Left paren: \(
54 |
55 | Right paren: \)
56 |
57 | Greater-than: \>
58 |
59 | Hash: \#
60 |
61 | Period: \.
62 |
63 | Bang: \!
64 |
65 | Plus: \+
66 |
67 | Minus: \-
68 |
69 |
70 | Nor should these, which occur in code spans:
71 | 72 |Backslash: \\
Backtick: \`
Asterisk: \*
Underscore: \_
Left brace: \{
Right brace: \}
Left bracket: \[
Right bracket: \]
Left paren: \(
Right paren: \)
Greater-than: \>
Hash: \#
Period: \.
Bang: \!
Plus: \+
Minus: \-
A ==simple== fixture file -- with " \ 22 | "a link.
\n" 23 | 24 | assert_equal expected, @output 25 | end 26 | 27 | def test_enabling_a_parse_option 28 | run_bin("--parse", "highlight", @fixture_path) 29 | 30 | assert_output "" 31 | refute_output "==" 32 | end 33 | 34 | def test_enabling_a_render_option 35 | run_bin("--render", "no-links", @fixture_path) 36 | 37 | assert_output "[link]" 38 | refute_output "" 39 | end 40 | 41 | def test_enabling_smarty_pants 42 | run_bin("--smarty", @fixture_path) 43 | 44 | assert_output "&ndash" 45 | refute_output "--" 46 | end 47 | 48 | def test_version_option 49 | run_bin("--version") 50 | assert_output "Redcarpet #{Redcarpet::VERSION}" 51 | end 52 | 53 | def test_legacy_option_parsing 54 | run_bin("--parse-highlight", "--render-no-links", @fixture_path) 55 | 56 | assert_output "" 57 | refute_output "==" 58 | 59 | assert_output "[link]" 60 | refute_output "" 61 | end 62 | 63 | private 64 | 65 | def run_bin(*args) 66 | bin_path = File.expand_path('../../bin/redcarpet', __FILE__) 67 | 68 | IO.popen("#{bin_path} #{args.join(" ")}") do |stream| 69 | @output = stream.read 70 | end 71 | end 72 | 73 | def assert_output(pattern) 74 | assert_match pattern, @output 75 | end 76 | 77 | def refute_output(pattern) 78 | refute_match Regexp.new(pattern), @output 79 | end 80 | end 81 | -------------------------------------------------------------------------------- /test/smarty_pants_test.rb: -------------------------------------------------------------------------------- 1 | # coding: UTF-8 2 | require 'test_helper' 3 | 4 | class SmartyPantsTest < Redcarpet::TestCase 5 | def setup 6 | @pants = Redcarpet::Render::SmartyPants 7 | end 8 | 9 | def test_that_smart_converts_single_quotes_in_words_that_end_in_re 10 | markdown = @pants.render("They're not for sale.
") 11 | assert_equal "They’re not for sale.
", markdown 12 | end 13 | 14 | def test_that_smart_converts_single_quotes_in_words_that_end_in_ll 15 | markdown = @pants.render("Well that'll be the day
") 16 | assert_equal "Well that’ll be the day
", markdown 17 | end 18 | 19 | def test_that_smart_converts_double_quotes_to_curly_quotes 20 | rd = @pants.render(%("Quoted text"
)) 21 | assert_equal %(“Quoted text”
), rd 22 | end 23 | 24 | def test_that_smart_gives_ve_suffix_a_rsquo 25 | rd = @pants.render("I've been meaning to tell you ..
") 26 | assert_equal "I’ve been meaning to tell you ..
", rd 27 | end 28 | 29 | def test_that_smart_gives_m_suffix_a_rsquo 30 | rd = @pants.render("I'm not kidding
") 31 | assert_equal "I’m not kidding
", rd 32 | end 33 | 34 | def test_that_smart_gives_d_suffix_a_rsquo 35 | rd = @pants.render("what'd you say?
") 36 | assert_equal "what’d you say?
", rd 37 | end 38 | 39 | def test_that_backticks_are_preserved 40 | rd = @pants.render("single `backticks` in HTML should be preserved
") 41 | assert_equal "single `backticks` in HTML should be preserved
", rd 42 | end 43 | 44 | def test_that_smart_converts_trailing_single_quotes_to_curly_quotes 45 | rd = @pants.render("Hopin' that this bug gets some fixin'.
") 46 | assert_equal "Hopin’ that this bug gets some fixin’.
", rd 47 | end 48 | 49 | def test_that_is_not_confused_by_fractions 50 | rd = @pants.render('I am 1/4... of the way to 1/4/2000') 51 | assert_equal "I am ¼… of the way to 1/4/2000", rd 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /redcarpet.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | Gem::Specification.new do |s| 3 | s.name = 'redcarpet' 4 | s.version = '3.3.2' 5 | s.summary = "Markdown that smells nice" 6 | s.description = 'A fast, safe and extensible Markdown to (X)HTML parser' 7 | s.date = '2015-06-22' 8 | s.email = 'vicent@github.com' 9 | s.homepage = 'http://github.com/vmg/redcarpet' 10 | s.authors = ["Natacha Porté", "Vicent Martí"] 11 | s.license = 'MIT' 12 | s.required_ruby_version = '>= 1.9.2' 13 | # = MANIFEST = 14 | s.files = %w[ 15 | COPYING 16 | Gemfile 17 | README.markdown 18 | Rakefile 19 | bin/redcarpet 20 | ext/redcarpet/autolink.c 21 | ext/redcarpet/autolink.h 22 | ext/redcarpet/buffer.c 23 | ext/redcarpet/buffer.h 24 | ext/redcarpet/extconf.rb 25 | ext/redcarpet/houdini.h 26 | ext/redcarpet/houdini_href_e.c 27 | ext/redcarpet/houdini_html_e.c 28 | ext/redcarpet/html.c 29 | ext/redcarpet/html.h 30 | ext/redcarpet/html_blocks.h 31 | ext/redcarpet/html_smartypants.c 32 | ext/redcarpet/markdown.c 33 | ext/redcarpet/markdown.h 34 | ext/redcarpet/rc_markdown.c 35 | ext/redcarpet/rc_render.c 36 | ext/redcarpet/redcarpet.h 37 | ext/redcarpet/stack.c 38 | ext/redcarpet/stack.h 39 | lib/redcarpet.rb 40 | lib/redcarpet/cli.rb 41 | lib/redcarpet/compat.rb 42 | lib/redcarpet/render_man.rb 43 | lib/redcarpet/render_strip.rb 44 | redcarpet.gemspec 45 | test/benchmark.rb 46 | test/custom_render_test.rb 47 | test/fixtures/benchmark.md 48 | test/html5_test.rb 49 | test/html_render_test.rb 50 | test/html_toc_render_test.rb 51 | test/markdown_test.rb 52 | test/pathological_inputs_test.rb 53 | test/redcarpet_bin_test.rb 54 | test/redcarpet_compat_test.rb 55 | test/safe_render_test.rb 56 | test/smarty_html_test.rb 57 | test/smarty_pants_test.rb 58 | test/stripdown_render_test.rb 59 | test/test_helper.rb 60 | ] 61 | # = MANIFEST = 62 | s.test_files = s.files.grep(%r{^test/}) 63 | s.extra_rdoc_files = ["COPYING"] 64 | s.extensions = ["ext/redcarpet/extconf.rb"] 65 | s.executables = ["redcarpet"] 66 | s.require_paths = ["lib"] 67 | 68 | s.add_development_dependency "rake-compiler", "~> 0.9.5" 69 | s.add_development_dependency "test-unit", "~> 3.1.3" 70 | end 71 | -------------------------------------------------------------------------------- /lib/redcarpet/compat.rb: -------------------------------------------------------------------------------- 1 | require 'redcarpet' 2 | 3 | # Creates an instance of Redcarpet with the RedCloth API. 4 | class RedcarpetCompat 5 | attr_accessor :text 6 | 7 | def initialize(text, *exts) 8 | exts_hash, render_hash = *parse_extensions_and_renderer_options(exts) 9 | @text = text 10 | renderer = Redcarpet::Render::HTML.new(render_hash) 11 | @markdown = Redcarpet::Markdown.new(renderer, exts_hash) 12 | end 13 | 14 | def to_html(*_dummy) 15 | @markdown.render(text) 16 | end 17 | 18 | private 19 | 20 | EXTENSION_MAP = { 21 | # old name => new name 22 | :autolink => :autolink, 23 | :fenced_code => :fenced_code_blocks, 24 | :filter_html => :filter_html, 25 | :hard_wrap => :hard_wrap, 26 | :prettify => :prettify, 27 | :lax_htmlblock => :lax_spacing, 28 | :no_image => :no_images, 29 | :no_intraemphasis => :no_intra_emphasis, 30 | :no_links => :no_links, 31 | :filter_styles => :no_styles, 32 | :safelink => :safe_links_only, 33 | :space_header => :space_after_headers, 34 | :strikethrough => :strikethrough, 35 | :tables => :tables, 36 | :generate_toc => :with_toc_data, 37 | :xhtml => :xhtml, 38 | 39 | # old names with no new mapping 40 | :gh_blockcode => nil, 41 | :no_tables => nil, 42 | :smart => nil, 43 | :strict => nil 44 | } 45 | 46 | RENDERER_OPTIONS = [:filter_html, :no_images, :no_links, :no_styles, 47 | :safe_links_only, :with_toc_data, :hard_wrap, :prettify, :xhtml] 48 | 49 | def rename_extensions(exts) 50 | exts.map do |old_name| 51 | if new_name = EXTENSION_MAP[old_name] 52 | new_name 53 | else 54 | old_name 55 | end 56 | end.compact 57 | end 58 | 59 | # Returns two hashes, the extensions and renderer options 60 | # given the extension list 61 | def parse_extensions_and_renderer_options(exts) 62 | exts = rename_extensions(exts) 63 | exts.partition {|ext| !RENDERER_OPTIONS.include?(ext) }. 64 | map {|list| list_to_truthy_hash(list) } 65 | end 66 | 67 | # Turns a list of symbols into a hash of symbol => true. 68 | def list_to_truthy_hash(list) 69 | list.inject({}) {|h, k| h[k] = true; h } 70 | end 71 | end 72 | 73 | Markdown = RedcarpetCompat unless defined? Markdown 74 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Ordered and unordered lists.html: -------------------------------------------------------------------------------- 1 |Asterisks tight:
4 | 5 |Asterisks loose:
12 | 13 |asterisk 1
asterisk 2
asterisk 3
Pluses tight:
22 | 23 |Pluses loose:
30 | 31 |Plus 1
Plus 2
Plus 3
Minuses tight:
40 | 41 |Minuses loose:
48 | 49 |Minus 1
Minus 2
Minus 3
Tight:
58 | 59 |and:
66 | 67 |Loose using tabs:
74 | 75 |First
Second
Third
and using spaces:
82 | 83 |One
Two
Three
Multiple paragraphs:
90 | 91 |Item 1, graf one.
93 | 94 |Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.
Item 2.
Item 3.
Here's another:
113 | 114 |Same thing but with paragraphs:
126 | 127 |First
Second:
130 | 131 |Third
These should all get escaped:
2 | 3 |Backslash: \
4 | 5 |Backtick: `
6 | 7 |Asterisk: *
8 | 9 |Underscore: _
10 | 11 |Left brace: {
12 | 13 |Right brace: }
14 | 15 |Left bracket: [
16 | 17 |Right bracket: ]
18 | 19 |Left paren: (
20 | 21 |Right paren: )
22 | 23 |Greater-than: >
24 | 25 |Hash: #
26 | 27 |Period: .
28 | 29 |Bang: !
30 | 31 |Plus: +
32 | 33 |Minus: -
34 | 35 |These should not, because they occur within a code block:
36 | 37 |Backslash: \\
38 |
39 | Backtick: \`
40 |
41 | Asterisk: \*
42 |
43 | Underscore: \_
44 |
45 | Left brace: \{
46 |
47 | Right brace: \}
48 |
49 | Left bracket: \[
50 |
51 | Right bracket: \]
52 |
53 | Left paren: \(
54 |
55 | Right paren: \)
56 |
57 | Greater-than: \>
58 |
59 | Hash: \#
60 |
61 | Period: \.
62 |
63 | Bang: \!
64 |
65 | Plus: \+
66 |
67 | Minus: \-
68 |
69 |
70 | Nor should these, which occur in code spans:
71 | 72 |Backslash: \\
Backtick: \`
Asterisk: \*
Underscore: \_
Left brace: \{
Right brace: \}
Left bracket: \[
Right bracket: \]
Left paren: \(
Right paren: \)
Greater-than: \>
Hash: \#
Period: \.
Bang: \!
Plus: \+
Minus: \-
These should get escaped, even though they're matching pairs for 106 | other Markdown constructs:
107 | 108 |*asterisks*
109 | 110 |_underscores_
111 | 112 |`backticks`
113 | 114 |This is a code span with a literal backslash-backtick sequence: \`
This is a tag with unescaped backticks bar.
117 | 118 |This is a tag with backslashes bar.
119 | -------------------------------------------------------------------------------- /ext/redcarpet/stack.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Vicent Marti 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | #include "stack.h" 24 | #includeAsterisks tight:
4 | 5 |Asterisks loose:
12 | 13 |asterisk 1
asterisk 2
asterisk 3
Pluses tight:
22 | 23 |Pluses loose:
30 | 31 |Plus 1
Plus 2
Plus 3
Minuses tight:
40 | 41 |Minuses loose:
48 | 49 |Minus 1
Minus 2
Minus 3
Tight:
58 | 59 |and:
66 | 67 |Loose using tabs:
74 | 75 |First
Second
Third
and using spaces:
82 | 83 |One
Two
Three
Multiple paragraphs:
90 | 91 |Item 1, graf one.
93 | 94 |Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.
Item 2.
Item 3.
Here's another:
113 | 114 |Same thing but with paragraphs:
126 | 127 |First
Second:
130 | 131 |Third
This was an error in Markdown 1.0.1:
141 | 142 |this
144 | 145 |that
" \
41 | "#{html_escape(code)}" \
42 | ""
43 | end
44 |
45 | private
46 |
47 | # TODO: This is far from ideal to have such method as we
48 | # are duplicating existing code from Houdini. This method
49 | # should be defined at the C level.
50 | def html_escape(string)
51 | string.gsub(/['&\"<>\/]/, {
52 | '&' => '&',
53 | '<' => '<',
54 | '>' => '>',
55 | '"' => '"',
56 | "'" => ''',
57 | "/" => '/',
58 | })
59 | end
60 | end
61 |
62 | # SmartyPants Mixin module
63 | #
64 | # Implements SmartyPants.postprocess, which
65 | # performs smartypants replacements on the HTML file,
66 | # once it has been fully rendered.
67 | #
68 | # To add SmartyPants postprocessing to your custom
69 | # renderers, just mixin the module `include SmartyPants`
70 | #
71 | # You can also use this as a standalone SmartyPants
72 | # implementation.
73 | #
74 | # Example:
75 | #
76 | # # Mixin
77 | # class CoolRenderer < HTML
78 | # include SmartyPants
79 | # # more code here
80 | # end
81 | #
82 | # # Standalone
83 | # Redcarpet::Render::SmartyPants.render("you're")
84 | #
85 | module SmartyPants
86 | extend self
87 | def self.render(text)
88 | postprocess text
89 | end
90 | end
91 | end
92 | end
93 |
--------------------------------------------------------------------------------
/ext/redcarpet/html.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Vicent Marti
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | #ifndef HTML_H__
24 | #define HTML_H__
25 |
26 | #include "markdown.h"
27 | #include "buffer.h"
28 | #include <script>BAD</script>
22 | 23 |<img src="/favicon.ico" />
24 | EOE 25 | 26 | assert_equal expected, render(source, with: [:escape_html]) 27 | end 28 | 29 | def test_that_filter_html_works 30 | markdown = 'Through NO ' 31 | output = render(markdown, with: [:filter_html]) 32 | 33 | assert_equal "Through NO DOUBLE NO
\n", 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 "Lorem,
\nipsum
)
45 | output = render(markdown, with: [:no_images])
46 |
47 | assert_no_match %r{a bold codespan
102 | However, this should be an emphasised codespan
103 |
104 | ABC or DEFThe bash man page!
\n) 116 | 117 | assert_equal expected, render(markdown) 118 | end 119 | 120 | def test_autolinking_works_as_expected 121 | markdown = "Uri ftp://user:pass@example.com/. Email foo@bar.com and link http://bar.com" 122 | output = render(markdown, with: [:autolink]) 123 | 124 | assert output.include? 'ftp://user:pass@example.com/' 125 | assert output.include? 'mailto:foo@bar.com' 126 | assert output.include? '' 127 | end 128 | 129 | def test_that_footnotes_work 130 | markdown = <<-MD 131 | This is a footnote.[^1] 132 | 133 | [^1]: It provides additional information. 134 | MD 135 | 136 | html = <This is a footnote.1 138 | 139 |It provides additional information. ↩
145 |[^1] And a trailing definition
165 | HTML 166 | 167 | output = render(markdown, with: [:footnotes]) 168 | assert_equal html, output 169 | end 170 | 171 | def test_footnotes_enabled_but_missing_definition 172 | markdown = "Some text with a marker[^1] but no definition." 173 | expected = "Some text with a marker[^1] but no definition.
\n" 174 | 175 | output = render(markdown, with: [:footnotes]) 176 | assert_equal expected, output 177 | end 178 | 179 | def test_autolink_short_domains 180 | markdown = "Example of uri ftp://auto/short/domains. Email auto@l.n and link http://a/u/t/o/s/h/o/r/t" 181 | output = render(markdown, with: [:autolink]) 182 | 183 | assert output.include? 'ftp://auto/short/domains' 184 | assert output.include? 'mailto:auto@l.n' 185 | assert output.include? 'http://a/u/t/o/s/h/o/r/t' 186 | end 187 | 188 | def test_that_prettify_works 189 | markdown = "\tclass Foo\nend" 190 | output = render(markdown, with: [:prettify]) 191 | 192 | assert output.include?("")
193 |
194 | markdown = "`class`"
195 | output = render(markdown, with: [:prettify])
196 |
197 | assert output.include?("")
198 | end
199 |
200 | def test_prettify_with_fenced_code_blocks
201 | markdown = "~~~ruby\ncode\n~~~"
202 | output = render(markdown, with: [:fenced_code_blocks, :prettify])
203 |
204 | assert output.include?("")
205 | end
206 |
207 | def test_safe_links_only_with_anchors
208 | markdown = "An [anchor link](#anchor) on a page."
209 | output = render(markdown, with: [:safe_links_only])
210 |
211 | assert_match %r{anchor link}, output
212 | end
213 |
214 | def test_autolink_with_link_attributes
215 | options = { autolink: true, link_attributes: {rel: "nofollow"} }
216 | output = render("https://github.com/", with: options)
217 |
218 | assert_match %r{rel="nofollow"}, output
219 | end
220 |
221 | def test_image_unsafe_src_with_safe_links_only
222 | markdown = ";)"
223 | output = render(markdown, with: [:safe_links_only])
224 |
225 | assert_not_match %r{img src}, output
226 | end
227 |
228 | def test_no_styles_option_inside_a_paragraph
229 | markdown = "Hello !"
230 | output = render(markdown, with: [:no_styles])
231 |
232 | assert_no_match %r{"
237 | output = render(markdown, with: [:no_styles])
238 |
239 | assert_no_match %r{