├── Gemfile.ci ├── 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 └── redcarpet_test.rb ├── .gitmodules ├── ext └── redcarpet │ ├── extconf.rb │ ├── stack.h │ ├── redcarpet.h │ ├── houdini.h │ ├── autolink.h │ ├── stack.c │ ├── html.h │ ├── houdini_html_e.c │ ├── buffer.h │ ├── houdini_href_e.c │ ├── rc_markdown.c │ ├── markdown.h │ ├── buffer.c │ ├── autolink.c │ ├── html_blocks.h │ ├── html_smartypants.c │ ├── rc_render.c │ └── html.c ├── .travis.yml ├── bin └── redcarpet ├── COPYING ├── lib ├── redcarpet.rb └── redcarpet │ └── render_man.rb ├── redcarpet.gemspec ├── Rakefile └── README.markdown /Gemfile.ci: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | gem "nokogiri" 3 | gem "rake-compiler" 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "sundown"] 2 | path = sundown 3 | url = git@github.com:tanoku/sundown.git 4 | -------------------------------------------------------------------------------- /ext/redcarpet/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | dir_config('redcarpet') 4 | create_makefile('redcarpet') 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | rvm: 2 | - 1.8.7 # (current default) 3 | - 1.9.2 4 | - 1.9.3 5 | - rbx-2.0 6 | - ruby-head 7 | - ree 8 | gemfile: Gemfile.ci 9 | -------------------------------------------------------------------------------- /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 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Nested blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 | 8 |
9 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 | 8 |
9 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Literal quotes in titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Code Spans.text: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. 6 | 7 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html: -------------------------------------------------------------------------------- 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 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
bar
14 |
15 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/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 | [Empty](). 10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
bar
14 |
15 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Inline HTML comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Inline HTML comments.text: -------------------------------------------------------------------------------- 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 Spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 | 3 |

Fix for backticks within HTML tag: like this

4 | 5 |

Here's how you put `backticks` in a code span.

6 | 7 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/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/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 |

Example:

3 | 4 |
sub status {
 5 |     print "working";
 6 | }
 7 | 
8 | 9 |

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/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.3/Tests/Blockquotes with code blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

3 | 4 |
sub status {
 5 |     print "working";
 6 | }
 7 | 
8 | 9 |

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /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 |

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 |

this and the other

10 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Auto links.text: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Auto links.text: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Links, inline style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 | 3 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

Empty.

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 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

URL and title.

10 | 11 |

Empty.

12 | -------------------------------------------------------------------------------- /ext/redcarpet/stack.h: -------------------------------------------------------------------------------- 1 | #ifndef STACK_H__ 2 | #define STACK_H__ 3 | 4 | #include 5 | 6 | struct stack { 7 | void **item; 8 | size_t size; 9 | size_t asize; 10 | }; 11 | 12 | void stack_free(struct stack *); 13 | int stack_grow(struct stack *, size_t); 14 | int stack_init(struct stack *, size_t); 15 | 16 | int stack_push(struct stack *, void *); 17 | 18 | void *stack_pop(struct stack *); 19 | void *stack_top(struct stack *); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bin/redcarpet: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # Usage: redcarpet [...] 3 | # Convert one or more Markdown files to HTML and write to standard output. With 4 | # no or when is '-', read Markdown source text from standard input. 5 | if ARGV.include?('--help') 6 | File.read(__FILE__).split("\n").grep(/^# /).each do |line| 7 | puts line[2..-1] 8 | end 9 | exit 0 10 | end 11 | 12 | require 'redcarpet' 13 | STDOUT.write(Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(ARGF.read)) 14 | -------------------------------------------------------------------------------- /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 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 |
  • this is a list item 5 | indented with spaces

  • 6 |
7 | 8 |

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 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 |
  • this is a list item 5 | indented with spaces

  • 6 |
7 | 8 |

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/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 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

Auto-links should not occur here: <http://example.com/>

16 | 17 |
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 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

Auto-links should not occur here: <http://example.com/>

16 | 17 |
or here: <http://example.com/>
18 | 
19 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Horizontal rules.html: -------------------------------------------------------------------------------- 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 | 25 |

Asterisks:

26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
***
36 | 
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
* * *
47 | 
48 | 49 |

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Natacha Porté 2 | Copyright (c) 2011, Vicent Marti 3 | 4 | Permission to use, copy, modify, and distribute this software for any 5 | purpose with or without fee is hereby granted, provided that the above 6 | copyright notice and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Horizontal rules.html: -------------------------------------------------------------------------------- 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 | 25 |

Asterisks:

26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
***
36 | 
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
* * *
47 | 
48 | 49 |

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | -------------------------------------------------------------------------------- /ext/redcarpet/redcarpet.h: -------------------------------------------------------------------------------- 1 | #ifndef REDCARPET_H__ 2 | #define REDCARPET_H__ 3 | 4 | #define RSTRING_NOT_MODIFIED 5 | #include "ruby.h" 6 | #include 7 | 8 | #ifdef HAVE_RUBY_ENCODING_H 9 | # include 10 | # define redcarpet_str_new(data, size) rb_enc_str_new(data, size, rb_utf8_encoding()) 11 | #else 12 | # define redcarpet_str_new(data, size) rb_str_new(data, size) 13 | #endif 14 | 15 | #include "markdown.h" 16 | #include "html.h" 17 | 18 | #define CSTR2SYM(s) (ID2SYM(rb_intern((s)))) 19 | 20 | extern void Init_redcarpet_rndr(); 21 | 22 | struct redcarpet_renderopt { 23 | struct html_renderopt html; 24 | VALUE self; 25 | VALUE base_class; 26 | }; 27 | 28 | struct rb_redcarpet_rndr { 29 | struct sd_callbacks callbacks; 30 | struct redcarpet_renderopt options; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Inline HTML (Simple).text: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Inline HTML (Simple).html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 | 3 |
4 | foo 5 |
6 | 7 |

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 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

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 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 | 3 |
4 | foo 5 |
6 | 7 |

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 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

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 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/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 | 33 | * * * 34 | 35 | [this] [this] should work 36 | 37 | So should [this][this]. 38 | 39 | And [this] []. 40 | 41 | And [this][]. 42 | 43 | And [this]. 44 | 45 | But not [that] []. 46 | 47 | Nor [that][]. 48 | 49 | Nor [that]. 50 | 51 | [Something in brackets like [this][] should work] 52 | 53 | [Same with [this].] 54 | 55 | In this case, [this](/somethingelse/) points to something else. 56 | 57 | Backslashing should suppress \[this] and [this\]. 58 | 59 | [this]: foo 60 | 61 | 62 | * * * 63 | 64 | Here's one where the [link 65 | breaks] across lines. 66 | 67 | Here's another where the [link 68 | breaks] across lines, but with a line-ending space. 69 | 70 | 71 | [link breaks]: /url/ 72 | -------------------------------------------------------------------------------- /lib/redcarpet.rb: -------------------------------------------------------------------------------- 1 | require 'redcarpet.so' 2 | 3 | module Redcarpet 4 | VERSION = '2.0.0b5' 5 | 6 | class Markdown 7 | attr_reader :renderer 8 | end 9 | 10 | module Render 11 | 12 | # XHTML Renderer 13 | class XHTML < HTML 14 | def initialize(extensions={}) 15 | super(extensions.merge(:xhtml => true)) 16 | end 17 | end 18 | 19 | # HTML + SmartyPants renderer 20 | class SmartyHTML < HTML 21 | include SmartyPants 22 | end 23 | 24 | # SmartyPants Mixin module 25 | # 26 | # Implements SmartyPants.postprocess, which 27 | # performs smartypants replacements on the HTML file, 28 | # once it has been fully rendered. 29 | # 30 | # To add SmartyPants postprocessing to your custom 31 | # renderers, just mixin the module `include SmartyPants` 32 | # 33 | # You can also use this as a standalone SmartyPants 34 | # implementation. 35 | # 36 | # Example: 37 | # 38 | # # Mixin 39 | # class CoolRenderer < HTML 40 | # include SmartyPants 41 | # # more code here 42 | # end 43 | # 44 | # # Standalone 45 | # Redcarpet::Render::SmartyPants.render("you're") 46 | # 47 | module SmartyPants 48 | extend self 49 | def self.render(text) 50 | postprocess text 51 | end 52 | end 53 | end 54 | end 55 | 56 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/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 | 20 |
21 | 22 |

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 |
47 | 48 |

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 | -------------------------------------------------------------------------------- /ext/redcarpet/houdini.h: -------------------------------------------------------------------------------- 1 | #ifndef HOUDINI_H__ 2 | #define HOUDINI_H__ 3 | 4 | #include "buffer.h" 5 | 6 | #ifdef HOUDINI_USE_LOCALE 7 | # define _isxdigit(c) isxdigit(c) 8 | # define _isdigit(c) isdigit(c) 9 | #else 10 | /* 11 | * Helper _isdigit methods -- do not trust the current locale 12 | * */ 13 | # define _isxdigit(c) (strchr("0123456789ABCDEFabcdef", (c)) != NULL) 14 | # define _isdigit(c) ((c) >= '0' && (c) <= '9') 15 | #endif 16 | 17 | extern void houdini_escape_html(struct buf *ob, const uint8_t *src, size_t size); 18 | extern void houdini_escape_html0(struct buf *ob, const uint8_t *src, size_t size, int secure); 19 | extern void houdini_unescape_html(struct buf *ob, const uint8_t *src, size_t size); 20 | extern void houdini_escape_xml(struct buf *ob, const uint8_t *src, size_t size); 21 | extern void houdini_escape_uri(struct buf *ob, const uint8_t *src, size_t size); 22 | extern void houdini_escape_url(struct buf *ob, const uint8_t *src, size_t size); 23 | extern void houdini_escape_href(struct buf *ob, const uint8_t *src, size_t size); 24 | extern void houdini_unescape_uri(struct buf *ob, const uint8_t *src, size_t size); 25 | extern void houdini_unescape_url(struct buf *ob, const uint8_t *src, size_t size); 26 | extern void houdini_escape_js(struct buf *ob, const uint8_t *src, size_t size); 27 | extern void houdini_unescape_js(struct buf *ob, const uint8_t *src, size_t size); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /ext/redcarpet/autolink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Vicent Marti 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef UPSKIRT_AUTOLINK_H 18 | #define UPSKIRT_AUTOLINK_H 19 | 20 | #include "buffer.h" 21 | 22 | extern int 23 | sd_autolink_issafe(const uint8_t *link, size_t link_len); 24 | 25 | extern size_t 26 | sd_autolink__www(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size); 27 | 28 | extern size_t 29 | sd_autolink__email(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size); 30 | 31 | extern size_t 32 | sd_autolink__url(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size); 33 | 34 | #endif 35 | 36 | /* vim: set filetype=c: */ 37 | -------------------------------------------------------------------------------- /ext/redcarpet/stack.c: -------------------------------------------------------------------------------- 1 | #include "stack.h" 2 | #include 3 | 4 | int 5 | stack_grow(struct stack *st, size_t new_size) 6 | { 7 | void **new_st; 8 | 9 | if (st->asize >= new_size) 10 | return 0; 11 | 12 | new_st = realloc(st->item, new_size * sizeof(void *)); 13 | if (new_st == NULL) 14 | return -1; 15 | 16 | memset(new_st + st->asize, 0x0, 17 | (new_size - st->asize) * sizeof(void *)); 18 | 19 | st->item = new_st; 20 | st->asize = new_size; 21 | 22 | if (st->size > new_size) 23 | st->size = new_size; 24 | 25 | return 0; 26 | } 27 | 28 | void 29 | stack_free(struct stack *st) 30 | { 31 | if (!st) 32 | return; 33 | 34 | free(st->item); 35 | 36 | st->item = NULL; 37 | st->size = 0; 38 | st->asize = 0; 39 | } 40 | 41 | int 42 | stack_init(struct stack *st, size_t initial_size) 43 | { 44 | st->item = NULL; 45 | st->size = 0; 46 | st->asize = 0; 47 | 48 | if (!initial_size) 49 | initial_size = 8; 50 | 51 | return stack_grow(st, initial_size); 52 | } 53 | 54 | void * 55 | stack_pop(struct stack *st) 56 | { 57 | if (!st->size) 58 | return NULL; 59 | 60 | return st->item[--st->size]; 61 | } 62 | 63 | int 64 | stack_push(struct stack *st, void *item) 65 | { 66 | if (stack_grow(st, st->size * 2) < 0) 67 | return -1; 68 | 69 | st->item[st->size++] = item; 70 | return 0; 71 | } 72 | 73 | void * 74 | stack_top(struct stack *st) 75 | { 76 | if (!st->size) 77 | return NULL; 78 | 79 | return st->item[st->size - 1]; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /redcarpet.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | Gem::Specification.new do |s| 3 | s.name = 'redcarpet' 4 | s.version = '2.0.0b5' 5 | s.summary = "Markdown that smells nice" 6 | s.description = 'A fast, safe and extensible Markdown to (X)HTML parser' 7 | s.date = '2011-09-14' 8 | s.email = 'vicent@github.com' 9 | s.homepage = 'http://github.com/tanoku/redcarpet' 10 | s.authors = ["Natacha Porté", "Vicent Martí"] 11 | # = MANIFEST = 12 | s.files = %w[ 13 | COPYING 14 | README.markdown 15 | Rakefile 16 | bin/redcarpet 17 | ext/redcarpet/autolink.c 18 | ext/redcarpet/autolink.h 19 | ext/redcarpet/buffer.c 20 | ext/redcarpet/buffer.h 21 | ext/redcarpet/extconf.rb 22 | ext/redcarpet/houdini.h 23 | ext/redcarpet/houdini_href_e.c 24 | ext/redcarpet/houdini_html_e.c 25 | ext/redcarpet/html.c 26 | ext/redcarpet/html.h 27 | ext/redcarpet/html_blocks.h 28 | ext/redcarpet/html_smartypants.c 29 | ext/redcarpet/markdown.c 30 | ext/redcarpet/markdown.h 31 | ext/redcarpet/rc_markdown.c 32 | ext/redcarpet/rc_render.c 33 | ext/redcarpet/redcarpet.h 34 | ext/redcarpet/stack.c 35 | ext/redcarpet/stack.h 36 | lib/redcarpet.rb 37 | lib/redcarpet/render_man.rb 38 | redcarpet.gemspec 39 | sundown 40 | test/redcarpet_test.rb 41 | ] 42 | # = MANIFEST = 43 | s.test_files = ["test/redcarpet_test.rb"] 44 | s.extra_rdoc_files = ["COPYING"] 45 | s.extensions = ["ext/redcarpet/extconf.rb"] 46 | s.executables = ["redcarpet"] 47 | s.require_paths = ["lib"] 48 | s.add_development_dependency "rake-compiler" 49 | end 50 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Backslash escapes.html: -------------------------------------------------------------------------------- 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 |

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: \\

73 | 74 |

Backtick: \`

75 | 76 |

Asterisk: \*

77 | 78 |

Underscore: \_

79 | 80 |

Left brace: \{

81 | 82 |

Right brace: \}

83 | 84 |

Left bracket: \[

85 | 86 |

Right bracket: \]

87 | 88 |

Left paren: \(

89 | 90 |

Right paren: \)

91 | 92 |

Greater-than: \>

93 | 94 |

Hash: \#

95 | 96 |

Period: \.

97 | 98 |

Bang: \!

99 | 100 |

Plus: \+

101 | 102 |

Minus: \-

103 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/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 | 106 | 107 | These should get escaped, even though they're matching pairs for 108 | other Markdown constructs: 109 | 110 | \*asterisks\* 111 | 112 | \_underscores\_ 113 | 114 | \`backticks\` 115 | 116 | This is a code span with a literal backslash-backtick sequence: `` \` `` 117 | 118 | This is a tag with unescaped backticks bar. 119 | 120 | This is a tag with backslashes bar. 121 | -------------------------------------------------------------------------------- /ext/redcarpet/html.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Vicent Marti 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef UPSKIRT_HTML_H 18 | #define UPSKIRT_HTML_H 19 | 20 | #include "markdown.h" 21 | #include "buffer.h" 22 | #include 23 | 24 | struct html_renderopt { 25 | struct { 26 | int header_count; 27 | int current_level; 28 | } toc_data; 29 | 30 | unsigned int flags; 31 | 32 | /* extra callbacks */ 33 | void (*link_attributes)(struct buf *ob, const struct buf *url, void *self); 34 | }; 35 | 36 | typedef enum { 37 | HTML_SKIP_HTML = (1 << 0), 38 | HTML_SKIP_STYLE = (1 << 1), 39 | HTML_SKIP_IMAGES = (1 << 2), 40 | HTML_SKIP_LINKS = (1 << 3), 41 | HTML_EXPAND_TABS = (1 << 4), 42 | HTML_SAFELINK = (1 << 5), 43 | HTML_TOC = (1 << 6), 44 | HTML_HARD_WRAP = (1 << 7), 45 | HTML_USE_XHTML = (1 << 8), 46 | } html_render_mode; 47 | 48 | typedef enum { 49 | HTML_TAG_NONE = 0, 50 | HTML_TAG_OPEN, 51 | HTML_TAG_CLOSE, 52 | } html_tag; 53 | 54 | int 55 | sdhtml_is_tag(const uint8_t *tag_data, size_t tag_size, const char *tagname); 56 | 57 | extern void 58 | sdhtml_renderer(struct sd_callbacks *callbacks, struct html_renderopt *options_ptr, unsigned int render_flags); 59 | 60 | extern void 61 | sdhtml_toc_renderer(struct sd_callbacks *callbacks, struct html_renderopt *options_ptr); 62 | 63 | extern void 64 | sdhtml_smartypants(struct buf *ob, const uint8_t *text, size_t size); 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Ordered and unordered lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

4 | 5 |
    6 |
  • asterisk 1
  • 7 |
  • asterisk 2
  • 8 |
  • asterisk 3
  • 9 |
10 | 11 |

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 |
  • asterisk 2

  • 16 |
  • asterisk 3

  • 17 |
18 | 19 |
20 | 21 |

Pluses tight:

22 | 23 |
    24 |
  • Plus 1
  • 25 |
  • Plus 2
  • 26 |
  • Plus 3
  • 27 |
28 | 29 |

Pluses loose:

30 | 31 |
    32 |
  • Plus 1

  • 33 |
  • Plus 2

  • 34 |
  • Plus 3

  • 35 |
36 | 37 |
38 | 39 |

Minuses tight:

40 | 41 |
    42 |
  • Minus 1
  • 43 |
  • Minus 2
  • 44 |
  • Minus 3
  • 45 |
46 | 47 |

Minuses loose:

48 | 49 |
    50 |
  • Minus 1

  • 51 |
  • Minus 2

  • 52 |
  • Minus 3

  • 53 |
54 | 55 |

Ordered

56 | 57 |

Tight:

58 | 59 |
    60 |
  1. First
  2. 61 |
  3. Second
  4. 62 |
  5. Third
  6. 63 |
64 | 65 |

and:

66 | 67 |
    68 |
  1. One
  2. 69 |
  3. Two
  4. 70 |
  5. Three
  6. 71 |
72 | 73 |

Loose using tabs:

74 | 75 |
    76 |
  1. First

  2. 77 |
  3. Second

  4. 78 |
  5. Third

  6. 79 |
80 | 81 |

and using spaces:

82 | 83 |
    84 |
  1. One

  2. 85 |
  3. Two

  4. 86 |
  5. Three

  6. 87 |
88 | 89 |

Multiple paragraphs:

90 | 91 |
    92 |
  1. Item 1, graf one.

    93 | 94 |

    Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.

  2. 96 |
  3. Item 2.

  4. 97 |
  5. Item 3.

  6. 98 |
99 | 100 |

Nested

101 | 102 |
    103 |
  • Tab 104 |
      105 |
    • Tab 106 |
        107 |
      • Tab
      • 108 |
    • 109 |
  • 110 |
111 | 112 |

Here's another:

113 | 114 |
    115 |
  1. First
  2. 116 |
  3. Second: 117 |
      118 |
    • Fee
    • 119 |
    • Fie
    • 120 |
    • Foe
    • 121 |
  4. 122 |
  5. Third
  6. 123 |
124 | 125 |

Same thing but with paragraphs:

126 | 127 |
    128 |
  1. First

  2. 129 |
  3. Second:

    130 | 131 |
      132 |
    • Fee
    • 133 |
    • Fie
    • 134 |
    • Foe
    • 135 |
  4. 136 |
  5. Third

  6. 137 |
138 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Backslash escapes.html: -------------------------------------------------------------------------------- 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 |

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: \\

73 | 74 |

Backtick: \`

75 | 76 |

Asterisk: \*

77 | 78 |

Underscore: \_

79 | 80 |

Left brace: \{

81 | 82 |

Right brace: \}

83 | 84 |

Left bracket: \[

85 | 86 |

Right bracket: \]

87 | 88 |

Left paren: \(

89 | 90 |

Right paren: \)

91 | 92 |

Greater-than: \>

93 | 94 |

Hash: \#

95 | 96 |

Period: \.

97 | 98 |

Bang: \!

99 | 100 |

Plus: \+

101 | 102 |

Minus: \-

103 | 104 | 105 |

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: \`

115 | 116 |

This is a tag with unescaped backticks bar.

117 | 118 |

This is a tag with backslashes bar.

119 | -------------------------------------------------------------------------------- /ext/redcarpet/houdini_html_e.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "houdini.h" 6 | 7 | #define ESCAPE_GROW_FACTOR(x) (((x) * 12) / 10) /* this is very scientific, yes */ 8 | 9 | /** 10 | * According to the OWASP rules: 11 | * 12 | * & --> & 13 | * < --> < 14 | * > --> > 15 | * " --> " 16 | * ' --> ' ' is not recommended 17 | * / --> / forward slash is included as it helps end an HTML entity 18 | * 19 | */ 20 | static const char HTML_ESCAPE_TABLE[] = { 21 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23 | 0, 0, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 4, 24 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 6, 0, 25 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37 | }; 38 | 39 | static const char *HTML_ESCAPES[] = { 40 | "", 41 | """, 42 | "&", 43 | "'", 44 | "/", 45 | "<", 46 | ">" 47 | }; 48 | 49 | void 50 | houdini_escape_html0(struct buf *ob, const uint8_t *src, size_t size, int secure) 51 | { 52 | size_t i = 0, org, esc = 0; 53 | 54 | bufgrow(ob, ESCAPE_GROW_FACTOR(size)); 55 | 56 | while (i < size) { 57 | org = i; 58 | while (i < size && (esc = HTML_ESCAPE_TABLE[src[i]]) == 0) 59 | i++; 60 | 61 | if (i > org) 62 | bufput(ob, src + org, i - org); 63 | 64 | /* escaping */ 65 | if (i >= size) 66 | break; 67 | 68 | /* The forward slash is only escaped in secure mode */ 69 | if (src[i] == '/' && !secure) { 70 | bufputc(ob, '/'); 71 | } else { 72 | bufputs(ob, HTML_ESCAPES[esc]); 73 | } 74 | 75 | i++; 76 | } 77 | } 78 | 79 | void 80 | houdini_escape_html(struct buf *ob, const uint8_t *src, size_t size) 81 | { 82 | houdini_escape_html0(ob, src, size, 1); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

4 | 5 |
    6 |
  • asterisk 1
  • 7 |
  • asterisk 2
  • 8 |
  • asterisk 3
  • 9 |
10 | 11 |

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 |
  • asterisk 2

  • 16 |
  • asterisk 3

  • 17 |
18 | 19 |
20 | 21 |

Pluses tight:

22 | 23 |
    24 |
  • Plus 1
  • 25 |
  • Plus 2
  • 26 |
  • Plus 3
  • 27 |
28 | 29 |

Pluses loose:

30 | 31 |
    32 |
  • Plus 1

  • 33 |
  • Plus 2

  • 34 |
  • Plus 3

  • 35 |
36 | 37 |
38 | 39 |

Minuses tight:

40 | 41 |
    42 |
  • Minus 1
  • 43 |
  • Minus 2
  • 44 |
  • Minus 3
  • 45 |
46 | 47 |

Minuses loose:

48 | 49 |
    50 |
  • Minus 1

  • 51 |
  • Minus 2

  • 52 |
  • Minus 3

  • 53 |
54 | 55 |

Ordered

56 | 57 |

Tight:

58 | 59 |
    60 |
  1. First
  2. 61 |
  3. Second
  4. 62 |
  5. Third
  6. 63 |
64 | 65 |

and:

66 | 67 |
    68 |
  1. One
  2. 69 |
  3. Two
  4. 70 |
  5. Three
  6. 71 |
72 | 73 |

Loose using tabs:

74 | 75 |
    76 |
  1. First

  2. 77 |
  3. Second

  4. 78 |
  5. Third

  6. 79 |
80 | 81 |

and using spaces:

82 | 83 |
    84 |
  1. One

  2. 85 |
  3. Two

  4. 86 |
  5. Three

  6. 87 |
88 | 89 |

Multiple paragraphs:

90 | 91 |
    92 |
  1. Item 1, graf one.

    93 | 94 |

    Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.

  2. 96 |
  3. Item 2.

  4. 97 |
  5. Item 3.

  6. 98 |
99 | 100 |

Nested

101 | 102 |
    103 |
  • Tab 104 |
      105 |
    • Tab 106 |
        107 |
      • Tab
      • 108 |
    • 109 |
  • 110 |
111 | 112 |

Here's another:

113 | 114 |
    115 |
  1. First
  2. 116 |
  3. Second: 117 |
      118 |
    • Fee
    • 119 |
    • Fie
    • 120 |
    • Foe
    • 121 |
  4. 122 |
  5. Third
  6. 123 |
124 | 125 |

Same thing but with paragraphs:

126 | 127 |
    128 |
  1. First

  2. 129 |
  3. Second:

    130 | 131 |
      132 |
    • Fee
    • 133 |
    • Fie
    • 134 |
    • Foe
    • 135 |
  4. 136 |
  5. Third

  6. 137 |
138 | 139 | 140 |

This was an error in Markdown 1.0.1:

141 | 142 |
    143 |
  • this

    144 | 145 |
    • sub
    146 | 147 |

    that

  • 148 |
149 | -------------------------------------------------------------------------------- /ext/redcarpet/buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, Natacha Porté 3 | * Copyright (c) 2011, Vicent Martí 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #ifndef BUFFER_H__ 19 | #define BUFFER_H__ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #if defined(_MSC_VER) 26 | #define __attribute__(x) 27 | #define inline 28 | #endif 29 | 30 | typedef enum { 31 | BUF_OK = 0, 32 | BUF_ENOMEM = -1, 33 | } buferror_t; 34 | 35 | /* struct buf: character array buffer */ 36 | struct buf { 37 | uint8_t *data; /* actual character data */ 38 | size_t size; /* size of the string */ 39 | size_t asize; /* allocated size (0 = volatile buffer) */ 40 | size_t unit; /* reallocation unit size (0 = read-only buffer) */ 41 | }; 42 | 43 | /* CONST_BUF: global buffer from a string litteral */ 44 | #define BUF_STATIC(string) \ 45 | { (uint8_t *)string, sizeof string -1, sizeof string, 0, 0 } 46 | 47 | /* VOLATILE_BUF: macro for creating a volatile buffer on the stack */ 48 | #define BUF_VOLATILE(strname) \ 49 | { (uint8_t *)strname, strlen(strname), 0, 0, 0 } 50 | 51 | /* BUFPUTSL: optimized bufputs of a string litteral */ 52 | #define BUFPUTSL(output, literal) \ 53 | bufput(output, literal, sizeof literal - 1) 54 | 55 | /* bufgrow: increasing the allocated size to the given value */ 56 | int bufgrow(struct buf *, size_t); 57 | 58 | /* bufnew: allocation of a new buffer */ 59 | struct buf *bufnew(size_t) __attribute__ ((malloc)); 60 | 61 | /* bufnullterm: NUL-termination of the string array (making a C-string) */ 62 | const char *bufcstr(struct buf *); 63 | 64 | /* bufprefix: compare the beginning of a buffer with a string */ 65 | int bufprefix(const struct buf *buf, const char *prefix); 66 | 67 | /* bufput: appends raw data to a buffer */ 68 | void bufput(struct buf *, const void *, size_t); 69 | 70 | /* bufputs: appends a NUL-terminated string to a buffer */ 71 | void bufputs(struct buf *, const char *); 72 | 73 | /* bufputc: appends a single char to a buffer */ 74 | void bufputc(struct buf *, int); 75 | 76 | /* bufrelease: decrease the reference count and free the buffer if needed */ 77 | void bufrelease(struct buf *); 78 | 79 | /* bufreset: frees internal data of the buffer */ 80 | void bufreset(struct buf *); 81 | 82 | /* bufslurp: removes a given number of bytes from the head of the array */ 83 | void bufslurp(struct buf *, size_t); 84 | 85 | /* bufprintf: formatted printing to a buffer */ 86 | void bufprintf(struct buf *, const char *, ...) __attribute__ ((format (printf, 2, 3))); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /ext/redcarpet/houdini_href_e.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "houdini.h" 6 | 7 | #define ESCAPE_GROW_FACTOR(x) (((x) * 12) / 10) 8 | 9 | /* 10 | * The following characters will not be escaped: 11 | * 12 | * -_.+!*'(),%#@?=;:/,+&$ alphanum 13 | * 14 | * Note that this character set is the addition of: 15 | * 16 | * - The characters which are safe to be in an URL 17 | * - The characters which are *not* safe to be in 18 | * an URL because they are RESERVED characters. 19 | * 20 | * We asume (lazily) that any RESERVED char that 21 | * appears inside an URL is actually meant to 22 | * have its native function (i.e. as an URL 23 | * component/separator) and hence needs no escaping. 24 | * 25 | * There are two exceptions: the chacters & (amp) 26 | * and ' (single quote) do not appear in the table. 27 | * They are meant to appear in the URL as components, 28 | * yet they require special HTML-entity escaping 29 | * to generate valid HTML markup. 30 | * 31 | * All other characters will be escaped to %XX. 32 | * 33 | */ 34 | static const char HREF_SAFE[] = { 35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37 | 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 38 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 39 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 40 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 41 | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 42 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 43 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51 | }; 52 | 53 | void 54 | houdini_escape_href(struct buf *ob, const uint8_t *src, size_t size) 55 | { 56 | static const char hex_chars[] = "0123456789ABCDEF"; 57 | size_t i = 0, org; 58 | char hex_str[3]; 59 | 60 | bufgrow(ob, ESCAPE_GROW_FACTOR(size)); 61 | hex_str[0] = '%'; 62 | 63 | while (i < size) { 64 | org = i; 65 | while (i < size && HREF_SAFE[src[i]] != 0) 66 | i++; 67 | 68 | if (i > org) 69 | bufput(ob, src + org, i - org); 70 | 71 | /* escaping */ 72 | if (i >= size) 73 | break; 74 | 75 | switch (src[i]) { 76 | /* amp appears all the time in URLs, but needs 77 | * HTML-entity escaping to be inside an href */ 78 | case '&': 79 | BUFPUTSL(ob, "&"); 80 | break; 81 | 82 | /* the single quote is a valid URL character 83 | * according to the standard; it needs HTML 84 | * entity escaping too */ 85 | case '\'': 86 | BUFPUTSL(ob, "'"); 87 | break; 88 | 89 | /* the space can be escaped to %20 or a plus 90 | * sign. we're going with the generic escape 91 | * for now. the plus thing is more commonly seen 92 | * when building GET strings */ 93 | #if 0 94 | case ' ': 95 | bufputc(ob, '+'); 96 | break; 97 | #endif 98 | 99 | /* every other character goes with a %XX escaping */ 100 | default: 101 | hex_str[1] = hex_chars[(src[i] >> 4) & 0xF]; 102 | hex_str[2] = hex_chars[src[i] & 0xF]; 103 | bufput(ob, hex_str, 3); 104 | } 105 | 106 | i++; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/MarkdownTest.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # MarkdownTester -- Run tests for Markdown implementations 5 | # 6 | # Copyright (c) 2004 John Gruber 7 | # 8 | # 9 | 10 | use strict; 11 | use warnings; 12 | use Getopt::Long; 13 | use Benchmark; 14 | 15 | our $VERSION = '1.0'; 16 | # Mon 13 Dec 2004 17 | 18 | my $time_start = new Benchmark; 19 | my $test_dir = "Tests"; 20 | my $script = "./Markdown.pl"; 21 | my $use_tidy = 0; 22 | my ($flag_version); 23 | 24 | GetOptions ( 25 | "script=s" => \$script, 26 | "testdir=s" => \$test_dir, 27 | "tidy" => \$use_tidy, 28 | "version" => \$flag_version, 29 | ); 30 | 31 | if($flag_version) { 32 | my $progname = $0; 33 | $progname =~ s{.*/}{}; 34 | die "$progname version $VERSION\n"; 35 | } 36 | 37 | unless (-d $test_dir) { die "'$test_dir' is not a directory.\n"; } 38 | unless (-f $script) { die "$script does not exist.\n"; } 39 | unless (-x $script) { die "$script is not executable.\n"; } 40 | 41 | my $tests_passed = 0; 42 | my $tests_failed = 0; 43 | 44 | foreach my $testfile (glob "$test_dir/*.text") { 45 | my $testname = $testfile; 46 | $testname =~ s{.*/(.+)\.text$}{$1}i; 47 | print "$testname ... "; 48 | 49 | # Look for a corresponding .html file for each .text file: 50 | my $resultfile = $testfile; 51 | $resultfile =~ s{\.text$}{\.html}i; 52 | unless (-f $resultfile) {die "'$resultfile' does not exist.\n";} 53 | 54 | # open(TEST, $testfile) || die("Can't open testfile: $!"); 55 | open(RESULT, $resultfile) || die("Can't open resultfile: $!"); 56 | undef $/; 57 | # my $t_input = ; 58 | my $t_result = ; 59 | 60 | my $t_output = `$script '$testfile'`; 61 | 62 | # Normalize the output and expected result strings: 63 | $t_result =~ s/\s+\z//; # trim trailing whitespace 64 | $t_output =~ s/\s+\z//; # trim trailing whitespace 65 | if ($use_tidy) { 66 | # Escape the strings, pass them through to CLI tidy tool for tag-level equivalency 67 | $t_result =~ s{'}{'\\''}g; # escape ' chars for shell 68 | $t_output =~ s{'}{'\\''}g; 69 | $t_result = `echo '$t_result' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`; 70 | $t_output = `echo '$t_output' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`; 71 | } 72 | 73 | if ($t_output eq $t_result) { 74 | print "OK\n"; 75 | $tests_passed++; 76 | } 77 | else { 78 | print "FAILED\n\n"; 79 | $tests_failed++; 80 | } 81 | } 82 | 83 | print "\n\n"; 84 | print "$tests_passed passed; $tests_failed failed.\n"; 85 | 86 | my $time_end = new Benchmark; 87 | my $time_diff = timediff($time_end, $time_start); 88 | print "Benchmark: ", timestr($time_diff), "\n"; 89 | 90 | 91 | __END__ 92 | 93 | =pod 94 | 95 | =head1 NAME 96 | 97 | B 98 | 99 | 100 | =head1 SYNOPSIS 101 | 102 | B [ B<--options> ] [ I ... ] 103 | 104 | 105 | =head1 DESCRIPTION 106 | 107 | 108 | =head1 OPTIONS 109 | 110 | Use "--" to end switch parsing. For example, to open a file named "-z", use: 111 | 112 | MarkdownTest.pl -- -z 113 | 114 | =over 4 115 | 116 | =item B<--script> 117 | 118 | Specify the path to the Markdown script to test. Defaults to 119 | "./Markdown.pl". Example: 120 | 121 | ./MarkdownTest.pl --script ./PHP-Markdown/php-markdown 122 | 123 | =item B<--testdir> 124 | 125 | Specify the path to a directory containing test data. Defaults to "Tests". 126 | 127 | =item B<--tidy> 128 | 129 | Flag to turn on using the command line 'tidy' tool to normalize HTML 130 | output before comparing script output to the expected test result. 131 | Assumes that the 'tidy' command is available in your PATH. Defaults to 132 | off. 133 | 134 | =back 135 | 136 | 137 | 138 | =head1 BUGS 139 | 140 | 141 | 142 | =head1 VERSION HISTORY 143 | 144 | 1.0 Mon 13 Dec 2004 145 | 146 | 147 | 148 | =head1 COPYRIGHT AND LICENSE 149 | 150 | Copyright (c) 2004 John Gruber 151 | 152 | All rights reserved. 153 | 154 | This is free software; you may redistribute it and/or modify it under 155 | the same terms as Perl itself. 156 | 157 | =cut 158 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'date' 2 | require 'rake/clean' 3 | require 'rake/extensiontask' 4 | require 'digest/md5' 5 | 6 | task :default => :test 7 | 8 | # ========================================================== 9 | # Ruby Extension 10 | # ========================================================== 11 | 12 | Rake::ExtensionTask.new('redcarpet') 13 | 14 | # ========================================================== 15 | # Testing 16 | # ========================================================== 17 | 18 | require 'rake/testtask' 19 | Rake::TestTask.new('test:unit') do |t| 20 | t.test_files = FileList['test/*_test.rb'] 21 | t.ruby_opts += ['-rubygems'] if defined? Gem 22 | end 23 | task 'test:unit' => [:compile] 24 | 25 | desc 'Run conformance tests (MARKDOWN_TEST_VER=1.0)' 26 | task 'test:conformance' => [:compile] do |t| 27 | script = "#{pwd}/bin/redcarpet" 28 | test_version = ENV['MARKDOWN_TEST_VER'] || '1.0.3' 29 | lib_dir = "#{pwd}/lib" 30 | chdir("test/MarkdownTest_#{test_version}") do 31 | sh "RUBYLIB=#{lib_dir} ./MarkdownTest.pl --script='#{script}' --tidy" 32 | end 33 | end 34 | 35 | desc 'Run version 1.0 conformance suite' 36 | task 'test:conformance:1.0' => [:compile] do |t| 37 | ENV['MARKDOWN_TEST_VER'] = '1.0' 38 | Rake::Task['test:conformance'].invoke 39 | end 40 | 41 | desc 'Run 1.0.3 conformance suite' 42 | task 'test:conformance:1.0.3' => [:compile] do |t| 43 | ENV['MARKDOWN_TEST_VER'] = '1.0.3' 44 | Rake::Task['test:conformance'].invoke 45 | end 46 | 47 | desc 'Run unit and conformance tests' 48 | task :test => %w[test:unit test:conformance] 49 | 50 | desc 'Run benchmarks' 51 | task :benchmark => :build do |t| 52 | $:.unshift 'lib' 53 | load 'test/benchmark.rb' 54 | end 55 | 56 | # PACKAGING ================================================================= 57 | 58 | require 'rubygems' 59 | $spec = eval(File.read('redcarpet.gemspec')) 60 | 61 | def package(ext='') 62 | "pkg/redcarpet-#{$spec.version}" + ext 63 | end 64 | 65 | desc 'Build packages' 66 | task :package => %w[.gem .tar.gz].map {|e| package(e)} 67 | 68 | desc 'Build and install as local gem' 69 | task :install => package('.gem') do 70 | sh "gem install #{package('.gem')}" 71 | end 72 | 73 | directory 'pkg/' 74 | 75 | file package('.gem') => %w[pkg/ redcarpet.gemspec] + $spec.files do |f| 76 | sh "gem build redcarpet.gemspec" 77 | mv File.basename(f.name), f.name 78 | end 79 | 80 | file package('.tar.gz') => %w[pkg/] + $spec.files do |f| 81 | sh "git archive --format=tar HEAD | gzip > #{f.name}" 82 | end 83 | 84 | # GEMSPEC HELPERS ========================================================== 85 | 86 | def source_version 87 | line = File.read('lib/redcarpet.rb')[/^\s*VERSION = .*/] 88 | line.match(/.*VERSION = '(.*)'/)[1] 89 | end 90 | 91 | task :update_gem do 92 | # read spec file and split out manifest section 93 | GEMFILE = 'redcarpet.gemspec' 94 | spec = File.read(GEMFILE) 95 | head, manifest, tail = spec.split(" # = MANIFEST =\n") 96 | head.sub!(/\.version = '.*'/, ".version = '#{source_version}'") 97 | head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'") 98 | # determine file list from git ls-files 99 | files = `git ls-files`. 100 | split("\n"). 101 | sort. 102 | reject{ |file| file =~ /^\./ || file =~ /^test\/MarkdownTest/ }. 103 | map{ |file| " #{file}" }. 104 | join("\n") 105 | # piece file back together and write... 106 | manifest = " s.files = %w[\n#{files}\n ]\n" 107 | spec = [head,manifest,tail].join(" # = MANIFEST =\n") 108 | File.open(GEMFILE, 'w') { |io| io.write(spec) } 109 | puts "updated #{GEMFILE}" 110 | end 111 | 112 | desc 'Gather required Sundown sources into extension directory' 113 | task :gather => 'sundown/src/markdown.h' do |t| 114 | files = 115 | FileList[ 116 | 'sundown/src/{markdown,buffer,stack,autolink,html_blocks}.h', 117 | 'sundown/src/{markdown,buffer,stack,autolink}.c', 118 | 'sundown/html/{html,html_smartypants,houdini_html_e,houdini_href_e}.c', 119 | 'sundown/html/{html,houdini}.h', 120 | ] 121 | cp files, 'ext/redcarpet/', 122 | :preserve => true, 123 | :verbose => true 124 | end 125 | 126 | file 'sundown/src/markdown.h' do |t| 127 | abort "The Sundown submodule is required." 128 | end 129 | 130 | 131 | -------------------------------------------------------------------------------- /ext/redcarpet/rc_markdown.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Vicent Marti 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | #include "redcarpet.h" 17 | 18 | VALUE rb_mRedcarpet; 19 | VALUE rb_cMarkdown; 20 | 21 | extern VALUE rb_cRenderBase; 22 | 23 | static void rb_redcarpet_md_flags(VALUE hash, unsigned int *enabled_extensions_p) 24 | { 25 | unsigned int extensions = 0; 26 | 27 | /** 28 | * Markdown extensions -- all disabled by default 29 | */ 30 | if (rb_hash_lookup(hash, CSTR2SYM("no_intra_emphasis")) == Qtrue) 31 | extensions |= MKDEXT_NO_INTRA_EMPHASIS; 32 | 33 | if (rb_hash_lookup(hash, CSTR2SYM("tables")) == Qtrue) 34 | extensions |= MKDEXT_TABLES; 35 | 36 | if (rb_hash_lookup(hash, CSTR2SYM("fenced_code_blocks")) == Qtrue) 37 | extensions |= MKDEXT_FENCED_CODE; 38 | 39 | if (rb_hash_lookup(hash, CSTR2SYM("autolink")) == Qtrue) 40 | extensions |= MKDEXT_AUTOLINK; 41 | 42 | if (rb_hash_lookup(hash, CSTR2SYM("strikethrough")) == Qtrue) 43 | extensions |= MKDEXT_STRIKETHROUGH; 44 | 45 | if (rb_hash_lookup(hash, CSTR2SYM("lax_html_blocks")) == Qtrue) 46 | extensions |= MKDEXT_LAX_HTML_BLOCKS; 47 | 48 | if (rb_hash_lookup(hash, CSTR2SYM("space_after_headers")) == Qtrue) 49 | extensions |= MKDEXT_SPACE_HEADERS; 50 | 51 | if (rb_hash_lookup(hash, CSTR2SYM("superscript")) == Qtrue) 52 | extensions |= MKDEXT_SUPERSCRIPT; 53 | 54 | *enabled_extensions_p = extensions; 55 | } 56 | 57 | static void 58 | rb_redcarpet_md__free(void *markdown) 59 | { 60 | sd_markdown_free((struct sd_markdown *)markdown); 61 | } 62 | 63 | static VALUE rb_redcarpet_md__new(int argc, VALUE *argv, VALUE klass) 64 | { 65 | VALUE rb_markdown, rb_rndr, hash; 66 | unsigned int extensions = 0; 67 | 68 | struct rb_redcarpet_rndr *rndr; 69 | struct sd_markdown *markdown; 70 | 71 | if (rb_scan_args(argc, argv, "11", &rb_rndr, &hash) == 2) 72 | rb_redcarpet_md_flags(hash, &extensions); 73 | 74 | if (rb_obj_is_kind_of(rb_rndr, rb_cClass)) 75 | rb_rndr = rb_funcall(rb_rndr, rb_intern("new"), 0); 76 | 77 | if (!rb_obj_is_kind_of(rb_rndr, rb_cRenderBase)) 78 | rb_raise(rb_eTypeError, "Invalid Renderer instance given"); 79 | 80 | Data_Get_Struct(rb_rndr, struct rb_redcarpet_rndr, rndr); 81 | 82 | markdown = sd_markdown_new(extensions, 16, &rndr->callbacks, &rndr->options); 83 | if (!markdown) 84 | rb_raise(rb_eRuntimeError, "Failed to create new Renderer class"); 85 | 86 | rb_markdown = Data_Wrap_Struct(klass, NULL, rb_redcarpet_md__free, markdown); 87 | rb_iv_set(rb_markdown, "@renderer", rb_rndr); 88 | 89 | return rb_markdown; 90 | } 91 | 92 | static VALUE rb_redcarpet_md_render(VALUE self, VALUE text) 93 | { 94 | VALUE rb_rndr; 95 | struct buf *output_buf; 96 | struct sd_markdown *markdown; 97 | 98 | Check_Type(text, T_STRING); 99 | 100 | rb_rndr = rb_iv_get(self, "@renderer"); 101 | Data_Get_Struct(self, struct sd_markdown, markdown); 102 | 103 | if (rb_respond_to(rb_rndr, rb_intern("preprocess"))) 104 | text = rb_funcall(rb_rndr, rb_intern("preprocess"), 1, text); 105 | 106 | /* initialize buffers */ 107 | output_buf = bufnew(128); 108 | 109 | /* render the magic */ 110 | sd_markdown_render( 111 | output_buf, 112 | RSTRING_PTR(text), 113 | RSTRING_LEN(text), 114 | markdown); 115 | 116 | /* build the Ruby string */ 117 | text = redcarpet_str_new(output_buf->data, output_buf->size); 118 | 119 | bufrelease(output_buf); 120 | 121 | if (rb_respond_to(rb_rndr, rb_intern("postprocess"))) 122 | text = rb_funcall(rb_rndr, rb_intern("postprocess"), 1, text); 123 | 124 | return text; 125 | } 126 | 127 | void Init_redcarpet() 128 | { 129 | rb_mRedcarpet = rb_define_module("Redcarpet"); 130 | 131 | rb_cMarkdown = rb_define_class_under(rb_mRedcarpet, "Markdown", rb_cObject); 132 | rb_define_singleton_method(rb_cMarkdown, "new", rb_redcarpet_md__new, -1); 133 | rb_define_method(rb_cMarkdown, "render", rb_redcarpet_md_render, 1); 134 | 135 | Init_redcarpet_rndr(); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/MarkdownTest.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # MarkdownTester -- Run tests for Markdown implementations 5 | # 6 | # Copyright (c) 2004-2005 John Gruber 7 | # 8 | # 9 | 10 | use strict; 11 | use warnings; 12 | use Getopt::Long; 13 | use Benchmark; 14 | 15 | our $VERSION = '1.0.2'; 16 | # Sat 24 Dec 2005 17 | 18 | my $time_start = new Benchmark; 19 | my $test_dir = "Tests"; 20 | my $script = "./Markdown.pl"; 21 | my $use_tidy = 0; 22 | my ($flag_version); 23 | 24 | GetOptions ( 25 | "script=s" => \$script, 26 | "testdir=s" => \$test_dir, 27 | "tidy" => \$use_tidy, 28 | "version" => \$flag_version, 29 | ); 30 | 31 | if($flag_version) { 32 | my $progname = $0; 33 | $progname =~ s{.*/}{}; 34 | die "$progname version $VERSION\n"; 35 | } 36 | 37 | unless (-d $test_dir) { die "'$test_dir' is not a directory.\n"; } 38 | unless (-f $script) { die "$script does not exist.\n"; } 39 | unless (-x $script) { die "$script is not executable.\n"; } 40 | 41 | my $tests_passed = 0; 42 | my $tests_failed = 0; 43 | 44 | TEST: 45 | foreach my $testfile (glob "$test_dir/*.text") { 46 | my $testname = $testfile; 47 | $testname =~ s{.*/(.+)\.text$}{$1}i; 48 | print "$testname ... "; 49 | 50 | # Look for a corresponding .html file for each .text file: 51 | my $resultfile = $testfile; 52 | $resultfile =~ s{\.text$}{\.html}i; 53 | unless (-f $resultfile) { 54 | print "'$resultfile' does not exist.\n\n"; 55 | next TEST; 56 | } 57 | 58 | # open(TEST, $testfile) || die("Can't open testfile: $!"); 59 | open(RESULT, $resultfile) || die("Can't open resultfile: $!"); 60 | undef $/; 61 | # my $t_input = ; 62 | my $t_result = ; 63 | 64 | my $t_output = `'$script' '$testfile'`; 65 | 66 | # Normalize the output and expected result strings: 67 | $t_result =~ s/\s+\z//; # trim trailing whitespace 68 | $t_output =~ s/\s+\z//; # trim trailing whitespace 69 | if ($use_tidy) { 70 | # Escape the strings, pass them through to CLI tidy tool for tag-level equivalency 71 | $t_result =~ s{'}{'\\''}g; # escape ' chars for shell 72 | $t_output =~ s{'}{'\\''}g; 73 | $t_result = `echo '$t_result' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`; 74 | $t_output = `echo '$t_output' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`; 75 | } 76 | 77 | if ($t_output eq $t_result) { 78 | print "OK\n"; 79 | $tests_passed++; 80 | } 81 | else { 82 | print "FAILED\n\n"; 83 | # This part added by JM to print diffs 84 | open(OUT, '>tmp1') or die $!; 85 | print OUT $t_output or die $!; 86 | open(RES, '>tmp2') or die $!; 87 | print RES $t_result or die $!; 88 | print `diff tmp1 tmp2`; 89 | close RES; 90 | close OUT; 91 | print "\n"; 92 | `rm tmp?`; 93 | # End of added part 94 | $tests_failed++; 95 | } 96 | } 97 | 98 | print "\n\n"; 99 | print "$tests_passed passed; $tests_failed failed.\n"; 100 | 101 | my $time_end = new Benchmark; 102 | my $time_diff = timediff($time_end, $time_start); 103 | print "Benchmark: ", timestr($time_diff), "\n"; 104 | 105 | 106 | __END__ 107 | 108 | =pod 109 | 110 | =head1 NAME 111 | 112 | B 113 | 114 | 115 | =head1 SYNOPSIS 116 | 117 | B [ B<--options> ] [ I ... ] 118 | 119 | 120 | =head1 DESCRIPTION 121 | 122 | 123 | =head1 OPTIONS 124 | 125 | Use "--" to end switch parsing. For example, to open a file named "-z", use: 126 | 127 | MarkdownTest.pl -- -z 128 | 129 | =over 4 130 | 131 | =item B<--script> 132 | 133 | Specify the path to the Markdown script to test. Defaults to 134 | "./Markdown.pl". Example: 135 | 136 | ./MarkdownTest.pl --script ./PHP-Markdown/php-markdown 137 | 138 | =item B<--testdir> 139 | 140 | Specify the path to a directory containing test data. Defaults to "Tests". 141 | 142 | =item B<--tidy> 143 | 144 | Flag to turn on using the command line 'tidy' tool to normalize HTML 145 | output before comparing script output to the expected test result. 146 | Assumes that the 'tidy' command is available in your PATH. Defaults to 147 | off. 148 | 149 | =back 150 | 151 | 152 | 153 | =head1 BUGS 154 | 155 | 156 | 157 | =head1 VERSION HISTORY 158 | 159 | 1.0 Mon 13 Dec 2004-2005 160 | 161 | 1.0.1 Mon 19 Sep 2005 162 | 163 | + Better handling of case when foo.text exists, but foo.html doesn't. 164 | It now prints a message and moves on, rather than dying. 165 | 166 | 167 | =head1 COPYRIGHT AND LICENSE 168 | 169 | Copyright (c) 2004-2005 John Gruber 170 | 171 | All rights reserved. 172 | 173 | This is free software; you may redistribute it and/or modify it under 174 | the same terms as Perl itself. 175 | 176 | =cut 177 | -------------------------------------------------------------------------------- /ext/redcarpet/markdown.h: -------------------------------------------------------------------------------- 1 | /* markdown.h - generic markdown parser */ 2 | 3 | /* 4 | * Copyright (c) 2009, Natacha Porté 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef UPSKIRT_MARKDOWN_H 20 | #define UPSKIRT_MARKDOWN_H 21 | 22 | #include "buffer.h" 23 | #include "autolink.h" 24 | 25 | #define UPSKIRT_VERSION "1.15.2" 26 | #define UPSKIRT_VER_MAJOR 1 27 | #define UPSKIRT_VER_MINOR 15 28 | #define UPSKIRT_VER_REVISION 2 29 | 30 | /******************** 31 | * TYPE DEFINITIONS * 32 | ********************/ 33 | 34 | /* mkd_autolink - type of autolink */ 35 | enum mkd_autolink { 36 | MKDA_NOT_AUTOLINK, /* used internally when it is not an autolink*/ 37 | MKDA_NORMAL, /* normal http/http/ftp/mailto/etc link */ 38 | MKDA_EMAIL, /* e-mail link without explit mailto: */ 39 | }; 40 | 41 | enum mkd_tableflags { 42 | MKD_TABLE_ALIGN_L = 1, 43 | MKD_TABLE_ALIGN_R = 2, 44 | MKD_TABLE_ALIGN_CENTER = 3, 45 | MKD_TABLE_ALIGNMASK = 3, 46 | MKD_TABLE_HEADER = 4 47 | }; 48 | 49 | enum mkd_extensions { 50 | MKDEXT_NO_INTRA_EMPHASIS = (1 << 0), 51 | MKDEXT_TABLES = (1 << 1), 52 | MKDEXT_FENCED_CODE = (1 << 2), 53 | MKDEXT_AUTOLINK = (1 << 3), 54 | MKDEXT_STRIKETHROUGH = (1 << 4), 55 | MKDEXT_LAX_HTML_BLOCKS = (1 << 5), 56 | MKDEXT_SPACE_HEADERS = (1 << 6), 57 | MKDEXT_SUPERSCRIPT = (1 << 7), 58 | }; 59 | 60 | /* sd_callbacks - functions for rendering parsed data */ 61 | struct sd_callbacks { 62 | /* block level callbacks - NULL skips the block */ 63 | void (*blockcode)(struct buf *ob, const struct buf *text, const struct buf *lang, void *opaque); 64 | void (*blockquote)(struct buf *ob, const struct buf *text, void *opaque); 65 | void (*blockhtml)(struct buf *ob,const struct buf *text, void *opaque); 66 | void (*header)(struct buf *ob, const struct buf *text, int level, void *opaque); 67 | void (*hrule)(struct buf *ob, void *opaque); 68 | void (*list)(struct buf *ob, const struct buf *text, int flags, void *opaque); 69 | void (*listitem)(struct buf *ob, const struct buf *text, int flags, void *opaque); 70 | void (*paragraph)(struct buf *ob, const struct buf *text, void *opaque); 71 | void (*table)(struct buf *ob, const struct buf *header, const struct buf *body, void *opaque); 72 | void (*table_row)(struct buf *ob, const struct buf *text, void *opaque); 73 | void (*table_cell)(struct buf *ob, const struct buf *text, int flags, void *opaque); 74 | 75 | 76 | /* span level callbacks - NULL or return 0 prints the span verbatim */ 77 | int (*autolink)(struct buf *ob, const struct buf *link, enum mkd_autolink type, void *opaque); 78 | int (*codespan)(struct buf *ob, const struct buf *text, void *opaque); 79 | int (*double_emphasis)(struct buf *ob, const struct buf *text, void *opaque); 80 | int (*emphasis)(struct buf *ob, const struct buf *text, void *opaque); 81 | int (*image)(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *alt, void *opaque); 82 | int (*linebreak)(struct buf *ob, void *opaque); 83 | int (*link)(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *content, void *opaque); 84 | int (*raw_html_tag)(struct buf *ob, const struct buf *tag, void *opaque); 85 | int (*triple_emphasis)(struct buf *ob, const struct buf *text, void *opaque); 86 | int (*strikethrough)(struct buf *ob, const struct buf *text, void *opaque); 87 | int (*superscript)(struct buf *ob, const struct buf *text, void *opaque); 88 | 89 | /* low level callbacks - NULL copies input directly into the output */ 90 | void (*entity)(struct buf *ob, const struct buf *entity, void *opaque); 91 | void (*normal_text)(struct buf *ob, const struct buf *text, void *opaque); 92 | 93 | /* header and footer */ 94 | void (*doc_header)(struct buf *ob, void *opaque); 95 | void (*doc_footer)(struct buf *ob, void *opaque); 96 | }; 97 | 98 | struct sd_markdown; 99 | 100 | /********* 101 | * FLAGS * 102 | *********/ 103 | 104 | /* list/listitem flags */ 105 | #define MKD_LIST_ORDERED 1 106 | #define MKD_LI_BLOCK 2 /*
  • containing block data */ 107 | 108 | /********************** 109 | * EXPORTED FUNCTIONS * 110 | **********************/ 111 | 112 | extern struct sd_markdown * 113 | sd_markdown_new( 114 | unsigned int extensions, 115 | size_t max_nesting, 116 | const struct sd_callbacks *callbacks, 117 | void *opaque); 118 | 119 | extern void 120 | sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, struct sd_markdown *md); 121 | 122 | extern void 123 | sd_markdown_free(struct sd_markdown *md); 124 | 125 | extern void 126 | sd_version(int *major, int *minor, int *revision); 127 | 128 | #endif 129 | 130 | /* vim: set filetype=c: */ 131 | -------------------------------------------------------------------------------- /ext/redcarpet/buffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, Natacha Porté 3 | * Copyright (c) 2011, Vicent Martí 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #define BUFFER_MAX_ALLOC_SIZE (1024 * 1024 * 16) //16mb 19 | 20 | #include "buffer.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | /* MSVC compat */ 27 | #if defined(_MSC_VER) 28 | # define _buf_vsnprintf _vsnprintf 29 | #else 30 | # define _buf_vsnprintf vsnprintf 31 | #endif 32 | 33 | int 34 | bufprefix(const struct buf *buf, const char *prefix) 35 | { 36 | size_t i; 37 | 38 | for (i = 0; i < buf->size; ++i) { 39 | if (prefix[i] == 0) 40 | return 0; 41 | 42 | if (buf->data[i] != prefix[i]) 43 | return buf->data[i] - prefix[i]; 44 | } 45 | 46 | return 0; 47 | } 48 | 49 | /* bufgrow: increasing the allocated size to the given value */ 50 | int 51 | bufgrow(struct buf *buf, size_t neosz) 52 | { 53 | size_t neoasz; 54 | void *neodata; 55 | if (!buf || !buf->unit || neosz > BUFFER_MAX_ALLOC_SIZE) 56 | return BUF_ENOMEM; 57 | 58 | if (buf->asize >= neosz) 59 | return BUF_OK; 60 | 61 | neoasz = buf->asize + buf->unit; 62 | while (neoasz < neosz) 63 | neoasz += buf->unit; 64 | 65 | neodata = realloc(buf->data, neoasz); 66 | if (!neodata) 67 | return BUF_ENOMEM; 68 | 69 | buf->data = neodata; 70 | buf->asize = neoasz; 71 | return BUF_OK; 72 | } 73 | 74 | 75 | /* bufnew: allocation of a new buffer */ 76 | struct buf * 77 | bufnew(size_t unit) 78 | { 79 | struct buf *ret; 80 | ret = malloc(sizeof (struct buf)); 81 | 82 | if (ret) { 83 | ret->data = 0; 84 | ret->size = ret->asize = 0; 85 | ret->unit = unit; 86 | } 87 | return ret; 88 | } 89 | 90 | /* bufnullterm: NULL-termination of the string array */ 91 | const char * 92 | bufcstr(struct buf *buf) 93 | { 94 | if (!buf || !buf->unit) 95 | return NULL; 96 | 97 | if (buf->size < buf->asize && buf->data[buf->size] == 0) 98 | return (char *)buf->data; 99 | 100 | if (buf->size + 1 <= buf->asize || bufgrow(buf, buf->size + 1) == 0) { 101 | buf->data[buf->size] = 0; 102 | return (char *)buf->data; 103 | } 104 | 105 | return NULL; 106 | } 107 | 108 | /* bufprintf: formatted printing to a buffer */ 109 | void 110 | bufprintf(struct buf *buf, const char *fmt, ...) 111 | { 112 | va_list ap; 113 | if (!buf || !buf->unit) 114 | return; 115 | 116 | int n; 117 | 118 | if (buf == 0 || (buf->size >= buf->asize && bufgrow(buf, buf->size + 1)) < 0) 119 | return; 120 | 121 | va_start(ap, fmt); 122 | n = _buf_vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap); 123 | va_end(ap); 124 | 125 | if (n < 0) { 126 | #ifdef _MSC_VER 127 | n = _vscprintf(fmt, ap); 128 | #else 129 | return; 130 | #endif 131 | } 132 | 133 | if ((size_t)n >= buf->asize - buf->size) { 134 | if (bufgrow(buf, buf->size + n + 1) < 0) 135 | return; 136 | va_start(ap, fmt); 137 | n = _buf_vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap); 138 | va_end(ap); 139 | } 140 | 141 | if (n < 0) 142 | return; 143 | 144 | buf->size += n; 145 | } 146 | 147 | /* bufput: appends raw data to a buffer */ 148 | void 149 | bufput(struct buf *buf, const void *data, size_t len) 150 | { 151 | if (!buf) 152 | return; 153 | 154 | if (buf->size + len > buf->asize && bufgrow(buf, buf->size + len) < 0) 155 | return; 156 | 157 | memcpy(buf->data + buf->size, data, len); 158 | buf->size += len; 159 | } 160 | 161 | /* bufputs: appends a NUL-terminated string to a buffer */ 162 | void 163 | bufputs(struct buf *buf, const char *str) 164 | { 165 | bufput(buf, str, strlen(str)); 166 | } 167 | 168 | 169 | /* bufputc: appends a single uint8_t to a buffer */ 170 | void 171 | bufputc(struct buf *buf, int c) 172 | { 173 | if (!buf) 174 | return; 175 | 176 | if (buf->size + 1 > buf->asize && bufgrow(buf, buf->size + 1) < 0) 177 | return; 178 | 179 | buf->data[buf->size] = c; 180 | buf->size += 1; 181 | } 182 | 183 | /* bufrelease: decrease the reference count and free the buffer if needed */ 184 | void 185 | bufrelease(struct buf *buf) 186 | { 187 | if (!buf) 188 | return; 189 | 190 | free(buf->data); 191 | free(buf); 192 | } 193 | 194 | 195 | /* bufreset: frees internal data of the buffer */ 196 | void 197 | bufreset(struct buf *buf) 198 | { 199 | if (!buf) 200 | return; 201 | 202 | free(buf->data); 203 | buf->data = NULL; 204 | buf->size = buf->asize = 0; 205 | } 206 | 207 | /* bufslurp: removes a given number of bytes from the head of the array */ 208 | void 209 | bufslurp(struct buf *buf, size_t len) 210 | { 211 | if (!buf || !buf->unit || len <= 0) 212 | return; 213 | 214 | if (len >= buf->size) { 215 | buf->size = 0; 216 | return; 217 | } 218 | 219 | buf->size -= len; 220 | memmove(buf->data, buf->data + len, buf->size); 221 | } 222 | 223 | /* vbufprintf: stdarg variant of formatted printing into a buffer */ 224 | void 225 | vbufprintf(struct buf *buf, const char *fmt, va_list ap) 226 | { 227 | 228 | } 229 | 230 | -------------------------------------------------------------------------------- /ext/redcarpet/autolink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Vicent Marti 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #include "buffer.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | int 25 | sd_autolink_issafe(const uint8_t *link, size_t link_len) 26 | { 27 | static const size_t valid_uris_count = 5; 28 | static const char *valid_uris[] = { 29 | "/", "http://", "https://", "ftp://", "mailto:" 30 | }; 31 | 32 | size_t i; 33 | 34 | for (i = 0; i < valid_uris_count; ++i) { 35 | size_t len = strlen(valid_uris[i]); 36 | 37 | if (link_len > len && 38 | strncasecmp((char *)link, valid_uris[i], len) == 0 && 39 | isalnum(link[len])) 40 | return 1; 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | static size_t 47 | autolink_delim(uint8_t *data, size_t link_end, size_t offset, size_t size) 48 | { 49 | uint8_t cclose, copen = 0; 50 | size_t i; 51 | 52 | for (i = 0; i < link_end; ++i) 53 | if (data[i] == '<') { 54 | link_end = i; 55 | break; 56 | } 57 | 58 | while (link_end > 0) { 59 | if (strchr("?!.,", data[link_end - 1]) != NULL) 60 | link_end--; 61 | 62 | else if (data[link_end - 1] == ';') { 63 | size_t new_end = link_end - 2; 64 | 65 | while (new_end > 0 && isalpha(data[new_end])) 66 | new_end--; 67 | 68 | if (new_end < link_end - 2 && data[new_end] == '&') 69 | link_end = new_end; 70 | else 71 | link_end--; 72 | } 73 | else break; 74 | } 75 | 76 | if (link_end == 0) 77 | return 0; 78 | 79 | cclose = data[link_end - 1]; 80 | 81 | switch (cclose) { 82 | case '"': copen = '"'; break; 83 | case '\'': copen = '\''; break; 84 | case ')': copen = '('; break; 85 | case ']': copen = '['; break; 86 | case '}': copen = '{'; break; 87 | } 88 | 89 | if (copen != 0) { 90 | size_t closing = 0; 91 | size_t opening = 0; 92 | size_t i = 0; 93 | 94 | /* Try to close the final punctuation sign in this same line; 95 | * if we managed to close it outside of the URL, that means that it's 96 | * not part of the URL. If it closes inside the URL, that means it 97 | * is part of the URL. 98 | * 99 | * Examples: 100 | * 101 | * foo http://www.pokemon.com/Pikachu_(Electric) bar 102 | * => http://www.pokemon.com/Pikachu_(Electric) 103 | * 104 | * foo (http://www.pokemon.com/Pikachu_(Electric)) bar 105 | * => http://www.pokemon.com/Pikachu_(Electric) 106 | * 107 | * foo http://www.pokemon.com/Pikachu_(Electric)) bar 108 | * => http://www.pokemon.com/Pikachu_(Electric)) 109 | * 110 | * (foo http://www.pokemon.com/Pikachu_(Electric)) bar 111 | * => foo http://www.pokemon.com/Pikachu_(Electric) 112 | */ 113 | 114 | while (i < link_end) { 115 | if (data[i] == copen) 116 | opening++; 117 | else if (data[i] == cclose) 118 | closing++; 119 | 120 | i++; 121 | } 122 | 123 | if (closing != opening) 124 | link_end--; 125 | } 126 | 127 | return link_end; 128 | } 129 | 130 | static size_t 131 | check_domain(uint8_t *data, size_t size) 132 | { 133 | size_t i, np = 0; 134 | 135 | if (!isalnum(data[0])) 136 | return 0; 137 | 138 | for (i = 1; i < size - 1; ++i) { 139 | if (data[i] == '.') np++; 140 | else if (!isalnum(data[i]) && data[i] != '-') break; 141 | } 142 | 143 | if (!isalnum(data[i - 1]) || np == 0) 144 | return 0; 145 | 146 | return i; 147 | } 148 | 149 | size_t 150 | sd_autolink__www(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size) 151 | { 152 | size_t link_end; 153 | 154 | if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1])) 155 | return 0; 156 | 157 | if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0) 158 | return 0; 159 | 160 | link_end = check_domain(data, size); 161 | 162 | if (link_end == 0) 163 | return 0; 164 | 165 | while (link_end < size && !isspace(data[link_end])) 166 | link_end++; 167 | 168 | link_end = autolink_delim(data, link_end, offset, size); 169 | 170 | if (link_end == 0) 171 | return 0; 172 | 173 | bufput(link, data, link_end); 174 | *rewind_p = 0; 175 | 176 | return (int)link_end; 177 | } 178 | 179 | size_t 180 | sd_autolink__email(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size) 181 | { 182 | size_t link_end, rewind; 183 | int nb = 0, np = 0; 184 | 185 | for (rewind = 0; rewind < offset; ++rewind) { 186 | uint8_t c = data[-rewind - 1]; 187 | 188 | if (isalnum(c)) 189 | continue; 190 | 191 | if (strchr(".+-_", c) != NULL) 192 | continue; 193 | 194 | break; 195 | } 196 | 197 | if (rewind == 0) 198 | return 0; 199 | 200 | for (link_end = 0; link_end < size; ++link_end) { 201 | uint8_t c = data[link_end]; 202 | 203 | if (isalnum(c)) 204 | continue; 205 | 206 | if (c == '@') 207 | nb++; 208 | else if (c == '.' && link_end < size - 1) 209 | np++; 210 | else if (c != '-' && c != '_') 211 | break; 212 | } 213 | 214 | if (link_end < 2 || nb != 1 || np == 0) 215 | return 0; 216 | 217 | link_end = autolink_delim(data, link_end, offset, size); 218 | 219 | if (link_end == 0) 220 | return 0; 221 | 222 | bufput(link, data - rewind, link_end + rewind); 223 | *rewind_p = rewind; 224 | 225 | return link_end; 226 | } 227 | 228 | size_t 229 | sd_autolink__url(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size) 230 | { 231 | size_t link_end, rewind = 0, domain_len; 232 | 233 | if (size < 4 || data[1] != '/' || data[2] != '/') 234 | return 0; 235 | 236 | while (rewind < offset && isalpha(data[-rewind - 1])) 237 | rewind++; 238 | 239 | if (!sd_autolink_issafe(data - rewind, size + rewind)) 240 | return 0; 241 | link_end = strlen("://"); 242 | 243 | domain_len = check_domain(data + link_end, size - link_end); 244 | if (domain_len == 0) 245 | return 0; 246 | 247 | link_end += domain_len; 248 | while (link_end < size && !isspace(data[link_end])) 249 | link_end++; 250 | 251 | link_end = autolink_delim(data, link_end, offset, size); 252 | 253 | if (link_end == 0) 254 | return 0; 255 | 256 | bufput(link, data - rewind, link_end + rewind); 257 | *rewind_p = rewind; 258 | 259 | return link_end; 260 | } 261 | 262 | -------------------------------------------------------------------------------- /ext/redcarpet/html_blocks.h: -------------------------------------------------------------------------------- 1 | /* C code produced by gperf version 3.0.3 */ 2 | /* Command-line: gperf -N find_block_tag -H hash_block_tag -C -c -E --ignore-case html_block_names.txt */ 3 | /* Computed positions: -k'1-2' */ 4 | 5 | #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ 6 | && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ 7 | && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ 8 | && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ 9 | && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ 10 | && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ 11 | && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ 12 | && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ 13 | && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ 14 | && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ 15 | && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ 16 | && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ 17 | && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ 18 | && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ 19 | && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ 20 | && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ 21 | && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ 22 | && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ 23 | && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ 24 | && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ 25 | && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ 26 | && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ 27 | && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) 28 | /* The character set is not based on ISO-646. */ 29 | error "gperf generated tables don't work with this execution character set. Please report a bug to ." 30 | #endif 31 | 32 | /* maximum key range = 37, duplicates = 0 */ 33 | 34 | #ifndef GPERF_DOWNCASE 35 | #define GPERF_DOWNCASE 1 36 | static unsigned char gperf_downcase[256] = 37 | { 38 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 39 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40 | 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 41 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 42 | 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 43 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 44 | 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 45 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 46 | 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 47 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 48 | 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 49 | 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 50 | 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 51 | 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 52 | 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 53 | 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 54 | 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 55 | 255 56 | }; 57 | #endif 58 | 59 | #ifndef GPERF_CASE_STRNCMP 60 | #define GPERF_CASE_STRNCMP 1 61 | static int 62 | gperf_case_strncmp (s1, s2, n) 63 | register const char *s1; 64 | register const char *s2; 65 | register unsigned int n; 66 | { 67 | for (; n > 0;) 68 | { 69 | unsigned char c1 = gperf_downcase[(unsigned char)*s1++]; 70 | unsigned char c2 = gperf_downcase[(unsigned char)*s2++]; 71 | if (c1 != 0 && c1 == c2) 72 | { 73 | n--; 74 | continue; 75 | } 76 | return (int)c1 - (int)c2; 77 | } 78 | return 0; 79 | } 80 | #endif 81 | 82 | #ifdef __GNUC__ 83 | __inline 84 | #else 85 | #ifdef __cplusplus 86 | inline 87 | #endif 88 | #endif 89 | static unsigned int 90 | hash_block_tag (str, len) 91 | register const char *str; 92 | register unsigned int len; 93 | { 94 | static const unsigned char asso_values[] = 95 | { 96 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 97 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 98 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 99 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 100 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 101 | 8, 30, 25, 20, 15, 10, 38, 38, 38, 38, 102 | 38, 38, 38, 38, 38, 38, 0, 38, 0, 38, 103 | 5, 5, 5, 15, 0, 38, 38, 0, 15, 10, 104 | 0, 38, 38, 15, 0, 5, 38, 38, 38, 38, 105 | 38, 38, 38, 38, 38, 38, 38, 38, 0, 38, 106 | 0, 38, 5, 5, 5, 15, 0, 38, 38, 0, 107 | 15, 10, 0, 38, 38, 15, 0, 5, 38, 38, 108 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 109 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 110 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 111 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 112 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 113 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 114 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 115 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 116 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 117 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 118 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 119 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 120 | 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 121 | 38, 38, 38, 38, 38, 38, 38 122 | }; 123 | register int hval = len; 124 | 125 | switch (hval) 126 | { 127 | default: 128 | hval += asso_values[(unsigned char)str[1]+1]; 129 | /*FALLTHROUGH*/ 130 | case 1: 131 | hval += asso_values[(unsigned char)str[0]]; 132 | break; 133 | } 134 | return hval; 135 | } 136 | 137 | #ifdef __GNUC__ 138 | __inline 139 | #ifdef __GNUC_STDC_INLINE__ 140 | __attribute__ ((__gnu_inline__)) 141 | #endif 142 | #endif 143 | const char * 144 | find_block_tag (str, len) 145 | register const char *str; 146 | register unsigned int len; 147 | { 148 | enum 149 | { 150 | TOTAL_KEYWORDS = 24, 151 | MIN_WORD_LENGTH = 1, 152 | MAX_WORD_LENGTH = 10, 153 | MIN_HASH_VALUE = 1, 154 | MAX_HASH_VALUE = 37 155 | }; 156 | 157 | static const char * const wordlist[] = 158 | { 159 | "", 160 | "p", 161 | "dl", 162 | "div", 163 | "math", 164 | "table", 165 | "", 166 | "ul", 167 | "del", 168 | "form", 169 | "blockquote", 170 | "figure", 171 | "ol", 172 | "fieldset", 173 | "", 174 | "h1", 175 | "", 176 | "h6", 177 | "pre", 178 | "", "", 179 | "script", 180 | "h5", 181 | "noscript", 182 | "", 183 | "style", 184 | "iframe", 185 | "h4", 186 | "ins", 187 | "", "", "", 188 | "h3", 189 | "", "", "", "", 190 | "h2" 191 | }; 192 | 193 | if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 194 | { 195 | register int key = hash_block_tag (str, len); 196 | 197 | if (key <= MAX_HASH_VALUE && key >= 0) 198 | { 199 | register const char *s = wordlist[key]; 200 | 201 | if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strncmp (str, s, len) && s[len] == '\0') 202 | return s; 203 | } 204 | } 205 | return 0; 206 | } 207 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text: -------------------------------------------------------------------------------- 1 | Markdown: Basics 2 | ================ 3 | 4 | 11 | 12 | 13 | Getting the Gist of Markdown's Formatting Syntax 14 | ------------------------------------------------ 15 | 16 | This page offers a brief overview of what it's like to use Markdown. 17 | The [syntax page] [s] provides complete, detailed documentation for 18 | every feature, but Markdown should be very easy to pick up simply by 19 | looking at a few examples of it in action. The examples on this page 20 | are written in a before/after style, showing example syntax and the 21 | HTML output produced by Markdown. 22 | 23 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a 24 | web application that allows you type your own Markdown-formatted text 25 | and translate it to XHTML. 26 | 27 | **Note:** This document is itself written using Markdown; you 28 | can [see the source for it by adding '.text' to the URL] [src]. 29 | 30 | [s]: /projects/markdown/syntax "Markdown Syntax" 31 | [d]: /projects/markdown/dingus "Markdown Dingus" 32 | [src]: /projects/markdown/basics.text 33 | 34 | 35 | ## Paragraphs, Headers, Blockquotes ## 36 | 37 | A paragraph is simply one or more consecutive lines of text, separated 38 | by one or more blank lines. (A blank line is any line that looks like a 39 | blank line -- a line containing nothing spaces or tabs is considered 40 | blank.) Normal paragraphs should not be intended with spaces or tabs. 41 | 42 | Markdown offers two styles of headers: *Setext* and *atx*. 43 | Setext-style headers for `

    ` and `

    ` are created by 44 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively. 45 | To create an atx-style header, you put 1-6 hash marks (`#`) at the 46 | beginning of the line -- the number of hashes equals the resulting 47 | HTML header level. 48 | 49 | Blockquotes are indicated using email-style '`>`' angle brackets. 50 | 51 | Markdown: 52 | 53 | A First Level Header 54 | ==================== 55 | 56 | A Second Level Header 57 | --------------------- 58 | 59 | Now is the time for all good men to come to 60 | the aid of their country. This is just a 61 | regular paragraph. 62 | 63 | The quick brown fox jumped over the lazy 64 | dog's back. 65 | 66 | ### Header 3 67 | 68 | > This is a blockquote. 69 | > 70 | > This is the second paragraph in the blockquote. 71 | > 72 | > ## This is an H2 in a blockquote 73 | 74 | 75 | Output: 76 | 77 |

    A First Level Header

    78 | 79 |

    A Second Level Header

    80 | 81 |

    Now is the time for all good men to come to 82 | the aid of their country. This is just a 83 | regular paragraph.

    84 | 85 |

    The quick brown fox jumped over the lazy 86 | dog's back.

    87 | 88 |

    Header 3

    89 | 90 |
    91 |

    This is a blockquote.

    92 | 93 |

    This is the second paragraph in the blockquote.

    94 | 95 |

    This is an H2 in a blockquote

    96 |
    97 | 98 | 99 | 100 | ### Phrase Emphasis ### 101 | 102 | Markdown uses asterisks and underscores to indicate spans of emphasis. 103 | 104 | Markdown: 105 | 106 | Some of these words *are emphasized*. 107 | Some of these words _are emphasized also_. 108 | 109 | Use two asterisks for **strong emphasis**. 110 | Or, if you prefer, __use two underscores instead__. 111 | 112 | Output: 113 | 114 |

    Some of these words are emphasized. 115 | Some of these words are emphasized also.

    116 | 117 |

    Use two asterisks for strong emphasis. 118 | Or, if you prefer, use two underscores instead.

    119 | 120 | 121 | 122 | ## Lists ## 123 | 124 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, 125 | `+`, and `-`) as list markers. These three markers are 126 | interchangable; this: 127 | 128 | * Candy. 129 | * Gum. 130 | * Booze. 131 | 132 | this: 133 | 134 | + Candy. 135 | + Gum. 136 | + Booze. 137 | 138 | and this: 139 | 140 | - Candy. 141 | - Gum. 142 | - Booze. 143 | 144 | all produce the same output: 145 | 146 |
      147 |
    • Candy.
    • 148 |
    • Gum.
    • 149 |
    • Booze.
    • 150 |
    151 | 152 | Ordered (numbered) lists use regular numbers, followed by periods, as 153 | list markers: 154 | 155 | 1. Red 156 | 2. Green 157 | 3. Blue 158 | 159 | Output: 160 | 161 |
      162 |
    1. Red
    2. 163 |
    3. Green
    4. 164 |
    5. Blue
    6. 165 |
    166 | 167 | If you put blank lines between items, you'll get `

    ` tags for the 168 | list item text. You can create multi-paragraph list items by indenting 169 | the paragraphs by 4 spaces or 1 tab: 170 | 171 | * A list item. 172 | 173 | With multiple paragraphs. 174 | 175 | * Another item in the list. 176 | 177 | Output: 178 | 179 |

      180 |
    • A list item.

      181 |

      With multiple paragraphs.

    • 182 |
    • Another item in the list.

    • 183 |
    184 | 185 | 186 | 187 | ### Links ### 188 | 189 | Markdown supports two styles for creating links: *inline* and 190 | *reference*. With both styles, you use square brackets to delimit the 191 | text you want to turn into a link. 192 | 193 | Inline-style links use parentheses immediately after the link text. 194 | For example: 195 | 196 | This is an [example link](http://example.com/). 197 | 198 | Output: 199 | 200 |

    This is an 201 | example link.

    202 | 203 | Optionally, you may include a title attribute in the parentheses: 204 | 205 | This is an [example link](http://example.com/ "With a Title"). 206 | 207 | Output: 208 | 209 |

    This is an 210 | example link.

    211 | 212 | Reference-style links allow you to refer to your links by names, which 213 | you define elsewhere in your document: 214 | 215 | I get 10 times more traffic from [Google][1] than from 216 | [Yahoo][2] or [MSN][3]. 217 | 218 | [1]: http://google.com/ "Google" 219 | [2]: http://search.yahoo.com/ "Yahoo Search" 220 | [3]: http://search.msn.com/ "MSN Search" 221 | 222 | Output: 223 | 224 |

    I get 10 times more traffic from Google than from Yahoo or MSN.

    228 | 229 | The title attribute is optional. Link names may contain letters, 230 | numbers and spaces, but are *not* case sensitive: 231 | 232 | I start my morning with a cup of coffee and 233 | [The New York Times][NY Times]. 234 | 235 | [ny times]: http://www.nytimes.com/ 236 | 237 | Output: 238 | 239 |

    I start my morning with a cup of coffee and 240 | The New York Times.

    241 | 242 | 243 | ### Images ### 244 | 245 | Image syntax is very much like link syntax. 246 | 247 | Inline (titles are optional): 248 | 249 | ![alt text](/path/to/img.jpg "Title") 250 | 251 | Reference-style: 252 | 253 | ![alt text][id] 254 | 255 | [id]: /path/to/img.jpg "Title" 256 | 257 | Both of the above examples produce the same output: 258 | 259 | alt text 260 | 261 | 262 | 263 | ### Code ### 264 | 265 | In a regular paragraph, you can create code span by wrapping text in 266 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or 267 | `>`) will automatically be translated into HTML entities. This makes 268 | it easy to use Markdown to write about HTML example code: 269 | 270 | I strongly recommend against using any `` tags. 271 | 272 | I wish SmartyPants used named entities like `—` 273 | instead of decimal-encoded entites like `—`. 274 | 275 | Output: 276 | 277 |

    I strongly recommend against using any 278 | <blink> tags.

    279 | 280 |

    I wish SmartyPants used named entities like 281 | &mdash; instead of decimal-encoded 282 | entites like &#8212;.

    283 | 284 | 285 | To specify an entire block of pre-formatted code, indent every line of 286 | the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, 287 | and `>` characters will be escaped automatically. 288 | 289 | Markdown: 290 | 291 | If you want your page to validate under XHTML 1.0 Strict, 292 | you've got to put paragraph tags in your blockquotes: 293 | 294 |
    295 |

    For example.

    296 |
    297 | 298 | Output: 299 | 300 |

    If you want your page to validate under XHTML 1.0 Strict, 301 | you've got to put paragraph tags in your blockquotes:

    302 | 303 |
    <blockquote>
    304 |         <p>For example.</p>
    305 |     </blockquote>
    306 |     
    307 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.text: -------------------------------------------------------------------------------- 1 | Markdown: Basics 2 | ================ 3 | 4 | 11 | 12 | 13 | Getting the Gist of Markdown's Formatting Syntax 14 | ------------------------------------------------ 15 | 16 | This page offers a brief overview of what it's like to use Markdown. 17 | The [syntax page] [s] provides complete, detailed documentation for 18 | every feature, but Markdown should be very easy to pick up simply by 19 | looking at a few examples of it in action. The examples on this page 20 | are written in a before/after style, showing example syntax and the 21 | HTML output produced by Markdown. 22 | 23 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a 24 | web application that allows you type your own Markdown-formatted text 25 | and translate it to XHTML. 26 | 27 | **Note:** This document is itself written using Markdown; you 28 | can [see the source for it by adding '.text' to the URL] [src]. 29 | 30 | [s]: /projects/markdown/syntax "Markdown Syntax" 31 | [d]: /projects/markdown/dingus "Markdown Dingus" 32 | [src]: /projects/markdown/basics.text 33 | 34 | 35 | ## Paragraphs, Headers, Blockquotes ## 36 | 37 | A paragraph is simply one or more consecutive lines of text, separated 38 | by one or more blank lines. (A blank line is any line that looks like a 39 | blank line -- a line containing nothing spaces or tabs is considered 40 | blank.) Normal paragraphs should not be intended with spaces or tabs. 41 | 42 | Markdown offers two styles of headers: *Setext* and *atx*. 43 | Setext-style headers for `

    ` and `

    ` are created by 44 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively. 45 | To create an atx-style header, you put 1-6 hash marks (`#`) at the 46 | beginning of the line -- the number of hashes equals the resulting 47 | HTML header level. 48 | 49 | Blockquotes are indicated using email-style '`>`' angle brackets. 50 | 51 | Markdown: 52 | 53 | A First Level Header 54 | ==================== 55 | 56 | A Second Level Header 57 | --------------------- 58 | 59 | Now is the time for all good men to come to 60 | the aid of their country. This is just a 61 | regular paragraph. 62 | 63 | The quick brown fox jumped over the lazy 64 | dog's back. 65 | 66 | ### Header 3 67 | 68 | > This is a blockquote. 69 | > 70 | > This is the second paragraph in the blockquote. 71 | > 72 | > ## This is an H2 in a blockquote 73 | 74 | 75 | Output: 76 | 77 |

    A First Level Header

    78 | 79 |

    A Second Level Header

    80 | 81 |

    Now is the time for all good men to come to 82 | the aid of their country. This is just a 83 | regular paragraph.

    84 | 85 |

    The quick brown fox jumped over the lazy 86 | dog's back.

    87 | 88 |

    Header 3

    89 | 90 |
    91 |

    This is a blockquote.

    92 | 93 |

    This is the second paragraph in the blockquote.

    94 | 95 |

    This is an H2 in a blockquote

    96 |
    97 | 98 | 99 | 100 | ### Phrase Emphasis ### 101 | 102 | Markdown uses asterisks and underscores to indicate spans of emphasis. 103 | 104 | Markdown: 105 | 106 | Some of these words *are emphasized*. 107 | Some of these words _are emphasized also_. 108 | 109 | Use two asterisks for **strong emphasis**. 110 | Or, if you prefer, __use two underscores instead__. 111 | 112 | Output: 113 | 114 |

    Some of these words are emphasized. 115 | Some of these words are emphasized also.

    116 | 117 |

    Use two asterisks for strong emphasis. 118 | Or, if you prefer, use two underscores instead.

    119 | 120 | 121 | 122 | ## Lists ## 123 | 124 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, 125 | `+`, and `-`) as list markers. These three markers are 126 | interchangable; this: 127 | 128 | * Candy. 129 | * Gum. 130 | * Booze. 131 | 132 | this: 133 | 134 | + Candy. 135 | + Gum. 136 | + Booze. 137 | 138 | and this: 139 | 140 | - Candy. 141 | - Gum. 142 | - Booze. 143 | 144 | all produce the same output: 145 | 146 |
      147 |
    • Candy.
    • 148 |
    • Gum.
    • 149 |
    • Booze.
    • 150 |
    151 | 152 | Ordered (numbered) lists use regular numbers, followed by periods, as 153 | list markers: 154 | 155 | 1. Red 156 | 2. Green 157 | 3. Blue 158 | 159 | Output: 160 | 161 |
      162 |
    1. Red
    2. 163 |
    3. Green
    4. 164 |
    5. Blue
    6. 165 |
    166 | 167 | If you put blank lines between items, you'll get `

    ` tags for the 168 | list item text. You can create multi-paragraph list items by indenting 169 | the paragraphs by 4 spaces or 1 tab: 170 | 171 | * A list item. 172 | 173 | With multiple paragraphs. 174 | 175 | * Another item in the list. 176 | 177 | Output: 178 | 179 |

      180 |
    • A list item.

      181 |

      With multiple paragraphs.

    • 182 |
    • Another item in the list.

    • 183 |
    184 | 185 | 186 | 187 | ### Links ### 188 | 189 | Markdown supports two styles for creating links: *inline* and 190 | *reference*. With both styles, you use square brackets to delimit the 191 | text you want to turn into a link. 192 | 193 | Inline-style links use parentheses immediately after the link text. 194 | For example: 195 | 196 | This is an [example link](http://example.com/). 197 | 198 | Output: 199 | 200 |

    This is an 201 | example link.

    202 | 203 | Optionally, you may include a title attribute in the parentheses: 204 | 205 | This is an [example link](http://example.com/ "With a Title"). 206 | 207 | Output: 208 | 209 |

    This is an 210 | example link.

    211 | 212 | Reference-style links allow you to refer to your links by names, which 213 | you define elsewhere in your document: 214 | 215 | I get 10 times more traffic from [Google][1] than from 216 | [Yahoo][2] or [MSN][3]. 217 | 218 | [1]: http://google.com/ "Google" 219 | [2]: http://search.yahoo.com/ "Yahoo Search" 220 | [3]: http://search.msn.com/ "MSN Search" 221 | 222 | Output: 223 | 224 |

    I get 10 times more traffic from Google than from Yahoo or MSN.

    228 | 229 | The title attribute is optional. Link names may contain letters, 230 | numbers and spaces, but are *not* case sensitive: 231 | 232 | I start my morning with a cup of coffee and 233 | [The New York Times][NY Times]. 234 | 235 | [ny times]: http://www.nytimes.com/ 236 | 237 | Output: 238 | 239 |

    I start my morning with a cup of coffee and 240 | The New York Times.

    241 | 242 | 243 | ### Images ### 244 | 245 | Image syntax is very much like link syntax. 246 | 247 | Inline (titles are optional): 248 | 249 | ![alt text](/path/to/img.jpg "Title") 250 | 251 | Reference-style: 252 | 253 | ![alt text][id] 254 | 255 | [id]: /path/to/img.jpg "Title" 256 | 257 | Both of the above examples produce the same output: 258 | 259 | alt text 260 | 261 | 262 | 263 | ### Code ### 264 | 265 | In a regular paragraph, you can create code span by wrapping text in 266 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or 267 | `>`) will automatically be translated into HTML entities. This makes 268 | it easy to use Markdown to write about HTML example code: 269 | 270 | I strongly recommend against using any `` tags. 271 | 272 | I wish SmartyPants used named entities like `—` 273 | instead of decimal-encoded entites like `—`. 274 | 275 | Output: 276 | 277 |

    I strongly recommend against using any 278 | <blink> tags.

    279 | 280 |

    I wish SmartyPants used named entities like 281 | &mdash; instead of decimal-encoded 282 | entites like &#8212;.

    283 | 284 | 285 | To specify an entire block of pre-formatted code, indent every line of 286 | the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, 287 | and `>` characters will be escaped automatically. 288 | 289 | Markdown: 290 | 291 | If you want your page to validate under XHTML 1.0 Strict, 292 | you've got to put paragraph tags in your blockquotes: 293 | 294 |
    295 |

    For example.

    296 |
    297 | 298 | Output: 299 | 300 |

    If you want your page to validate under XHTML 1.0 Strict, 301 | you've got to put paragraph tags in your blockquotes:

    302 | 303 |
    <blockquote>
    304 |         <p>For example.</p>
    305 |     </blockquote>
    306 |     
    307 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html: -------------------------------------------------------------------------------- 1 |

    Markdown: Basics

    2 | 3 | 10 | 11 |

    Getting the Gist of Markdown's Formatting Syntax

    12 | 13 |

    This page offers a brief overview of what it's like to use Markdown. 14 | The syntax page provides complete, detailed documentation for 15 | every feature, but Markdown should be very easy to pick up simply by 16 | looking at a few examples of it in action. The examples on this page 17 | are written in a before/after style, showing example syntax and the 18 | HTML output produced by Markdown.

    19 | 20 |

    It's also helpful to simply try Markdown out; the Dingus is a 21 | web application that allows you type your own Markdown-formatted text 22 | and translate it to XHTML.

    23 | 24 |

    Note: This document is itself written using Markdown; you 25 | can see the source for it by adding '.text' to the URL.

    26 | 27 |

    Paragraphs, Headers, Blockquotes

    28 | 29 |

    A paragraph is simply one or more consecutive lines of text, separated 30 | by one or more blank lines. (A blank line is any line that looks like a 31 | blank line -- a line containing nothing spaces or tabs is considered 32 | blank.) Normal paragraphs should not be intended with spaces or tabs.

    33 | 34 |

    Markdown offers two styles of headers: Setext and atx. 35 | Setext-style headers for <h1> and <h2> are created by 36 | "underlining" with equal signs (=) and hyphens (-), respectively. 37 | To create an atx-style header, you put 1-6 hash marks (#) at the 38 | beginning of the line -- the number of hashes equals the resulting 39 | HTML header level.

    40 | 41 |

    Blockquotes are indicated using email-style '>' angle brackets.

    42 | 43 |

    Markdown:

    44 | 45 |
    A First Level Header
     46 | ====================
     47 | 
     48 | A Second Level Header
     49 | ---------------------
     50 | 
     51 | Now is the time for all good men to come to
     52 | the aid of their country. This is just a
     53 | regular paragraph.
     54 | 
     55 | The quick brown fox jumped over the lazy
     56 | dog's back.
     57 | 
     58 | ### Header 3
     59 | 
     60 | > This is a blockquote.
     61 | > 
     62 | > This is the second paragraph in the blockquote.
     63 | >
     64 | > ## This is an H2 in a blockquote
     65 | 
    66 | 67 |

    Output:

    68 | 69 |
    <h1>A First Level Header</h1>
     70 | 
     71 | <h2>A Second Level Header</h2>
     72 | 
     73 | <p>Now is the time for all good men to come to
     74 | the aid of their country. This is just a
     75 | regular paragraph.</p>
     76 | 
     77 | <p>The quick brown fox jumped over the lazy
     78 | dog's back.</p>
     79 | 
     80 | <h3>Header 3</h3>
     81 | 
     82 | <blockquote>
     83 |     <p>This is a blockquote.</p>
     84 | 
     85 |     <p>This is the second paragraph in the blockquote.</p>
     86 | 
     87 |     <h2>This is an H2 in a blockquote</h2>
     88 | </blockquote>
     89 | 
    90 | 91 |

    Phrase Emphasis

    92 | 93 |

    Markdown uses asterisks and underscores to indicate spans of emphasis.

    94 | 95 |

    Markdown:

    96 | 97 |
    Some of these words *are emphasized*.
     98 | Some of these words _are emphasized also_.
     99 | 
    100 | Use two asterisks for **strong emphasis**.
    101 | Or, if you prefer, __use two underscores instead__.
    102 | 
    103 | 104 |

    Output:

    105 | 106 |
    <p>Some of these words <em>are emphasized</em>.
    107 | Some of these words <em>are emphasized also</em>.</p>
    108 | 
    109 | <p>Use two asterisks for <strong>strong emphasis</strong>.
    110 | Or, if you prefer, <strong>use two underscores instead</strong>.</p>
    111 | 
    112 | 113 |

    Lists

    114 | 115 |

    Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, 116 | +, and -) as list markers. These three markers are 117 | interchangable; this:

    118 | 119 |
    *   Candy.
    120 | *   Gum.
    121 | *   Booze.
    122 | 
    123 | 124 |

    this:

    125 | 126 |
    +   Candy.
    127 | +   Gum.
    128 | +   Booze.
    129 | 
    130 | 131 |

    and this:

    132 | 133 |
    -   Candy.
    134 | -   Gum.
    135 | -   Booze.
    136 | 
    137 | 138 |

    all produce the same output:

    139 | 140 |
    <ul>
    141 | <li>Candy.</li>
    142 | <li>Gum.</li>
    143 | <li>Booze.</li>
    144 | </ul>
    145 | 
    146 | 147 |

    Ordered (numbered) lists use regular numbers, followed by periods, as 148 | list markers:

    149 | 150 |
    1.  Red
    151 | 2.  Green
    152 | 3.  Blue
    153 | 
    154 | 155 |

    Output:

    156 | 157 |
    <ol>
    158 | <li>Red</li>
    159 | <li>Green</li>
    160 | <li>Blue</li>
    161 | </ol>
    162 | 
    163 | 164 |

    If you put blank lines between items, you'll get <p> tags for the 165 | list item text. You can create multi-paragraph list items by indenting 166 | the paragraphs by 4 spaces or 1 tab:

    167 | 168 |
    *   A list item.
    169 | 
    170 |     With multiple paragraphs.
    171 | 
    172 | *   Another item in the list.
    173 | 
    174 | 175 |

    Output:

    176 | 177 |
    <ul>
    178 | <li><p>A list item.</p>
    179 | <p>With multiple paragraphs.</p></li>
    180 | <li><p>Another item in the list.</p></li>
    181 | </ul>
    182 | 
    183 | 184 |

    Links

    185 | 186 |

    Markdown supports two styles for creating links: inline and 187 | reference. With both styles, you use square brackets to delimit the 188 | text you want to turn into a link.

    189 | 190 |

    Inline-style links use parentheses immediately after the link text. 191 | For example:

    192 | 193 |
    This is an [example link](http://example.com/).
    194 | 
    195 | 196 |

    Output:

    197 | 198 |
    <p>This is an <a href="http://example.com/">
    199 | example link</a>.</p>
    200 | 
    201 | 202 |

    Optionally, you may include a title attribute in the parentheses:

    203 | 204 |
    This is an [example link](http://example.com/ "With a Title").
    205 | 
    206 | 207 |

    Output:

    208 | 209 |
    <p>This is an <a href="http://example.com/" title="With a Title">
    210 | example link</a>.</p>
    211 | 
    212 | 213 |

    Reference-style links allow you to refer to your links by names, which 214 | you define elsewhere in your document:

    215 | 216 |
    I get 10 times more traffic from [Google][1] than from
    217 | [Yahoo][2] or [MSN][3].
    218 | 
    219 | [1]: http://google.com/        "Google"
    220 | [2]: http://search.yahoo.com/  "Yahoo Search"
    221 | [3]: http://search.msn.com/    "MSN Search"
    222 | 
    223 | 224 |

    Output:

    225 | 226 |
    <p>I get 10 times more traffic from <a href="http://google.com/"
    227 | title="Google">Google</a> than from <a href="http://search.yahoo.com/"
    228 | title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
    229 | title="MSN Search">MSN</a>.</p>
    230 | 
    231 | 232 |

    The title attribute is optional. Link names may contain letters, 233 | numbers and spaces, but are not case sensitive:

    234 | 235 |
    I start my morning with a cup of coffee and
    236 | [The New York Times][NY Times].
    237 | 
    238 | [ny times]: http://www.nytimes.com/
    239 | 
    240 | 241 |

    Output:

    242 | 243 |
    <p>I start my morning with a cup of coffee and
    244 | <a href="http://www.nytimes.com/">The New York Times</a>.</p>
    245 | 
    246 | 247 |

    Images

    248 | 249 |

    Image syntax is very much like link syntax.

    250 | 251 |

    Inline (titles are optional):

    252 | 253 |
    ![alt text](/path/to/img.jpg "Title")
    254 | 
    255 | 256 |

    Reference-style:

    257 | 258 |
    ![alt text][id]
    259 | 
    260 | [id]: /path/to/img.jpg "Title"
    261 | 
    262 | 263 |

    Both of the above examples produce the same output:

    264 | 265 |
    <img src="/path/to/img.jpg" alt="alt text" title="Title" />
    266 | 
    267 | 268 |

    Code

    269 | 270 |

    In a regular paragraph, you can create code span by wrapping text in 271 | backtick quotes. Any ampersands (&) and angle brackets (< or 272 | >) will automatically be translated into HTML entities. This makes 273 | it easy to use Markdown to write about HTML example code:

    274 | 275 |
    I strongly recommend against using any `<blink>` tags.
    276 | 
    277 | I wish SmartyPants used named entities like `&mdash;`
    278 | instead of decimal-encoded entites like `&#8212;`.
    279 | 
    280 | 281 |

    Output:

    282 | 283 |
    <p>I strongly recommend against using any
    284 | <code>&lt;blink&gt;</code> tags.</p>
    285 | 
    286 | <p>I wish SmartyPants used named entities like
    287 | <code>&amp;mdash;</code> instead of decimal-encoded
    288 | entites like <code>&amp;#8212;</code>.</p>
    289 | 
    290 | 291 |

    To specify an entire block of pre-formatted code, indent every line of 292 | the block by 4 spaces or 1 tab. Just like with code spans, &, <, 293 | and > characters will be escaped automatically.

    294 | 295 |

    Markdown:

    296 | 297 |
    If you want your page to validate under XHTML 1.0 Strict,
    298 | you've got to put paragraph tags in your blockquotes:
    299 | 
    300 |     <blockquote>
    301 |         <p>For example.</p>
    302 |     </blockquote>
    303 | 
    304 | 305 |

    Output:

    306 | 307 |
    <p>If you want your page to validate under XHTML 1.0 Strict,
    308 | you've got to put paragraph tags in your blockquotes:</p>
    309 | 
    310 | <pre><code>&lt;blockquote&gt;
    311 |     &lt;p&gt;For example.&lt;/p&gt;
    312 | &lt;/blockquote&gt;
    313 | </code></pre>
    314 | 
    315 | -------------------------------------------------------------------------------- /test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.html: -------------------------------------------------------------------------------- 1 |

    Markdown: Basics

    2 | 3 | 10 | 11 |

    Getting the Gist of Markdown's Formatting Syntax

    12 | 13 |

    This page offers a brief overview of what it's like to use Markdown. 14 | The syntax page provides complete, detailed documentation for 15 | every feature, but Markdown should be very easy to pick up simply by 16 | looking at a few examples of it in action. The examples on this page 17 | are written in a before/after style, showing example syntax and the 18 | HTML output produced by Markdown.

    19 | 20 |

    It's also helpful to simply try Markdown out; the Dingus is a 21 | web application that allows you type your own Markdown-formatted text 22 | and translate it to XHTML.

    23 | 24 |

    Note: This document is itself written using Markdown; you 25 | can see the source for it by adding '.text' to the URL.

    26 | 27 |

    Paragraphs, Headers, Blockquotes

    28 | 29 |

    A paragraph is simply one or more consecutive lines of text, separated 30 | by one or more blank lines. (A blank line is any line that looks like a 31 | blank line -- a line containing nothing spaces or tabs is considered 32 | blank.) Normal paragraphs should not be intended with spaces or tabs.

    33 | 34 |

    Markdown offers two styles of headers: Setext and atx. 35 | Setext-style headers for <h1> and <h2> are created by 36 | "underlining" with equal signs (=) and hyphens (-), respectively. 37 | To create an atx-style header, you put 1-6 hash marks (#) at the 38 | beginning of the line -- the number of hashes equals the resulting 39 | HTML header level.

    40 | 41 |

    Blockquotes are indicated using email-style '>' angle brackets.

    42 | 43 |

    Markdown:

    44 | 45 |
    A First Level Header
     46 | ====================
     47 | 
     48 | A Second Level Header
     49 | ---------------------
     50 | 
     51 | Now is the time for all good men to come to
     52 | the aid of their country. This is just a
     53 | regular paragraph.
     54 | 
     55 | The quick brown fox jumped over the lazy
     56 | dog's back.
     57 | 
     58 | ### Header 3
     59 | 
     60 | > This is a blockquote.
     61 | > 
     62 | > This is the second paragraph in the blockquote.
     63 | >
     64 | > ## This is an H2 in a blockquote
     65 | 
    66 | 67 |

    Output:

    68 | 69 |
    <h1>A First Level Header</h1>
     70 | 
     71 | <h2>A Second Level Header</h2>
     72 | 
     73 | <p>Now is the time for all good men to come to
     74 | the aid of their country. This is just a
     75 | regular paragraph.</p>
     76 | 
     77 | <p>The quick brown fox jumped over the lazy
     78 | dog's back.</p>
     79 | 
     80 | <h3>Header 3</h3>
     81 | 
     82 | <blockquote>
     83 |     <p>This is a blockquote.</p>
     84 | 
     85 |     <p>This is the second paragraph in the blockquote.</p>
     86 | 
     87 |     <h2>This is an H2 in a blockquote</h2>
     88 | </blockquote>
     89 | 
    90 | 91 |

    Phrase Emphasis

    92 | 93 |

    Markdown uses asterisks and underscores to indicate spans of emphasis.

    94 | 95 |

    Markdown:

    96 | 97 |
    Some of these words *are emphasized*.
     98 | Some of these words _are emphasized also_.
     99 | 
    100 | Use two asterisks for **strong emphasis**.
    101 | Or, if you prefer, __use two underscores instead__.
    102 | 
    103 | 104 |

    Output:

    105 | 106 |
    <p>Some of these words <em>are emphasized</em>.
    107 | Some of these words <em>are emphasized also</em>.</p>
    108 | 
    109 | <p>Use two asterisks for <strong>strong emphasis</strong>.
    110 | Or, if you prefer, <strong>use two underscores instead</strong>.</p>
    111 | 
    112 | 113 |

    Lists

    114 | 115 |

    Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, 116 | +, and -) as list markers. These three markers are 117 | interchangable; this:

    118 | 119 |
    *   Candy.
    120 | *   Gum.
    121 | *   Booze.
    122 | 
    123 | 124 |

    this:

    125 | 126 |
    +   Candy.
    127 | +   Gum.
    128 | +   Booze.
    129 | 
    130 | 131 |

    and this:

    132 | 133 |
    -   Candy.
    134 | -   Gum.
    135 | -   Booze.
    136 | 
    137 | 138 |

    all produce the same output:

    139 | 140 |
    <ul>
    141 | <li>Candy.</li>
    142 | <li>Gum.</li>
    143 | <li>Booze.</li>
    144 | </ul>
    145 | 
    146 | 147 |

    Ordered (numbered) lists use regular numbers, followed by periods, as 148 | list markers:

    149 | 150 |
    1.  Red
    151 | 2.  Green
    152 | 3.  Blue
    153 | 
    154 | 155 |

    Output:

    156 | 157 |
    <ol>
    158 | <li>Red</li>
    159 | <li>Green</li>
    160 | <li>Blue</li>
    161 | </ol>
    162 | 
    163 | 164 |

    If you put blank lines between items, you'll get <p> tags for the 165 | list item text. You can create multi-paragraph list items by indenting 166 | the paragraphs by 4 spaces or 1 tab:

    167 | 168 |
    *   A list item.
    169 | 
    170 |     With multiple paragraphs.
    171 | 
    172 | *   Another item in the list.
    173 | 
    174 | 175 |

    Output:

    176 | 177 |
    <ul>
    178 | <li><p>A list item.</p>
    179 | <p>With multiple paragraphs.</p></li>
    180 | <li><p>Another item in the list.</p></li>
    181 | </ul>
    182 | 
    183 | 184 |

    Links

    185 | 186 |

    Markdown supports two styles for creating links: inline and 187 | reference. With both styles, you use square brackets to delimit the 188 | text you want to turn into a link.

    189 | 190 |

    Inline-style links use parentheses immediately after the link text. 191 | For example:

    192 | 193 |
    This is an [example link](http://example.com/).
    194 | 
    195 | 196 |

    Output:

    197 | 198 |
    <p>This is an <a href="http://example.com/">
    199 | example link</a>.</p>
    200 | 
    201 | 202 |

    Optionally, you may include a title attribute in the parentheses:

    203 | 204 |
    This is an [example link](http://example.com/ "With a Title").
    205 | 
    206 | 207 |

    Output:

    208 | 209 |
    <p>This is an <a href="http://example.com/" title="With a Title">
    210 | example link</a>.</p>
    211 | 
    212 | 213 |

    Reference-style links allow you to refer to your links by names, which 214 | you define elsewhere in your document:

    215 | 216 |
    I get 10 times more traffic from [Google][1] than from
    217 | [Yahoo][2] or [MSN][3].
    218 | 
    219 | [1]: http://google.com/        "Google"
    220 | [2]: http://search.yahoo.com/  "Yahoo Search"
    221 | [3]: http://search.msn.com/    "MSN Search"
    222 | 
    223 | 224 |

    Output:

    225 | 226 |
    <p>I get 10 times more traffic from <a href="http://google.com/"
    227 | title="Google">Google</a> than from <a href="http://search.yahoo.com/"
    228 | title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
    229 | title="MSN Search">MSN</a>.</p>
    230 | 
    231 | 232 |

    The title attribute is optional. Link names may contain letters, 233 | numbers and spaces, but are not case sensitive:

    234 | 235 |
    I start my morning with a cup of coffee and
    236 | [The New York Times][NY Times].
    237 | 
    238 | [ny times]: http://www.nytimes.com/
    239 | 
    240 | 241 |

    Output:

    242 | 243 |
    <p>I start my morning with a cup of coffee and
    244 | <a href="http://www.nytimes.com/">The New York Times</a>.</p>
    245 | 
    246 | 247 |

    Images

    248 | 249 |

    Image syntax is very much like link syntax.

    250 | 251 |

    Inline (titles are optional):

    252 | 253 |
    ![alt text](/path/to/img.jpg "Title")
    254 | 
    255 | 256 |

    Reference-style:

    257 | 258 |
    ![alt text][id]
    259 | 
    260 | [id]: /path/to/img.jpg "Title"
    261 | 
    262 | 263 |

    Both of the above examples produce the same output:

    264 | 265 |
    <img src="/path/to/img.jpg" alt="alt text" title="Title" />
    266 | 
    267 | 268 |

    Code

    269 | 270 |

    In a regular paragraph, you can create code span by wrapping text in 271 | backtick quotes. Any ampersands (&) and angle brackets (< or 272 | >) will automatically be translated into HTML entities. This makes 273 | it easy to use Markdown to write about HTML example code:

    274 | 275 |
    I strongly recommend against using any `<blink>` tags.
    276 | 
    277 | I wish SmartyPants used named entities like `&mdash;`
    278 | instead of decimal-encoded entites like `&#8212;`.
    279 | 
    280 | 281 |

    Output:

    282 | 283 |
    <p>I strongly recommend against using any
    284 | <code>&lt;blink&gt;</code> tags.</p>
    285 | 
    286 | <p>I wish SmartyPants used named entities like
    287 | <code>&amp;mdash;</code> instead of decimal-encoded
    288 | entites like <code>&amp;#8212;</code>.</p>
    289 | 
    290 | 291 |

    To specify an entire block of pre-formatted code, indent every line of 292 | the block by 4 spaces or 1 tab. Just like with code spans, &, <, 293 | and > characters will be escaped automatically.

    294 | 295 |

    Markdown:

    296 | 297 |
    If you want your page to validate under XHTML 1.0 Strict,
    298 | you've got to put paragraph tags in your blockquotes:
    299 | 
    300 |     <blockquote>
    301 |         <p>For example.</p>
    302 |     </blockquote>
    303 | 
    304 | 305 |

    Output:

    306 | 307 |
    <p>If you want your page to validate under XHTML 1.0 Strict,
    308 | you've got to put paragraph tags in your blockquotes:</p>
    309 | 
    310 | <pre><code>&lt;blockquote&gt;
    311 |     &lt;p&gt;For example.&lt;/p&gt;
    312 | &lt;/blockquote&gt;
    313 | </code></pre>
    314 | 
    315 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | Redcarpet 2 is written with sugar, spice and everything nice 2 | ============================================================ 3 | 4 | Redcarpet is Ruby library for Markdown processing that smells like 5 | butterflies and popcorn. 6 | 7 | Redcarpet used to be a drop-in replacement for Redcloth. This is no longer the 8 | case since version 2 -- it now has its own API, but retains the old name. Yes, 9 | that does mean that Redcarpet 2 is not backwards-compatible with the 1.X 10 | versions. 11 | 12 | Redcarpet is powered by the Sundown library, which can be found at 13 | 14 | https://www.github.com/tanoku/sundown 15 | 16 | You might want to find out more about Sundown to see what makes this Ruby 17 | library so awesome. 18 | 19 | This library is written by people 20 | ------------------------------------------------------- 21 | 22 | Redcarpet 2 has been rewritten from scratch by Vicent Martí (@tanoku). Why 23 | are you not following me on Twitter? 24 | 25 | Redcarpet would not be possible without the Sundown library and its authors 26 | (Natacha Porté, Vicent Martí, and its many awesome contributors). 27 | 28 | You can totally install it as a Gem 29 | ----------------------------------- 30 | 31 | Redcarpet is readily available as a Ruby gem. It will build some native 32 | extensions, but the parser is standalone and requires no installed libraries. 33 | 34 | $ [sudo] gem install redcarpet 35 | 36 | The Redcarpet source (including Sundown as a submodule) is available at GitHub: 37 | 38 | $ git clone git://github.com/tanoku/redcarpet.git 39 | 40 | And it's like *really* simple to use 41 | ------------------------------------ 42 | 43 | The core of the Redcarpet library is the `Redcarpet::Markdown` class. Each 44 | instance of the class is attached to a `Renderer` object; the Markdown class 45 | performs parsing of a document and uses the attached renderer to generate 46 | output. 47 | 48 | The `Markdown` object is encouraged to be instantiated once with the required 49 | settings, and reused between parses. 50 | 51 | Markdown.new(renderer, extensions={}) 52 | 53 | Initializes a Markdown parser 54 | 55 | renderer - a renderer object, inheriting from Redcarpet::Render::Base. 56 | If the given object has not been instantiated, the library 57 | will do it with default arguments. 58 | 59 | extensions - a hash containing the Markdown extensions which the parser 60 | will identify. The following extensions are accepted: 61 | 62 | :no_intra_emphasis - do not parse emphasis inside of words. 63 | Strings such as `foo_bar_baz` will not generate `` 64 | tags. 65 | 66 | :tables - parse tables, PHP-Markdown style 67 | 68 | :fenced_code_blocks - parse fenced code blocks, PHP-Markdown 69 | style .Blocks delimited with 3 or more `~` or backticks 70 | will be considered as code, without the need to be 71 | indented. An optional language name may be added at the 72 | end of the opening fence for the code block 73 | 74 | :autolink - parse links even when they are not enclosed in 75 | `<>` characters. Autolinks for the http, https and ftp 76 | protocols will be automatically detected. Email addresses 77 | are also handled, and http links without protocol, but 78 | starting with `www.` 79 | 80 | :strikethrough - parse strikethrough, PHP-Markdown style 81 | Two `~` characters mark the start of a strikethrough, 82 | e.g. `this is ~~good~~ bad` 83 | 84 | :lax_html_blocks - HTML blocks do not require to be surrounded 85 | by an empty line as in the Markdown standard. 86 | 87 | :space_after_headers - A space is always required between the 88 | hash at the beginning of a header and its name, e.g. 89 | `#this is my header` would not be a valid header. 90 | 91 | :superscript - parse superscripts after the `^` character; 92 | contiguous superscripts are nested together, and complex 93 | values can be enclosed in parenthesis, 94 | e.g. `this is the 2^(nd) time` 95 | 96 | Example: 97 | 98 | markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, 99 | :autolink => true, :space_after_headers => true) 100 | 101 | Rendering with the `Markdown` object is done through `Markdown#render`. 102 | Unlike in the RedCloth API, the text to render is passed as an argument 103 | and not stored inside the `Markdown` instance, to encourage reusability. 104 | 105 | Markdown.render(text) 106 | 107 | Render a Markdown document with the attached renderer 108 | 109 | text - a Markdown document 110 | 111 | Example: 112 | 113 | markdown.render("This is *bongos*, indeed.") 114 | #=> "

    This is bongos, indeed

    " 115 | 116 | 117 | Darling, I packed you a couple renderers for lunch 118 | -------------------------------------------------- 119 | 120 | Redcarpet comes with two built-in renderers, `Redcarpet::Render::HTML` and 121 | `Redcarpet::Render::XHTML`, which output HTML and XHTML, respectively. These 122 | renderers are actually implemented in C, and hence offer a brilliant 123 | performance, several degrees of magnitude faster than other Ruby Markdown 124 | solutions. 125 | 126 | All the rendering flags that previously applied only to HTML output have 127 | now been moved to the `Render::HTML` class, and may be enabled when 128 | instantiating the renderer: 129 | 130 | Render::HTML.new(render_options={}) 131 | 132 | Initializes an HTML renderer. The following flags are available: 133 | 134 | :filter_html - do not allow any user-inputted HTML in the output 135 | 136 | :no_images - do not generate any `` tags 137 | 138 | :no_links - do not generate any `` tags 139 | 140 | :no_styles - do not generate any `