├── .npmignore ├── .gitignore ├── test ├── new │ ├── escaped_angles.text │ ├── escaped_angles.html │ ├── gfm_del.text │ ├── not_a_link.text │ ├── lazy_blockquotes.text │ ├── gfm_del.html │ ├── not_a_link.html │ ├── same_bullet.text │ ├── gfm_em.text │ ├── nested_code.text │ ├── nested_square_link.text │ ├── ref_paren.text │ ├── case_insensitive_refs.html │ ├── case_insensitive_refs.text │ ├── nested_code.html │ ├── autolink_lines.text │ ├── gfm_em.html │ ├── ref_paren.html │ ├── gfm_break.breaks.text │ ├── nested_em.text │ ├── gfm_break.breaks.html │ ├── gfm_links.text │ ├── list_item_text.text │ ├── hr_list_break.text │ ├── nested_square_link.html │ ├── lazy_blockquotes.html │ ├── same_bullet.html │ ├── list_item_text.html │ ├── blockquote_list_item.text │ ├── autolink_lines.html │ ├── nested_em.html │ ├── gfm_links.html │ ├── hr_list_break.html │ ├── blockquote_list_item.html │ ├── text.smartypants.text │ ├── text.smartypants.html │ ├── tricky_list.text │ ├── def_blocks.text │ ├── double_link.text │ ├── double_link.html │ ├── gfm_code.text │ ├── gfm_code.html │ ├── def_blocks.html │ ├── tricky_list.html │ ├── loose_lists.text │ ├── toplevel_paragraphs.gfm.text │ ├── gfm_tables.text │ ├── toplevel_paragraphs.gfm.html │ ├── gfm_code_hr_list.text │ ├── loose_lists.html │ ├── gfm_code_hr_list.html │ ├── main.text │ ├── main.html │ └── gfm_tables.html ├── tests │ ├── escaped_angles.text │ ├── escaped_angles.html │ ├── gfm_del.text │ ├── not_a_link.text │ ├── lazy_blockquotes.text │ ├── not_a_link.html │ ├── gfm_del.html │ ├── nested_code.text │ ├── ref_paren.text │ ├── same_bullet.text │ ├── case_insensitive_refs.text │ ├── gfm_em.text │ ├── nested_square_link.text │ ├── autolink_lines.text │ ├── case_insensitive_refs.html │ ├── gfm_em.html │ ├── nested_code.html │ ├── ref_paren.html │ ├── gfm_break.breaks.text │ ├── nested_blockquotes.text │ ├── gfm_break.breaks.html │ ├── list_item_text.text │ ├── nested_em.text │ ├── gfm_links.text │ ├── nested_square_link.html │ ├── hr_list_break.text │ ├── lazy_blockquotes.html │ ├── same_bullet.html │ ├── list_item_text.html │ ├── blockquote_list_item.text │ ├── autolink_lines.html │ ├── tidyness.text │ ├── nested_em.html │ ├── gfm_links.html │ ├── blockquote_list_item.html │ ├── hr_list_break.html │ ├── strong_and_em_together.text │ ├── literal_quotes_in_titles.text │ ├── nested_blockquotes.html │ ├── text.smartypants.text │ ├── tidyness.html │ ├── text.smartypants.html │ ├── code_spans.text │ ├── literal_quotes_in_titles.html │ ├── blockquotes_with_code_blocks.text │ ├── tricky_list.text │ ├── def_blocks.text │ ├── double_link.text │ ├── inline_html_advanced.text │ ├── inline_html_comments.text │ ├── inline_html_advanced.html │ ├── strong_and_em_together.html │ ├── code_spans.html │ ├── inline_html_comments.html │ ├── code_blocks.text │ ├── hard_wrapped_paragraphs_with_list_like_lines.nogfm.text │ ├── double_link.html │ ├── hard_wrapped_paragraphs_with_list_like_lines.nogfm.html │ ├── blockquotes_with_code_blocks.html │ ├── gfm_code.text │ ├── links_shortcut_references.html │ ├── auto_links.text │ ├── links_shortcut_references.text │ ├── gfm_code.html │ ├── def_blocks.html │ ├── code_blocks.html │ ├── links_inline_style.text │ ├── tabs.text │ ├── tricky_list.html │ ├── amps_and_angles_encoding.text │ ├── loose_lists.text │ ├── tabs.html │ ├── toplevel_paragraphs.gfm.text │ ├── links_inline_style.html │ ├── horizontal_rules.text │ ├── gfm_tables.text │ ├── amps_and_angles_encoding.html │ ├── auto_links.html │ ├── toplevel_paragraphs.gfm.html │ ├── horizontal_rules.html │ ├── gfm_code_hr_list.text │ ├── inline_html_simple.text │ ├── loose_lists.html │ ├── gfm_code_hr_list.html │ ├── inline_html_simple.html │ ├── links_reference_style.text │ ├── main.text │ ├── main.html │ ├── links_reference_style.html │ ├── gfm_tables.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 ├── original │ ├── nested_blockquotes.text │ ├── tidyness.text │ ├── strong_and_em_together.text │ ├── literal_quotes_in_titles.text │ ├── nested_blockquotes.html │ ├── tidyness.html │ ├── literal_quotes_in_titles.html │ ├── code_spans.text │ ├── 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 │ ├── inline_html_comments.html │ ├── code_blocks.text │ ├── hard_wrapped_paragraphs_with_list_like_lines.html │ ├── blockquotes_with_code_blocks.html │ ├── links_shortcut_references.html │ ├── auto_links.text │ ├── links_shortcut_references.text │ ├── code_blocks.html │ ├── links_inline_style.text │ ├── tabs.text │ ├── amps_and_angles_encoding.text │ ├── tabs.html │ ├── links_inline_style.html │ ├── amps_and_angles_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 ├── browser │ ├── index.html │ ├── index.js │ └── test.js ├── README └── index.js ├── index.js ├── Makefile ├── component.json ├── package.json ├── LICENSE ├── doc └── broken.md ├── README.md ├── marked.min.js └── lib └── marked.js /.npmignore: -------------------------------------------------------------------------------- 1 | .git* 2 | test/ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.idea/ -------------------------------------------------------------------------------- /test/new/escaped_angles.text: -------------------------------------------------------------------------------- 1 | \> 2 | -------------------------------------------------------------------------------- /test/tests/escaped_angles.text: -------------------------------------------------------------------------------- 1 | \> 2 | -------------------------------------------------------------------------------- /test/new/escaped_angles.html: -------------------------------------------------------------------------------- 1 |

>

2 | -------------------------------------------------------------------------------- /test/tests/escaped_angles.html: -------------------------------------------------------------------------------- 1 |

>

2 | -------------------------------------------------------------------------------- /test/new/gfm_del.text: -------------------------------------------------------------------------------- 1 | hello ~~hi~~ world 2 | -------------------------------------------------------------------------------- /test/new/not_a_link.text: -------------------------------------------------------------------------------- 1 | \[test](not a link) 2 | -------------------------------------------------------------------------------- /test/tests/gfm_del.text: -------------------------------------------------------------------------------- 1 | hello ~~hi~~ world 2 | -------------------------------------------------------------------------------- /test/new/lazy_blockquotes.text: -------------------------------------------------------------------------------- 1 | > hi there 2 | bud 3 | -------------------------------------------------------------------------------- /test/tests/not_a_link.text: -------------------------------------------------------------------------------- 1 | \[test](not a link) 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/marked'); 2 | -------------------------------------------------------------------------------- /test/new/gfm_del.html: -------------------------------------------------------------------------------- 1 |

hello hi world

2 | -------------------------------------------------------------------------------- /test/new/not_a_link.html: -------------------------------------------------------------------------------- 1 |

[test](not a link)

2 | -------------------------------------------------------------------------------- /test/new/same_bullet.text: -------------------------------------------------------------------------------- 1 | * test 2 | + test 3 | - test 4 | -------------------------------------------------------------------------------- /test/tests/lazy_blockquotes.text: -------------------------------------------------------------------------------- 1 | > hi there 2 | bud 3 | -------------------------------------------------------------------------------- /test/tests/not_a_link.html: -------------------------------------------------------------------------------- 1 |

[test](not a link)

2 | -------------------------------------------------------------------------------- /test/new/gfm_em.text: -------------------------------------------------------------------------------- 1 | These words should_not_be_emphasized. 2 | -------------------------------------------------------------------------------- /test/new/nested_code.text: -------------------------------------------------------------------------------- 1 | ````` hi ther `` ok ``` ````` 2 | -------------------------------------------------------------------------------- /test/new/nested_square_link.text: -------------------------------------------------------------------------------- 1 | [the `]` character](/url) 2 | -------------------------------------------------------------------------------- /test/new/ref_paren.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [hi]: /url (there) 4 | -------------------------------------------------------------------------------- /test/tests/gfm_del.html: -------------------------------------------------------------------------------- 1 |

hello hi world

2 | -------------------------------------------------------------------------------- /test/tests/nested_code.text: -------------------------------------------------------------------------------- 1 | ````` hi ther `` ok ``` ````` 2 | -------------------------------------------------------------------------------- /test/tests/ref_paren.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [hi]: /url (there) 4 | -------------------------------------------------------------------------------- /test/tests/same_bullet.text: -------------------------------------------------------------------------------- 1 | * test 2 | + test 3 | - test 4 | -------------------------------------------------------------------------------- /test/new/case_insensitive_refs.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/new/case_insensitive_refs.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [HI]: /url 4 | -------------------------------------------------------------------------------- /test/new/nested_code.html: -------------------------------------------------------------------------------- 1 |

hi ther `` ok ```

2 | -------------------------------------------------------------------------------- /test/tests/case_insensitive_refs.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [HI]: /url 4 | -------------------------------------------------------------------------------- /test/tests/gfm_em.text: -------------------------------------------------------------------------------- 1 | These words should_not_be_emphasized. 2 | -------------------------------------------------------------------------------- /test/tests/nested_square_link.text: -------------------------------------------------------------------------------- 1 | [the `]` character](/url) 2 | -------------------------------------------------------------------------------- /test/new/autolink_lines.text: -------------------------------------------------------------------------------- 1 | hello world 2 | 3 | -------------------------------------------------------------------------------- /test/new/gfm_em.html: -------------------------------------------------------------------------------- 1 |

These words should_not_be_emphasized.

2 | -------------------------------------------------------------------------------- /test/new/ref_paren.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/tests/autolink_lines.text: -------------------------------------------------------------------------------- 1 | hello world 2 | 3 | -------------------------------------------------------------------------------- /test/tests/case_insensitive_refs.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/tests/gfm_em.html: -------------------------------------------------------------------------------- 1 |

These words should_not_be_emphasized.

2 | -------------------------------------------------------------------------------- /test/tests/nested_code.html: -------------------------------------------------------------------------------- 1 |

hi ther `` ok ```

2 | -------------------------------------------------------------------------------- /test/tests/ref_paren.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/new/gfm_break.breaks.text: -------------------------------------------------------------------------------- 1 | Look at the 2 | pretty line 3 | breaks. 4 | -------------------------------------------------------------------------------- /test/new/nested_em.text: -------------------------------------------------------------------------------- 1 | *test **test** test* 2 | 3 | _test __test__ test_ 4 | -------------------------------------------------------------------------------- /test/tests/gfm_break.breaks.text: -------------------------------------------------------------------------------- 1 | Look at the 2 | pretty line 3 | breaks. 4 | -------------------------------------------------------------------------------- /test/tests/nested_blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /test/new/gfm_break.breaks.html: -------------------------------------------------------------------------------- 1 |

Look at the
pretty line
breaks.

2 | -------------------------------------------------------------------------------- /test/new/gfm_links.text: -------------------------------------------------------------------------------- 1 | This should be a link: http://example.com/hello-world. 2 | -------------------------------------------------------------------------------- /test/new/list_item_text.text: -------------------------------------------------------------------------------- 1 | * item1 2 | 3 | * item2 4 | 5 | text 6 | -------------------------------------------------------------------------------- /test/original/nested_blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /test/tests/gfm_break.breaks.html: -------------------------------------------------------------------------------- 1 |

Look at the
pretty line
breaks.

2 | -------------------------------------------------------------------------------- /test/tests/list_item_text.text: -------------------------------------------------------------------------------- 1 | * item1 2 | 3 | * item2 4 | 5 | text 6 | -------------------------------------------------------------------------------- /test/tests/nested_em.text: -------------------------------------------------------------------------------- 1 | *test **test** test* 2 | 3 | _test __test__ test_ 4 | -------------------------------------------------------------------------------- /test/tests/gfm_links.text: -------------------------------------------------------------------------------- 1 | This should be a link: http://example.com/hello-world. 2 | -------------------------------------------------------------------------------- /test/new/hr_list_break.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | * how 4 | are 5 | * * * 6 | you today? 7 | -------------------------------------------------------------------------------- /test/new/nested_square_link.html: -------------------------------------------------------------------------------- 1 |

the ] character

2 | -------------------------------------------------------------------------------- /test/tests/nested_square_link.html: -------------------------------------------------------------------------------- 1 |

the ] character

2 | -------------------------------------------------------------------------------- /test/new/lazy_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

hi there 3 | bud

4 |
5 | -------------------------------------------------------------------------------- /test/new/same_bullet.html: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /test/tests/hr_list_break.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | * how 4 | are 5 | * * * 6 | you today? 7 | -------------------------------------------------------------------------------- /test/tests/lazy_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

hi there 3 | bud

4 |
5 | -------------------------------------------------------------------------------- /test/new/list_item_text.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/tests/same_bullet.html: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /test/new/blockquote_list_item.text: -------------------------------------------------------------------------------- 1 | This fails in markdown.pl and upskirt: 2 | 3 | * hello 4 | > world 5 | -------------------------------------------------------------------------------- /test/tests/list_item_text.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/new/autolink_lines.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | http://example.com 3 |

4 | -------------------------------------------------------------------------------- /test/tests/blockquote_list_item.text: -------------------------------------------------------------------------------- 1 | This fails in markdown.pl and upskirt: 2 | 3 | * hello 4 | > world 5 | -------------------------------------------------------------------------------- /test/tests/autolink_lines.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | http://example.com 3 |

4 | -------------------------------------------------------------------------------- /test/tests/tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /test/original/tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /test/new/nested_em.html: -------------------------------------------------------------------------------- 1 |

test test test

2 | 3 |

test test test

4 | -------------------------------------------------------------------------------- /test/new/gfm_links.html: -------------------------------------------------------------------------------- 1 |

This should be a link: 2 | http://example.com/hello-world.

3 | -------------------------------------------------------------------------------- /test/tests/nested_em.html: -------------------------------------------------------------------------------- 1 |

test test test

2 | 3 |

test test test

4 | -------------------------------------------------------------------------------- /test/tests/gfm_links.html: -------------------------------------------------------------------------------- 1 |

This should be a link: 2 | http://example.com/hello-world.

3 | -------------------------------------------------------------------------------- /test/new/hr_list_break.html: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | 10 |

you today?

11 | -------------------------------------------------------------------------------- /test/new/blockquote_list_item.html: -------------------------------------------------------------------------------- 1 |

This fails in markdown.pl and upskirt:

2 | 3 | 4 | -------------------------------------------------------------------------------- /test/tests/blockquote_list_item.html: -------------------------------------------------------------------------------- 1 |

This fails in markdown.pl and upskirt:

2 | 3 | 4 | -------------------------------------------------------------------------------- /test/tests/hr_list_break.html: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | 10 |

you today?

11 | -------------------------------------------------------------------------------- /test/browser/index.html: -------------------------------------------------------------------------------- 1 | 2 | marked tests 3 |

testing...

4 | 5 | 6 | -------------------------------------------------------------------------------- /test/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/original/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/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/original/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/new/text.smartypants.text: -------------------------------------------------------------------------------- 1 | Hello world 'how' "are" you -- today... 2 | 3 | "It's a more 'challenging' smartypants test..." 4 | 5 | 'And,' as a bonus -- "one 6 | multiline" test! 7 | -------------------------------------------------------------------------------- /test/original/nested_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /test/tests/nested_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /test/original/tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 |
    4 |
  • asterisk 1
  • 5 |
  • asterisk 2
  • 6 |
  • asterisk 3
  • 7 |
8 |
9 | -------------------------------------------------------------------------------- /test/tests/text.smartypants.text: -------------------------------------------------------------------------------- 1 | Hello world 'how' "are" you -- today... 2 | 3 | "It's a more 'challenging' smartypants test..." 4 | 5 | 'And,' as a bonus -- "one 6 | multiline" test! 7 | -------------------------------------------------------------------------------- /test/tests/tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 |
    4 |
  • asterisk 1
  • 5 |
  • asterisk 2
  • 6 |
  • asterisk 3
  • 7 |
8 |
9 | -------------------------------------------------------------------------------- /test/new/text.smartypants.html: -------------------------------------------------------------------------------- 1 |

Hello world ‘how’ “are” you — today…

2 | 3 |

“It’s a more ‘challenging’ smartypants test…”

4 | 5 |

‘And,’ as a bonus — “one 6 | multiline” test!

7 | -------------------------------------------------------------------------------- /test/tests/text.smartypants.html: -------------------------------------------------------------------------------- 1 |

Hello world ‘how’ “are” you — today…

2 | 3 |

“It’s a more ‘challenging’ smartypants test…”

4 | 5 |

‘And,’ as a bonus — “one 6 | multiline” test!

7 | -------------------------------------------------------------------------------- /test/original/literal_quotes_in_titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /test/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/tests/literal_quotes_in_titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /test/original/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/new/tricky_list.text: -------------------------------------------------------------------------------- 1 | **hello** _world_ 2 | 3 | * hello world 4 | 5 | **hello** _world_ 6 | 7 | * hello world 8 | 9 | **hello** _world_ 10 | 11 | * Hello world 12 | 13 | **hello** _world_ 14 | 15 | * hello world 16 | -------------------------------------------------------------------------------- /test/original/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/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/tests/tricky_list.text: -------------------------------------------------------------------------------- 1 | **hello** _world_ 2 | 3 | * hello world 4 | 5 | **hello** _world_ 6 | 7 | * hello world 8 | 9 | **hello** _world_ 10 | 11 | * Hello world 12 | 13 | **hello** _world_ 14 | 15 | * hello world 16 | -------------------------------------------------------------------------------- /test/new/def_blocks.text: -------------------------------------------------------------------------------- 1 | > hello 2 | > [1]: hello 3 | 4 | * * * 5 | 6 | > hello 7 | [2]: hello 8 | 9 | 10 | * hello 11 | * [3]: hello 12 | 13 | 14 | * hello 15 | [4]: hello 16 | 17 | 18 | > foo 19 | > bar 20 | [1]: foo 21 | > bar 22 | -------------------------------------------------------------------------------- /test/tests/def_blocks.text: -------------------------------------------------------------------------------- 1 | > hello 2 | > [1]: hello 3 | 4 | * * * 5 | 6 | > hello 7 | [2]: hello 8 | 9 | 10 | * hello 11 | * [3]: hello 12 | 13 | 14 | * hello 15 | [4]: hello 16 | 17 | 18 | > foo 19 | > bar 20 | [1]: foo 21 | > bar 22 | -------------------------------------------------------------------------------- /test/new/double_link.text: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 | Already linked: [http://example.com/](http://example.com/). 4 | 5 | Already linked: **http://example.com/**. 6 | -------------------------------------------------------------------------------- /test/tests/double_link.text: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 | Already linked: [http://example.com/](http://example.com/). 4 | 5 | Already linked: **http://example.com/**. 6 | -------------------------------------------------------------------------------- /test/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/original/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/tests/inline_html_comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /test/original/inline_html_comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @cp lib/marked.js marked.js 3 | @uglifyjs --comments '/\*[^\0]+?Copyright[^\0]+?\*/' -o marked.min.js lib/marked.js 4 | 5 | clean: 6 | @rm marked.js 7 | @rm marked.min.js 8 | 9 | bench: 10 | @node test --bench 11 | 12 | .PHONY: clean all 13 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | In this directory: 2 | 3 | # 4 | # MarkdownTester -- Run tests for Markdown implementations 5 | # 6 | # Copyright (c) 2004-2005 John Gruber 7 | # 8 | # 9 | 10 | Partially modified for testing purposes. 11 | -------------------------------------------------------------------------------- /test/original/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/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/original/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/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/original/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/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/original/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/original/inline_html_comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 | 8 | 9 |

Paragraph two.

10 | 11 | 12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /test/tests/inline_html_comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 | 8 | 9 |

Paragraph two.

10 | 11 | 12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /test/new/double_link.html: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 |

Already linked: http://example.com/.

4 | 5 |

Already linked: http://example.com/.

6 | -------------------------------------------------------------------------------- /test/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 15 | -------------------------------------------------------------------------------- /test/tests/hard_wrapped_paragraphs_with_list_like_lines.nogfm.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/original/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 15 | -------------------------------------------------------------------------------- /test/tests/double_link.html: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 |

Already linked: http://example.com/.

4 | 5 |

Already linked: http://example.com/.

6 | -------------------------------------------------------------------------------- /test/original/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/original/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/tests/hard_wrapped_paragraphs_with_list_like_lines.nogfm.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 | -------------------------------------------------------------------------------- /component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "marked", 3 | "version": "0.3.2", 4 | "repo": "DemocracyOS/marked", 5 | "description": "A markdown parser built for speed", 6 | "keywords": ["markdown", "markup", "html"], 7 | "scripts": ["lib/marked.js"], 8 | "main": "lib/marked.js", 9 | "license": "MIT" 10 | } 11 | -------------------------------------------------------------------------------- /test/new/gfm_code.text: -------------------------------------------------------------------------------- 1 | ``` js 2 | var a = 'hello'; 3 | console.log(a + ' world'); 4 | ``` 5 | 6 | ~~~bash 7 | echo "hello, ${WORLD}" 8 | ~~~ 9 | 10 | ```````longfence 11 | Q: What do you call a tall person who sells stolen goods? 12 | ``````` 13 | 14 | ~~~~~~~~~~ ManyTildes 15 | A longfence! 16 | ~~~~~~~~~~ 17 | -------------------------------------------------------------------------------- /test/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/tests/gfm_code.text: -------------------------------------------------------------------------------- 1 | ``` js 2 | var a = 'hello'; 3 | console.log(a + ' world'); 4 | ``` 5 | 6 | ~~~bash 7 | echo "hello, ${WORLD}" 8 | ~~~ 9 | 10 | ```````longfence 11 | Q: What do you call a tall person who sells stolen goods? 12 | ``````` 13 | 14 | ~~~~~~~~~~ ManyTildes 15 | A longfence! 16 | ~~~~~~~~~~ 17 | -------------------------------------------------------------------------------- /test/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/original/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/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: 14 | -------------------------------------------------------------------------------- /test/original/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: 14 | -------------------------------------------------------------------------------- /test/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/new/gfm_code.html: -------------------------------------------------------------------------------- 1 |
var a = 'hello';
2 | console.log(a + ' world');
3 |
echo "hello, ${WORLD}"
4 |
Q: What do you call a tall person who sells stolen goods?
5 |
A longfence!
6 | -------------------------------------------------------------------------------- /test/original/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/tests/gfm_code.html: -------------------------------------------------------------------------------- 1 |
var a = 'hello';
2 | console.log(a + ' world');
3 |
echo "hello, ${WORLD}"
4 |
Q: What do you call a tall person who sells stolen goods?
5 |
A longfence!
6 | -------------------------------------------------------------------------------- /test/new/def_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

hello 3 | [1]: hello

4 |
5 | 6 |
7 | 8 |
9 |

hello

10 |
11 | 12 | 13 |
    14 |
  • hello
  • 15 |
  • [3]: hello
  • 16 |
17 | 18 | 19 |
    20 |
  • hello
  • 21 |
22 | 23 | 24 |
25 |

foo 26 | bar 27 | bar

28 |
29 | -------------------------------------------------------------------------------- /test/tests/def_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

hello 3 | [1]: hello

4 |
5 | 6 |
7 | 8 |
9 |

hello

10 |
11 | 12 | 13 |
    14 |
  • hello
  • 15 |
  • [3]: hello
  • 16 |
17 | 18 | 19 |
    20 |
  • hello
  • 21 |
22 | 23 | 24 |
25 |

foo 26 | bar 27 | bar

28 |
29 | -------------------------------------------------------------------------------- /test/original/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/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/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 | [URL and title]( /url/has space ). 12 | 13 | [URL and title]( /url/has space/ "url has space and title"). 14 | 15 | [Empty](). 16 | -------------------------------------------------------------------------------- /test/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/original/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 | [URL and title]( /url/has space ). 12 | 13 | [URL and title]( /url/has space/ "url has space and title"). 14 | 15 | [Empty](). 16 | -------------------------------------------------------------------------------- /test/original/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/new/tricky_list.html: -------------------------------------------------------------------------------- 1 |

hello world

2 | 3 |
    4 |
  • hello world
  • 5 |
6 | 7 |

hello world

8 | 9 |
    10 |
  • hello world
  • 11 |
12 | 13 |

hello world

14 | 15 |
    16 |
  • Hello world
  • 17 |
18 | 19 |

hello world

20 | 21 |
    22 |
  • hello world
  • 23 |
24 | -------------------------------------------------------------------------------- /test/tests/tricky_list.html: -------------------------------------------------------------------------------- 1 |

hello world

2 | 3 |
    4 |
  • hello world
  • 5 |
6 | 7 |

hello world

8 | 9 |
    10 |
  • hello world
  • 11 |
12 | 13 |

hello world

14 | 15 |
    16 |
  • Hello world
  • 17 |
18 | 19 |

hello world

20 | 21 |
    22 |
  • hello world
  • 23 |
24 | -------------------------------------------------------------------------------- /test/tests/amps_and_angles_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" 22 | -------------------------------------------------------------------------------- /test/original/amps_and_angles_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" 22 | -------------------------------------------------------------------------------- /test/new/loose_lists.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | 4 | how 5 | are 6 | * you 7 | 8 | 9 | 10 | better behavior: 11 | 12 | * hello 13 | * world 14 | how 15 | 16 | are 17 | you 18 | 19 | * today 20 | * hi 21 | 22 | 23 | 24 | * hello 25 | 26 | * world 27 | * hi 28 | 29 | 30 | 31 | * hello 32 | * world 33 | 34 | * hi 35 | 36 | 37 | 38 | * hello 39 | * world 40 | 41 | how 42 | * hi 43 | 44 | 45 | 46 | * hello 47 | * world 48 | * how 49 | 50 | are 51 | 52 | 53 | 54 | * hello 55 | * world 56 | 57 | * how 58 | 59 | are 60 | -------------------------------------------------------------------------------- /test/new/toplevel_paragraphs.gfm.text: -------------------------------------------------------------------------------- 1 | hello world 2 | how are you 3 | how are you 4 | 5 | hello world 6 | ``` 7 | how are you 8 | ``` 9 | 10 | hello world 11 | * * * 12 | 13 | hello world 14 | # how are you 15 | 16 | hello world 17 | how are you 18 | =========== 19 | 20 | hello world 21 | > how are you 22 | 23 | hello world 24 | * how are you 25 | 26 | hello world 27 |
how are you
28 | 29 | hello world 30 | how are you 31 | 32 | hello [world][how] 33 | [how]: /are/you 34 | 35 |
hello
36 | 37 | hello 38 | -------------------------------------------------------------------------------- /test/original/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/tests/loose_lists.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | 4 | how 5 | are 6 | * you 7 | 8 | 9 | 10 | better behavior: 11 | 12 | * hello 13 | * world 14 | how 15 | 16 | are 17 | you 18 | 19 | * today 20 | * hi 21 | 22 | 23 | 24 | * hello 25 | 26 | * world 27 | * hi 28 | 29 | 30 | 31 | * hello 32 | * world 33 | 34 | * hi 35 | 36 | 37 | 38 | * hello 39 | * world 40 | 41 | how 42 | * hi 43 | 44 | 45 | 46 | * hello 47 | * world 48 | * how 49 | 50 | are 51 | 52 | 53 | 54 | * hello 55 | * world 56 | 57 | * how 58 | 59 | are 60 | -------------------------------------------------------------------------------- /test/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/tests/toplevel_paragraphs.gfm.text: -------------------------------------------------------------------------------- 1 | hello world 2 | how are you 3 | how are you 4 | 5 | hello world 6 | ``` 7 | how are you 8 | ``` 9 | 10 | hello world 11 | * * * 12 | 13 | hello world 14 | # how are you 15 | 16 | hello world 17 | how are you 18 | =========== 19 | 20 | hello world 21 | > how are you 22 | 23 | hello world 24 | * how are you 25 | 26 | hello world 27 |
how are you
28 | 29 | hello world 30 | how are you 31 | 32 | hello [world][how] 33 | [how]: /are/you 34 | 35 |
hello
36 | 37 | hello 38 | -------------------------------------------------------------------------------- /test/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 |

URL and title.

12 | 13 |

URL and title.

14 | 15 |

Empty.

16 | -------------------------------------------------------------------------------- /test/original/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 |

URL and title.

12 | 13 |

URL and title.

14 | 15 |

Empty.

16 | -------------------------------------------------------------------------------- /test/new/gfm_tables.text: -------------------------------------------------------------------------------- 1 | | Heading 1 | Heading 2 2 | | --------- | --------- 3 | | Cell 1 | Cell 2 4 | | Cell 3 | Cell 4 5 | 6 | | Header 1 | Header 2 | Header 3 | Header 4 | 7 | | :------: | -------: | :------- | -------- | 8 | | Cell 1 | Cell 2 | Cell 3 | Cell 4 | 9 | | Cell 5 | Cell 6 | Cell 7 | Cell 8 | 10 | 11 | Test code 12 | 13 | Header 1 | Header 2 14 | -------- | -------- 15 | Cell 1 | Cell 2 16 | Cell 3 | Cell 4 17 | 18 | Header 1|Header 2|Header 3|Header 4 19 | :-------|:------:|-------:|-------- 20 | Cell 1 |Cell 2 |Cell 3 |Cell 4 21 | *Cell 5*|Cell 6 |Cell 7 |Cell 8 22 | -------------------------------------------------------------------------------- /test/original/amps_and_angles_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/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/original/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/tests/gfm_tables.text: -------------------------------------------------------------------------------- 1 | | Heading 1 | Heading 2 2 | | --------- | --------- 3 | | Cell 1 | Cell 2 4 | | Cell 3 | Cell 4 5 | 6 | | Header 1 | Header 2 | Header 3 | Header 4 | 7 | | :------: | -------: | :------- | -------- | 8 | | Cell 1 | Cell 2 | Cell 3 | Cell 4 | 9 | | Cell 5 | Cell 6 | Cell 7 | Cell 8 | 10 | 11 | Test code 12 | 13 | Header 1 | Header 2 14 | -------- | -------- 15 | Cell 1 | Cell 2 16 | Cell 3 | Cell 4 17 | 18 | Header 1|Header 2|Header 3|Header 4 19 | :-------|:------:|-------:|-------- 20 | Cell 1 |Cell 2 |Cell 3 |Cell 4 21 | *Cell 5*|Cell 6 |Cell 7 |Cell 8 22 | -------------------------------------------------------------------------------- /test/tests/amps_and_angles_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/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/original/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/new/toplevel_paragraphs.gfm.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | how are you 3 | how are you

4 | 5 |

hello world

6 |
how are you
7 | 8 |

hello world

9 |
10 | 11 |

hello world

12 |

how are you

13 | 14 |

hello world

15 |

how are you

16 | 17 |

hello world

18 |

how are you

19 | 20 |

hello world

21 |
  • how are you
22 | 23 |

hello world

24 |
how are you
25 | 26 |

hello world 27 | how are you

28 | 29 |

hello world 30 |

31 | 32 |
hello
33 | 34 |

hello

35 | -------------------------------------------------------------------------------- /test/tests/toplevel_paragraphs.gfm.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | how are you 3 | how are you

4 | 5 |

hello world

6 |
how are you
7 | 8 |

hello world

9 |
10 | 11 |

hello world

12 |

how are you

13 | 14 |

hello world

15 |

how are you

16 | 17 |

hello world

18 |

how are you

19 | 20 |

hello world

21 |
  • how are you
22 | 23 |

hello world

24 |
how are you
25 | 26 |

hello world 27 | how are you

28 | 29 |

hello world 30 |

31 | 32 |
hello
33 | 34 |

hello

35 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "marked", 3 | "description": "A markdown parser built for speed", 4 | "author": "Christopher Jeffrey", 5 | "version": "0.3.2", 6 | "main": "./lib/marked.js", 7 | "bin": "./bin/marked", 8 | "man": "./man/marked.1", 9 | "preferGlobal": true, 10 | "repository": "git://github.com/chjj/marked.git", 11 | "homepage": "https://github.com/chjj/marked", 12 | "bugs": { "url": "http://github.com/chjj/marked/issues" }, 13 | "license": "MIT", 14 | "keywords": ["markdown", "markup", "html"], 15 | "tags": ["markdown", "markup", "html"], 16 | "devDependencies": { 17 | "markdown": "*", 18 | "showdown": "*", 19 | "robotskirt": "*" 20 | }, 21 | "scripts": { "test": "node test", "bench": "node test --bench" } 22 | } 23 | -------------------------------------------------------------------------------- /test/original/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 | -------------------------------------------------------------------------------- /test/new/gfm_code_hr_list.text: -------------------------------------------------------------------------------- 1 | ## foo 2 | 3 | 1. bar: 4 | 5 | > - one 6 | - two 7 | - three 8 | - four 9 | - five 10 | 11 | 1. foo: 12 | 13 | ``` 14 | line 1 15 | line 2 16 | ``` 17 | 18 | 1. foo: 19 | 20 | 1. foo `bar` bar: 21 | 22 | ``` erb 23 | some code here 24 | ``` 25 | 26 | 2. foo `bar` bar: 27 | 28 | ``` erb 29 | foo 30 | --- 31 | bar 32 | --- 33 | foo 34 | bar 35 | ``` 36 | 37 | 3. foo `bar` bar: 38 | 39 | ``` html 40 | --- 41 | foo 42 | foo 43 | --- 44 | bar 45 | ``` 46 | 47 | 4. foo `bar` bar: 48 | 49 | foo 50 | --- 51 | bar 52 | 53 | 5. foo 54 | -------------------------------------------------------------------------------- /test/tests/gfm_code_hr_list.text: -------------------------------------------------------------------------------- 1 | ## foo 2 | 3 | 1. bar: 4 | 5 | > - one 6 | - two 7 | - three 8 | - four 9 | - five 10 | 11 | 1. foo: 12 | 13 | ``` 14 | line 1 15 | line 2 16 | ``` 17 | 18 | 1. foo: 19 | 20 | 1. foo `bar` bar: 21 | 22 | ``` erb 23 | some code here 24 | ``` 25 | 26 | 2. foo `bar` bar: 27 | 28 | ``` erb 29 | foo 30 | --- 31 | bar 32 | --- 33 | foo 34 | bar 35 | ``` 36 | 37 | 3. foo `bar` bar: 38 | 39 | ``` html 40 | --- 41 | foo 42 | foo 43 | --- 44 | bar 45 | ``` 46 | 47 | 4. foo `bar` bar: 48 | 49 | foo 50 | --- 51 | bar 52 | 53 | 5. foo 54 | -------------------------------------------------------------------------------- /test/new/loose_lists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • hello 3 | world

    4 | 5 |

    how 6 | are

  • 7 |
  • you
  • 8 |
9 | 10 | 11 | 12 |

better behavior:

13 | 14 |
  • hello

    • world 15 | how

      are 16 | you

    • today

  • hi
17 | 18 | 19 | 20 |
    21 |
  • hello

  • 22 |
  • world

  • 23 |
  • hi
  • 24 |
25 | 26 | 27 | 28 |
    29 |
  • hello
  • 30 |
  • world

  • 31 |
  • hi

  • 32 |
33 | 34 | 35 | 36 |
    37 |
  • hello
  • 38 |
  • world

    39 | 40 |

    how

  • 41 |
  • hi
  • 42 |
43 | 44 | 45 | 46 |
    47 |
  • hello
  • 48 |
  • world
  • 49 |
  • how

    50 | 51 |

    are

  • 52 |
53 | 54 | 55 | 56 |
    57 |
  • hello
  • 58 |
  • world

  • 59 |
  • how

    60 | 61 |

    are

  • 62 |
63 | -------------------------------------------------------------------------------- /test/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/tests/loose_lists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • hello 3 | world

    4 | 5 |

    how 6 | are

  • 7 |
  • you
  • 8 |
9 | 10 | 11 | 12 |

better behavior:

13 | 14 |
  • hello

    • world 15 | how

      are 16 | you

    • today

  • hi
17 | 18 | 19 | 20 |
    21 |
  • hello

  • 22 |
  • world

  • 23 |
  • hi
  • 24 |
25 | 26 | 27 | 28 |
    29 |
  • hello
  • 30 |
  • world

  • 31 |
  • hi

  • 32 |
33 | 34 | 35 | 36 |
    37 |
  • hello
  • 38 |
  • world

    39 | 40 |

    how

  • 41 |
  • hi
  • 42 |
43 | 44 | 45 | 46 |
    47 |
  • hello
  • 48 |
  • world
  • 49 |
  • how

    50 | 51 |

    are

  • 52 |
53 | 54 | 55 | 56 |
    57 |
  • hello
  • 58 |
  • world

  • 59 |
  • how

    60 | 61 |

    are

  • 62 |
63 | -------------------------------------------------------------------------------- /test/original/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/new/gfm_code_hr_list.html: -------------------------------------------------------------------------------- 1 |

foo

2 |
    3 |
  1. bar:

    4 |
    5 |
      6 |
    • one
        7 |
      • two
          8 |
        • three
        • 9 |
        • four
        • 10 |
        • five
        • 11 |
        12 |
      • 13 |
      14 |
    • 15 |
    16 |
    17 |
  2. 18 |
  3. foo:

    19 |
     line 1
    20 |  line 2
    21 |
  4. 22 |
  5. foo:

    23 |
      24 |
    1. foo bar bar:

      25 |
       some code here
      26 | 
      27 |
    2. 28 |
    3. foo bar bar:

      29 |
       foo
      30 |  ---
      31 |  bar
      32 |  ---
      33 |  foo
      34 |  bar
      35 |
    4. 36 |
    5. foo bar bar:

      37 |
       ---
      38 |  foo
      39 |  foo
      40 |  ---
      41 |  bar
      42 |
    6. 43 |
    7. foo bar bar:

      44 |
       foo
      45 |  ---
      46 |  bar
      47 |
    8. 48 |
    9. foo

      49 |
    10. 50 |
    51 |
  6. 52 |
53 | -------------------------------------------------------------------------------- /test/tests/gfm_code_hr_list.html: -------------------------------------------------------------------------------- 1 |

foo

2 |
    3 |
  1. bar:

    4 |
    5 |
      6 |
    • one
        7 |
      • two
          8 |
        • three
        • 9 |
        • four
        • 10 |
        • five
        • 11 |
        12 |
      • 13 |
      14 |
    • 15 |
    16 |
    17 |
  2. 18 |
  3. foo:

    19 |
     line 1
    20 |  line 2
    21 |
  4. 22 |
  5. foo:

    23 |
      24 |
    1. foo bar bar:

      25 |
       some code here
      26 | 
      27 |
    2. 28 |
    3. foo bar bar:

      29 |
       foo
      30 |  ---
      31 |  bar
      32 |  ---
      33 |  foo
      34 |  bar
      35 |
    4. 36 |
    5. foo bar bar:

      37 |
       ---
      38 |  foo
      39 |  foo
      40 |  ---
      41 |  bar
      42 |
    6. 43 |
    7. foo bar bar:

      44 |
       foo
      45 |  ---
      46 |  bar
      47 |
    8. 48 |
    9. foo

      49 |
    10. 50 |
    51 |
  6. 52 |
53 | -------------------------------------------------------------------------------- /test/browser/index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | var test = require('../') 4 | , runTests = test.runTests 5 | , load = test.load; 6 | 7 | var express = require('express') 8 | , app = express(); 9 | 10 | app.use(function(req, res, next) { 11 | var setHeader = res.setHeader; 12 | res.setHeader = function(name) { 13 | switch (name) { 14 | case 'Cache-Control': 15 | case 'Last-Modified': 16 | case 'ETag': 17 | return; 18 | } 19 | return setHeader.apply(res, arguments); 20 | }; 21 | next(); 22 | }); 23 | 24 | var dir = __dirname + '/../tests' 25 | , files = {}; 26 | 27 | app.get('/test.js', function(req, res, next) { 28 | var test = fs.readFileSync(__dirname + '/test.js', 'utf8') 29 | , files = load(); 30 | 31 | test = test.replace('__TESTS__', JSON.stringify(files)); 32 | test = test.replace('__MAIN__', runTests + ''); 33 | 34 | res.contentType('.js'); 35 | res.send(test); 36 | }); 37 | 38 | app.use(express.static(__dirname + '/../../lib')); 39 | app.use(express.static(__dirname)); 40 | 41 | app.listen(8080); 42 | -------------------------------------------------------------------------------- /test/original/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/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/original/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /test/new/main.text: -------------------------------------------------------------------------------- 1 | [test]: http://google.com/ "Google" 2 | 3 | # A heading 4 | 5 | Just a note, I've found that I can't test my markdown parser vs others. 6 | For example, both markdown.js and showdown code blocks in lists wrong. They're 7 | also completely [inconsistent][test] with regards to paragraphs in list items. 8 | 9 | A link. Not anymore. 10 | 11 | 13 | 14 | * List Item 1 15 | 16 | * List Item 2 17 | * New List Item 1 18 | Hi, this is a list item. 19 | * New List Item 2 20 | Another item 21 | Code goes here. 22 | Lots of it... 23 | * New List Item 3 24 | The last item 25 | 26 | * List Item 3 27 | The final item. 28 | 29 | * List Item 4 30 | The real final item. 31 | 32 | Paragraph. 33 | 34 | > * bq Item 1 35 | > * bq Item 2 36 | > * New bq Item 1 37 | > * New bq Item 2 38 | > Text here 39 | 40 | * * * 41 | 42 | > Another blockquote! 43 | > I really need to get 44 | > more creative with 45 | > mockup text.. 46 | > markdown.js breaks here again 47 | 48 | Another Heading 49 | ------------- 50 | 51 | Hello *world*. Here is a [link](//hello). 52 | And an image ![alt](src). 53 | 54 | Code goes here. 55 | Lots of it... 56 | -------------------------------------------------------------------------------- /test/tests/main.text: -------------------------------------------------------------------------------- 1 | [test]: http://google.com/ "Google" 2 | 3 | # A heading 4 | 5 | Just a note, I've found that I can't test my markdown parser vs others. 6 | For example, both markdown.js and showdown code blocks in lists wrong. They're 7 | also completely [inconsistent][test] with regards to paragraphs in list items. 8 | 9 | A link. Not anymore. 10 | 11 | 13 | 14 | * List Item 1 15 | 16 | * List Item 2 17 | * New List Item 1 18 | Hi, this is a list item. 19 | * New List Item 2 20 | Another item 21 | Code goes here. 22 | Lots of it... 23 | * New List Item 3 24 | The last item 25 | 26 | * List Item 3 27 | The final item. 28 | 29 | * List Item 4 30 | The real final item. 31 | 32 | Paragraph. 33 | 34 | > * bq Item 1 35 | > * bq Item 2 36 | > * New bq Item 1 37 | > * New bq Item 2 38 | > Text here 39 | 40 | * * * 41 | 42 | > Another blockquote! 43 | > I really need to get 44 | > more creative with 45 | > mockup text.. 46 | > markdown.js breaks here again 47 | 48 | Another Heading 49 | ------------- 50 | 51 | Hello *world*. Here is a [link](//hello). 52 | And an image ![alt](src). 53 | 54 | Code goes here. 55 | Lots of it... 56 | -------------------------------------------------------------------------------- /test/new/main.html: -------------------------------------------------------------------------------- 1 |

A heading

Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.

A link. Not anymore.

  • List Item 1

  • List Item 2

    • New List Item 1 Hi, this is a list item.
    • New List Item 2 Another item
      Code goes here.
      3 | Lots of it...
    • New List Item 3 The last item
  • List Item 3 The final item.

  • List Item 4 The real final item.

Paragraph.

  • bq Item 1
  • bq Item 2
    • New bq Item 1
    • New bq Item 2 Text here

Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again

Another Heading

Hello world. Here is a link. And an image alt.

Code goes here.
4 | Lots of it...
5 | -------------------------------------------------------------------------------- /test/tests/main.html: -------------------------------------------------------------------------------- 1 |

A heading

Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.

A link. Not anymore.

  • List Item 1

  • List Item 2

    • New List Item 1 Hi, this is a list item.
    • New List Item 2 Another item
      Code goes here.
      3 | Lots of it...
    • New List Item 3 The last item
  • List Item 3 The final item.

  • List Item 4 The real final item.

Paragraph.

  • bq Item 1
  • bq Item 2
    • New bq Item 1
    • New bq Item 2 Text here

Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again

Another Heading

Hello world. Here is a link. And an image alt.

Code goes here.
4 | Lots of it...
5 | -------------------------------------------------------------------------------- /test/original/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/browser/test.js: -------------------------------------------------------------------------------- 1 | ;(function() { 2 | 3 | var console = {} 4 | , files = __TESTS__; 5 | 6 | console.log = function(text) { 7 | var args = Array.prototype.slice.call(arguments, 1) 8 | , i = 0; 9 | 10 | text = text.replace(/%\w/g, function() { 11 | return args[i++] || ''; 12 | }); 13 | 14 | if (window.console) window.console.log(text); 15 | document.body.innerHTML += '
' + escape(text) + '
'; 16 | }; 17 | 18 | if (!Object.keys) { 19 | Object.keys = function(obj) { 20 | var out = [] 21 | , key; 22 | 23 | for (key in obj) { 24 | if (Object.prototype.hasOwnProperty.call(obj, key)) { 25 | out.push(key); 26 | } 27 | } 28 | 29 | return out; 30 | }; 31 | } 32 | 33 | if (!Array.prototype.forEach) { 34 | Array.prototype.forEach = function(callback, context) { 35 | for (var i = 0; i < this.length; i++) { 36 | callback.call(context || null, this[i], i, obj); 37 | } 38 | }; 39 | } 40 | 41 | if (!String.prototype.trim) { 42 | String.prototype.trim = function() { 43 | return this.replace(/^\s+|\s+$/g, ''); 44 | }; 45 | } 46 | 47 | function load() { 48 | return files; 49 | } 50 | 51 | function escape(html, encode) { 52 | return html 53 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') 54 | .replace(//g, '>') 56 | .replace(/"/g, '"') 57 | .replace(/'/g, '''); 58 | } 59 | 60 | (__MAIN__)(); 61 | 62 | }).call(this); 63 | -------------------------------------------------------------------------------- /test/new/gfm_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Heading 1Heading 2
Cell 1Cell 2
Cell 3Cell 4
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
19 |
Test code
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Header 1Header 2
Cell 1Cell 2
Cell 3Cell 4
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
38 | -------------------------------------------------------------------------------- /test/tests/gfm_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Heading 1Heading 2
Cell 1Cell 2
Cell 3Cell 4
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
19 |
Test code
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Header 1Header 2
Cell 1Cell 2
Cell 3Cell 4
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
38 | -------------------------------------------------------------------------------- /test/original/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/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/original/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/original/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/original/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /doc/broken.md: -------------------------------------------------------------------------------- 1 | # Markdown is broken 2 | 3 | I have a lot of scraps of markdown engine oddities that I've collected over the 4 | years. What you see below is slightly messy, but it's what I've managed to 5 | cobble together to illustrate the differences between markdown engines, and 6 | why, if there ever is a markdown specification, it has to be absolutely 7 | thorough. There are a lot more of these little differences I have documented 8 | elsewhere. I know I will find them lingering on my disk one day, but until 9 | then, I'll continue to add whatever strange nonsensical things I find. 10 | 11 | Some of these examples may only mention a particular engine compared to marked. 12 | However, the examples with markdown.pl could easily be swapped out for 13 | discount, upskirt, or markdown.js, and you would very easily see even more 14 | inconsistencies. 15 | 16 | A lot of this was written when I was very unsatisfied with the inconsistencies 17 | between markdown engines. Please excuse the frustration noticeable in my 18 | writing. 19 | 20 | ## Examples of markdown's "stupid" list parsing 21 | 22 | ``` 23 | $ markdown.pl 24 | 25 | * item1 26 | 27 | * item2 28 | 29 | text 30 | ^D 31 |
    32 |
  • item1

    33 | 34 |
      35 |
    • item2
    • 36 |
    37 | 38 |

    text

  • 39 |

40 | ``` 41 | 42 | 43 | ``` 44 | $ marked 45 | * item1 46 | 47 | * item2 48 | 49 | text 50 | ^D 51 |
    52 |
  • item1

    53 |
      54 |
    • item2
    • 55 |
    56 |

    text

    57 |
  • 58 |
59 | ``` 60 | 61 | Which looks correct to you? 62 | 63 | - - - 64 | 65 | ``` 66 | $ markdown.pl 67 | * hello 68 | > world 69 | ^D 70 |

    71 |
  • hello

    72 | 73 |
    74 |

    world

  • 75 |

76 | 77 | ``` 78 | 79 | ``` 80 | $ marked 81 | * hello 82 | > world 83 | ^D 84 |
    85 |
  • hello
    86 |

    world

    87 |
    88 |
  • 89 |
90 | ``` 91 | 92 | Again, which looks correct to you? 93 | 94 | - - - 95 | 96 | EXAMPLE: 97 | 98 | ``` 99 | $ markdown.pl 100 | * hello 101 | * world 102 | * hi 103 | code 104 | ^D 105 |
    106 |
  • hello 107 |
      108 |
    • world
    • 109 |
    • hi 110 | code
    • 111 |
  • 112 |
113 | ``` 114 | 115 | The code isn't a code block even though it's after the bullet margin. I know, 116 | lets give it two more spaces, effectively making it 8 spaces past the bullet. 117 | 118 | ``` 119 | $ markdown.pl 120 | * hello 121 | * world 122 | * hi 123 | code 124 | ^D 125 |
    126 |
  • hello 127 |
      128 |
    • world
    • 129 |
    • hi 130 | code
    • 131 |
  • 132 |
133 | ``` 134 | 135 | And, it's still not a code block. Did you also notice that the 3rd item isn't 136 | even its own list? Markdown screws that up too because of its indentation 137 | unaware parsing. 138 | 139 | - - - 140 | 141 | Let's look at some more examples of markdown's list parsing: 142 | 143 | ``` 144 | $ markdown.pl 145 | 146 | * item1 147 | 148 | * item2 149 | 150 | text 151 | ^D 152 |
    153 |
  • item1

    154 | 155 |
      156 |
    • item2
    • 157 |
    158 | 159 |

    text

  • 160 |

161 | ``` 162 | 163 | Misnested tags. 164 | 165 | 166 | ``` 167 | $ marked 168 | * item1 169 | 170 | * item2 171 | 172 | text 173 | ^D 174 |
    175 |
  • item1

    176 |
      177 |
    • item2
    • 178 |
    179 |

    text

    180 |
  • 181 |
182 | ``` 183 | 184 | Which looks correct to you? 185 | 186 | - - - 187 | 188 | ``` 189 | $ markdown.pl 190 | * hello 191 | > world 192 | ^D 193 |

    194 |
  • hello

    195 | 196 |
    197 |

    world

  • 198 |

199 | 200 | ``` 201 | 202 | More misnested tags. 203 | 204 | 205 | ``` 206 | $ marked 207 | * hello 208 | > world 209 | ^D 210 |
    211 |
  • hello
    212 |

    world

    213 |
    214 |
  • 215 |
216 | ``` 217 | 218 | Again, which looks correct to you? 219 | 220 | - - - 221 | 222 | # Why quality matters - Part 2 223 | 224 | ``` bash 225 | $ markdown.pl 226 | * hello 227 | > world 228 | ^D 229 |

    230 |
  • hello

    231 | 232 |
    233 |

    world

  • 234 |

235 | 236 | ``` 237 | 238 | ``` bash 239 | $ sundown # upskirt 240 | * hello 241 | > world 242 | ^D 243 |
    244 |
  • hello 245 | > world
  • 246 |
247 | ``` 248 | 249 | ``` bash 250 | $ marked 251 | * hello 252 | > world 253 | ^D 254 |
  • hello

    world

255 | ``` 256 | 257 | Which looks correct to you? 258 | 259 | - - - 260 | 261 | See: https://github.com/evilstreak/markdown-js/issues/23 262 | 263 | ``` bash 264 | $ markdown.pl # upskirt/markdown.js/discount 265 | * hello 266 | var a = 1; 267 | * world 268 | ^D 269 |
    270 |
  • hello 271 | var a = 1;
  • 272 |
  • world
  • 273 |
274 | ``` 275 | 276 | ``` bash 277 | $ marked 278 | * hello 279 | var a = 1; 280 | * world 281 | ^D 282 |
  • hello 283 |
    code>var a = 1;
  • 284 |
  • world
285 | ``` 286 | 287 | Which looks more reasonable? Why shouldn't code blocks be able to appear in 288 | list items in a sane way? 289 | 290 | - - - 291 | 292 | ``` bash 293 | $ markdown.js 294 |
hello
295 | 296 | hello 297 | ^D 298 |

<div>hello</div>

299 | 300 |

<span>hello</span>

301 | ``` 302 | 303 | ``` bash 304 | $ marked 305 |
hello
306 | 307 | hello 308 | ^D 309 |
hello
310 | 311 | 312 |

hello 313 |

314 | ``` 315 | 316 | - - - 317 | 318 | See: https://github.com/evilstreak/markdown-js/issues/27 319 | 320 | ``` bash 321 | $ markdown.js 322 | [![an image](/image)](/link) 323 | ^D 324 |

![an image

325 | ``` 326 | 327 | ``` bash 328 | $ marked 329 | [![an image](/image)](/link) 330 | ^D 331 |

an image 332 |

333 | ``` 334 | 335 | - - - 336 | 337 | See: https://github.com/evilstreak/markdown-js/issues/24 338 | 339 | ``` bash 340 | $ markdown.js 341 | > a 342 | 343 | > b 344 | 345 | > c 346 | ^D 347 |

a

bundefined> c

348 | ``` 349 | 350 | ``` bash 351 | $ marked 352 | > a 353 | 354 | > b 355 | 356 | > c 357 | ^D 358 |

a 359 | 360 |

361 |

b 362 | 363 |

364 |

c 365 |

366 | ``` 367 | 368 | - - - 369 | 370 | ``` bash 371 | $ markdown.pl 372 | * hello 373 | * world 374 | how 375 | 376 | are 377 | you 378 | 379 | * today 380 | * hi 381 | ^D 382 |
    383 |
  • hello

    384 | 385 |
      386 |
    • world 387 | how
    • 388 |
    389 | 390 |

    are 391 | you

    392 | 393 |
      394 |
    • today
    • 395 |
  • 396 |
  • hi
  • 397 |
398 | ``` 399 | 400 | ``` bash 401 | $ marked 402 | * hello 403 | * world 404 | how 405 | 406 | are 407 | you 408 | 409 | * today 410 | * hi 411 | ^D 412 |
    413 |
  • hello

    414 |
      415 |
    • world 416 | how

      417 |

      are 418 | you

      419 |
    • 420 |
    • today

      421 |
    • 422 |
    423 |
  • 424 |
  • hi
  • 425 |
426 | ``` 427 | -------------------------------------------------------------------------------- /test/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/original/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/original/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/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 | 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.md: -------------------------------------------------------------------------------- 1 | # marked 2 | 3 | > A full-featured markdown parser and compiler, written in JavaScript. Built 4 | > for speed. 5 | 6 | [![NPM version](https://badge.fury.io/js/marked.png)][badge] 7 | 8 | ## Install 9 | 10 | ``` bash 11 | npm install marked --save 12 | ``` 13 | 14 | ## Usage 15 | 16 | Minimal usage: 17 | 18 | ```js 19 | var marked = require('marked'); 20 | console.log(marked('I am using __markdown__.')); 21 | // Outputs:

I am using markdown.

22 | ``` 23 | 24 | Example setting options with default values: 25 | 26 | ```js 27 | var marked = require('marked'); 28 | marked.setOptions({ 29 | renderer: new marked.Renderer(), 30 | gfm: true, 31 | tables: true, 32 | breaks: false, 33 | pedantic: false, 34 | sanitize: true, 35 | smartLists: true, 36 | smartypants: false 37 | }); 38 | 39 | console.log(marked('I am using __markdown__.')); 40 | ``` 41 | 42 | ### Browser 43 | 44 | ```html 45 | 46 | 47 | 48 | 49 | Marked in the browser 50 | 51 | 52 | 53 |
54 | 58 | 59 | 60 | ``` 61 | 62 | ## marked(markdownString [,options] [,callback]) 63 | 64 | ### markdownString 65 | 66 | Type: `string` 67 | 68 | String of markdown source to be compiled. 69 | 70 | ### options 71 | 72 | Type: `object` 73 | 74 | Hash of options. Can also be set using the `marked.setOptions` method as seen 75 | above. 76 | 77 | ### callback 78 | 79 | Type: `function` 80 | 81 | Function called when the `markdownString` has been fully parsed when using 82 | async highlighting. If the `options` argument is omitted, this can be used as 83 | the second argument. 84 | 85 | ## Options 86 | 87 | ### highlight 88 | 89 | Type: `function` 90 | 91 | A function to highlight code blocks. The first example below uses async highlighting with 92 | [node-pygmentize-bundled][pygmentize], and the second is a synchronous example using 93 | [highlight.js][highlight]: 94 | 95 | ```js 96 | var marked = require('marked'); 97 | 98 | var markdownString = '```js\n console.log("hello"); \n```'; 99 | 100 | // Async highlighting with pygmentize-bundled 101 | marked.setOptions({ 102 | highlight: function (code, lang, callback) { 103 | require('pygmentize-bundled')({ lang: lang, format: 'html' }, code, function (err, result) { 104 | callback(err, result.toString()); 105 | }); 106 | } 107 | }); 108 | 109 | // Using async version of marked 110 | marked(markdownString, function (err, content) { 111 | if (err) throw err; 112 | console.log(content); 113 | }); 114 | 115 | // Synchronous highlighting with highlight.js 116 | marked.setOptions({ 117 | highlight: function (code) { 118 | return require('highlight.js').highlightAuto(code).value; 119 | } 120 | }); 121 | 122 | console.log(marked(markdownString)); 123 | ``` 124 | 125 | #### highlight arguments 126 | 127 | `code` 128 | 129 | Type: `string` 130 | 131 | The section of code to pass to the highlighter. 132 | 133 | `lang` 134 | 135 | Type: `string` 136 | 137 | The programming language specified in the code block. 138 | 139 | `callback` 140 | 141 | Type: `function` 142 | 143 | The callback function to call when using an async highlighter. 144 | 145 | ### renderer 146 | 147 | Type: `object` 148 | Default: `new Renderer()` 149 | 150 | An object containing functions to render tokens to HTML. 151 | 152 | #### Overriding renderer methods 153 | 154 | The renderer option allows you to render tokens in a custom manor. Here is an 155 | example of overriding the default heading token rendering by adding an embedded anchor tag like on GitHub: 156 | 157 | ```javascript 158 | var marked = require('marked'); 159 | var renderer = new marked.Renderer(); 160 | 161 | renderer.heading = function (text, level) { 162 | var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-'); 163 | 164 | return '' + 169 | text + ''; 170 | }, 171 | 172 | console.log(marked('# heading+', { renderer: renderer })); 173 | ``` 174 | This code will output the following HTML: 175 | ```html 176 |

177 | 178 | 179 | 180 | heading+ 181 |

182 | ``` 183 | 184 | #### Block level renderer methods 185 | 186 | - code(*string* code, *string* language) 187 | - blockquote(*string* quote) 188 | - html(*string* html) 189 | - heading(*string* text, *number* level) 190 | - hr() 191 | - list(*string* body, *boolean* ordered) 192 | - listitem(*string* text) 193 | - paragraph(*string* text) 194 | - table(*string* header, *string* body) 195 | - tablerow(*string* content) 196 | - tablecell(*string* content, *object* flags) 197 | 198 | `flags` has the following properties: 199 | 200 | ```js 201 | { 202 | header: true || false, 203 | align: 'center' || 'left' || 'right' 204 | } 205 | ``` 206 | 207 | #### Inline level renderer methods 208 | 209 | - strong(*string* text) 210 | - em(*string* text) 211 | - codespan(*string* code) 212 | - br() 213 | - del(*string* text) 214 | - link(*string* href, *string* title, *string* text) 215 | - image(*string* href, *string* title, *string* text) 216 | 217 | ### gfm 218 | 219 | Type: `boolean` 220 | Default: `true` 221 | 222 | Enable [GitHub flavored markdown][gfm]. 223 | 224 | ### tables 225 | 226 | Type: `boolean` 227 | Default: `true` 228 | 229 | Enable GFM [tables][tables]. 230 | This option requires the `gfm` option to be true. 231 | 232 | ### breaks 233 | 234 | Type: `boolean` 235 | Default: `false` 236 | 237 | Enable GFM [line breaks][breaks]. 238 | This option requires the `gfm` option to be true. 239 | 240 | ### pedantic 241 | 242 | Type: `boolean` 243 | Default: `false` 244 | 245 | Conform to obscure parts of `markdown.pl` as much as possible. Don't fix any of 246 | the original markdown bugs or poor behavior. 247 | 248 | ### sanitize 249 | 250 | Type: `boolean` 251 | Default: `false` 252 | 253 | Sanitize the output. Ignore any HTML that has been input. 254 | 255 | ### smartLists 256 | 257 | Type: `boolean` 258 | Default: `true` 259 | 260 | Use smarter list behavior than the original markdown. May eventually be 261 | default with the old behavior moved into `pedantic`. 262 | 263 | ### smartypants 264 | 265 | Type: `boolean` 266 | Default: `false` 267 | 268 | Use "smart" typograhic punctuation for things like quotes and dashes. 269 | 270 | ## Access to lexer and parser 271 | 272 | You also have direct access to the lexer and parser if you so desire. 273 | 274 | ``` js 275 | var tokens = marked.lexer(text, options); 276 | console.log(marked.parser(tokens)); 277 | ``` 278 | 279 | ``` js 280 | var lexer = new marked.Lexer(options); 281 | var tokens = lexer.lex(text); 282 | console.log(tokens); 283 | console.log(lexer.rules); 284 | ``` 285 | 286 | ## CLI 287 | 288 | ``` bash 289 | $ marked -o hello.html 290 | hello world 291 | ^D 292 | $ cat hello.html 293 |

hello world

294 | ``` 295 | 296 | ## Philosophy behind marked 297 | 298 | The point of marked was to create a markdown compiler where it was possible to 299 | frequently parse huge chunks of markdown without having to worry about 300 | caching the compiled output somehow...or blocking for an unnecesarily long time. 301 | 302 | marked is very concise and still implements all markdown features. It is also 303 | now fully compatible with the client-side. 304 | 305 | marked more or less passes the official markdown test suite in its 306 | entirety. This is important because a surprising number of markdown compilers 307 | cannot pass more than a few tests. It was very difficult to get marked as 308 | compliant as it is. It could have cut corners in several areas for the sake 309 | of performance, but did not in order to be exactly what you expect in terms 310 | of a markdown rendering. In fact, this is why marked could be considered at a 311 | disadvantage in the benchmarks above. 312 | 313 | Along with implementing every markdown feature, marked also implements [GFM 314 | features][gfmf]. 315 | 316 | ## Benchmarks 317 | 318 | node v0.8.x 319 | 320 | ``` bash 321 | $ node test --bench 322 | marked completed in 3411ms. 323 | marked (gfm) completed in 3727ms. 324 | marked (pedantic) completed in 3201ms. 325 | robotskirt completed in 808ms. 326 | showdown (reuse converter) completed in 11954ms. 327 | showdown (new converter) completed in 17774ms. 328 | markdown-js completed in 17191ms. 329 | ``` 330 | 331 | __Marked is now faster than Discount, which is written in C.__ 332 | 333 | For those feeling skeptical: These benchmarks run the entire markdown test suite 1000 times. The test suite tests every feature. It doesn't cater to specific aspects. 334 | 335 | ### Pro level 336 | 337 | You also have direct access to the lexer and parser if you so desire. 338 | 339 | ``` js 340 | var tokens = marked.lexer(text, options); 341 | console.log(marked.parser(tokens)); 342 | ``` 343 | 344 | ``` js 345 | var lexer = new marked.Lexer(options); 346 | var tokens = lexer.lex(text); 347 | console.log(tokens); 348 | console.log(lexer.rules); 349 | ``` 350 | 351 | ``` bash 352 | $ node 353 | > require('marked').lexer('> i am using marked.') 354 | [ { type: 'blockquote_start' }, 355 | { type: 'paragraph', 356 | text: 'i am using marked.' }, 357 | { type: 'blockquote_end' }, 358 | links: {} ] 359 | ``` 360 | 361 | ## Running Tests & Contributing 362 | 363 | If you want to submit a pull request, make sure your changes pass the test 364 | suite. If you're adding a new feature, be sure to add your own test. 365 | 366 | The marked test suite is set up slightly strangely: `test/new` is for all tests 367 | that are not part of the original markdown.pl test suite (this is where your 368 | test should go if you make one). `test/original` is only for the original 369 | markdown.pl tests. `test/tests` houses both types of tests after they have been 370 | combined and moved/generated by running `node test --fix` or `marked --test 371 | --fix`. 372 | 373 | In other words, if you have a test to add, add it to `test/new/` and then 374 | regenerate the tests with `node test --fix`. Commit the result. If your test 375 | uses a certain feature, for example, maybe it assumes GFM is *not* enabled, you 376 | can add `.nogfm` to the filename. So, `my-test.text` becomes 377 | `my-test.nogfm.text`. You can do this with any marked option. Say you want 378 | line breaks and smartypants enabled, your filename should be: 379 | `my-test.breaks.smartypants.text`. 380 | 381 | To run the tests: 382 | 383 | ``` bash 384 | cd marked/ 385 | node test 386 | ``` 387 | 388 | ### Contribution and License Agreement 389 | 390 | If you contribute code to this project, you are implicitly allowing your code 391 | to be distributed under the MIT license. You are also implicitly verifying that 392 | all code is your original work. `` 393 | 394 | ## License 395 | 396 | Copyright (c) 2011-2014, Christopher Jeffrey. (MIT License) 397 | 398 | See LICENSE for more info. 399 | 400 | [gfm]: https://help.github.com/articles/github-flavored-markdown 401 | [gfmf]: http://github.github.com/github-flavored-markdown/ 402 | [pygmentize]: https://github.com/rvagg/node-pygmentize-bundled 403 | [highlight]: https://github.com/isagalaev/highlight.js 404 | [badge]: http://badge.fury.io/js/marked 405 | [tables]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#wiki-tables 406 | [breaks]: https://help.github.com/articles/github-flavored-markdown#newlines 407 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * marked tests 5 | * Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed) 6 | * https://github.com/chjj/marked 7 | */ 8 | 9 | /** 10 | * Modules 11 | */ 12 | 13 | var fs = require('fs') 14 | , path = require('path') 15 | , marked = require('../'); 16 | 17 | /** 18 | * Load Tests 19 | */ 20 | 21 | function load() { 22 | var dir = __dirname + '/tests' 23 | , files = {} 24 | , list 25 | , file 26 | , i 27 | , l; 28 | 29 | list = fs 30 | .readdirSync(dir) 31 | .filter(function(file) { 32 | return path.extname(file) !== '.html'; 33 | }) 34 | .sort(function(a, b) { 35 | a = path.basename(a).toLowerCase().charCodeAt(0); 36 | b = path.basename(b).toLowerCase().charCodeAt(0); 37 | return a > b ? 1 : (a < b ? -1 : 0); 38 | }); 39 | 40 | i = 0; 41 | l = list.length; 42 | 43 | for (; i < l; i++) { 44 | file = path.join(dir, list[i]); 45 | files[path.basename(file)] = { 46 | text: fs.readFileSync(file, 'utf8'), 47 | html: fs.readFileSync(file.replace(/[^.]+$/, 'html'), 'utf8') 48 | }; 49 | } 50 | 51 | return files; 52 | } 53 | 54 | /** 55 | * Test Runner 56 | */ 57 | 58 | function runTests(engine, options) { 59 | if (typeof engine !== 'function') { 60 | options = engine; 61 | engine = null; 62 | } 63 | 64 | var engine = engine || marked 65 | , options = options || {} 66 | , files = options.files || load() 67 | , complete = 0 68 | , failed = 0 69 | , failures = [] 70 | , keys = Object.keys(files) 71 | , i = 0 72 | , len = keys.length 73 | , filename 74 | , file 75 | , flags 76 | , text 77 | , html 78 | , j 79 | , l; 80 | 81 | if (options.marked) { 82 | marked.setOptions(options.marked); 83 | } 84 | 85 | main: 86 | for (; i < len; i++) { 87 | filename = keys[i]; 88 | file = files[filename]; 89 | 90 | if (marked._original) { 91 | marked.defaults = marked._original; 92 | delete marked._original; 93 | } 94 | 95 | flags = filename.split('.').slice(1, -1); 96 | if (flags.length) { 97 | marked._original = marked.defaults; 98 | marked.defaults = {}; 99 | Object.keys(marked._original).forEach(function(key) { 100 | marked.defaults[key] = marked._original[key]; 101 | }); 102 | flags.forEach(function(key) { 103 | var val = true; 104 | if (key.indexOf('no') === 0) { 105 | key = key.substring(2); 106 | val = false; 107 | } 108 | if (marked.defaults.hasOwnProperty(key)) { 109 | marked.defaults[key] = val; 110 | } 111 | }); 112 | } 113 | 114 | try { 115 | text = engine(file.text).replace(/\s/g, ''); 116 | html = file.html.replace(/\s/g, ''); 117 | } catch(e) { 118 | console.log('%s failed.', filename); 119 | throw e; 120 | } 121 | 122 | j = 0; 123 | l = html.length; 124 | 125 | for (; j < l; j++) { 126 | if (text[j] !== html[j]) { 127 | failed++; 128 | failures.push(filename); 129 | 130 | text = text.substring( 131 | Math.max(j - 30, 0), 132 | Math.min(j + 30, text.length)); 133 | 134 | html = html.substring( 135 | Math.max(j - 30, 0), 136 | Math.min(j + 30, html.length)); 137 | 138 | console.log( 139 | '\n#%d. %s failed at offset %d. Near: "%s".\n', 140 | i + 1, filename, j, text); 141 | 142 | console.log('\nGot:\n%s\n', text.trim() || text); 143 | console.log('\nExpected:\n%s\n', html.trim() || html); 144 | 145 | if (options.stop) { 146 | break main; 147 | } 148 | 149 | continue main; 150 | } 151 | } 152 | 153 | complete++; 154 | console.log('#%d. %s completed.', i + 1, filename); 155 | } 156 | 157 | console.log('%d/%d tests completed successfully.', complete, len); 158 | if (failed) console.log('%d/%d tests failed.', failed, len); 159 | 160 | // Tests currently failing. 161 | if (~failures.indexOf('def_blocks.text')) { 162 | failed -= 1; 163 | } 164 | 165 | return !failed; 166 | } 167 | 168 | /** 169 | * Benchmark a function 170 | */ 171 | 172 | function bench(name, func) { 173 | var files = bench.files || load(); 174 | 175 | if (!bench.files) { 176 | bench.files = files; 177 | 178 | // Change certain tests to allow 179 | // comparison to older benchmark times. 180 | fs.readdirSync(__dirname + '/new').forEach(function(name) { 181 | if (path.extname(name) === '.html') return; 182 | if (name === 'main.text') return; 183 | delete files[name]; 184 | }); 185 | 186 | files['backslash_escapes.text'] = { 187 | text: 'hello world \\[how](are you) today' 188 | }; 189 | 190 | files['main.text'].text = files['main.text'].text.replace('* * *\n\n', ''); 191 | } 192 | 193 | var start = Date.now() 194 | , times = 1000 195 | , keys = Object.keys(files) 196 | , i 197 | , l = keys.length 198 | , filename 199 | , file; 200 | 201 | while (times--) { 202 | for (i = 0; i < l; i++) { 203 | filename = keys[i]; 204 | file = files[filename]; 205 | func(file.text); 206 | } 207 | } 208 | 209 | console.log('%s completed in %dms.', name, Date.now() - start); 210 | } 211 | 212 | /** 213 | * Benchmark all engines 214 | */ 215 | 216 | function runBench(options) { 217 | var options = options || {}; 218 | 219 | // Non-GFM, Non-pedantic 220 | marked.setOptions({ 221 | gfm: false, 222 | tables: false, 223 | breaks: false, 224 | pedantic: false, 225 | sanitize: false, 226 | smartLists: false 227 | }); 228 | if (options.marked) { 229 | marked.setOptions(options.marked); 230 | } 231 | bench('marked', marked); 232 | 233 | // GFM 234 | marked.setOptions({ 235 | gfm: true, 236 | tables: false, 237 | breaks: false, 238 | pedantic: false, 239 | sanitize: false, 240 | smartLists: false 241 | }); 242 | if (options.marked) { 243 | marked.setOptions(options.marked); 244 | } 245 | bench('marked (gfm)', marked); 246 | 247 | // Pedantic 248 | marked.setOptions({ 249 | gfm: false, 250 | tables: false, 251 | breaks: false, 252 | pedantic: true, 253 | sanitize: false, 254 | smartLists: false 255 | }); 256 | if (options.marked) { 257 | marked.setOptions(options.marked); 258 | } 259 | bench('marked (pedantic)', marked); 260 | 261 | // robotskirt 262 | try { 263 | bench('robotskirt', (function() { 264 | var rs = require('robotskirt'); 265 | return function(text) { 266 | var parser = rs.Markdown.std(); 267 | return parser.render(text); 268 | }; 269 | })()); 270 | } catch (e) { 271 | console.log('Could not bench robotskirt.'); 272 | } 273 | 274 | // showdown 275 | try { 276 | bench('showdown (reuse converter)', (function() { 277 | var Showdown = require('showdown'); 278 | var convert = new Showdown.converter(); 279 | return function(text) { 280 | return convert.makeHtml(text); 281 | }; 282 | })()); 283 | bench('showdown (new converter)', (function() { 284 | var Showdown = require('showdown'); 285 | return function(text) { 286 | var convert = new Showdown.converter(); 287 | return convert.makeHtml(text); 288 | }; 289 | })()); 290 | } catch (e) { 291 | console.log('Could not bench showdown.'); 292 | } 293 | 294 | // markdown.js 295 | try { 296 | bench('markdown.js', require('markdown').parse); 297 | } catch (e) { 298 | console.log('Could not bench markdown.js.'); 299 | } 300 | } 301 | 302 | /** 303 | * A simple one-time benchmark 304 | */ 305 | 306 | function time(options) { 307 | var options = options || {}; 308 | if (options.marked) { 309 | marked.setOptions(options.marked); 310 | } 311 | bench('marked', marked); 312 | } 313 | 314 | /** 315 | * Markdown Test Suite Fixer 316 | * This function is responsible for "fixing" 317 | * the markdown test suite. There are 318 | * certain aspects of the suite that 319 | * are strange or might make tests 320 | * fail for reasons unrelated to 321 | * conformance. 322 | */ 323 | 324 | function fix(options) { 325 | ['tests', 'original', 'new'].forEach(function(dir) { 326 | try { 327 | fs.mkdirSync(path.resolve(__dirname, dir), 0755); 328 | } catch (e) { 329 | ; 330 | } 331 | }); 332 | 333 | // rm -rf tests 334 | fs.readdirSync(path.resolve(__dirname, 'tests')).forEach(function(file) { 335 | fs.unlinkSync(path.resolve(__dirname, 'tests', file)); 336 | }); 337 | 338 | // cp -r original tests 339 | fs.readdirSync(path.resolve(__dirname, 'original')).forEach(function(file) { 340 | var nfile = file; 341 | if (file.indexOf('hard_wrapped_paragraphs_with_list_like_lines.') === 0) { 342 | nfile = file.replace(/\.(text|html)$/, '.nogfm.$1'); 343 | } 344 | fs.writeFileSync(path.resolve(__dirname, 'tests', nfile), 345 | fs.readFileSync(path.resolve(__dirname, 'original', file))); 346 | }); 347 | 348 | // node fix.js 349 | var dir = __dirname + '/tests'; 350 | 351 | fs.readdirSync(dir).filter(function(file) { 352 | return path.extname(file) === '.html'; 353 | }).forEach(function(file) { 354 | var file = path.join(dir, file) 355 | , html = fs.readFileSync(file, 'utf8'); 356 | 357 | // fix unencoded quotes 358 | html = html 359 | .replace(/='([^\n']*)'(?=[^<>\n]*>)/g, '=&__APOS__;$1&__APOS__;') 360 | .replace(/="([^\n"]*)"(?=[^<>\n]*>)/g, '=&__QUOT__;$1&__QUOT__;') 361 | .replace(/"/g, '"') 362 | .replace(/'/g, ''') 363 | .replace(/&__QUOT__;/g, '"') 364 | .replace(/&__APOS__;/g, '\''); 365 | 366 | // add heading id's 367 | html = html.replace(/<(h[1-6])>([^<]+)<\/\1>/g, function(s, h, text) { 368 | var id = text 369 | .replace(/'/g, '\'') 370 | .replace(/"/g, '"') 371 | .replace(/>/g, '>') 372 | .replace(/</g, '<') 373 | .replace(/&/g, '&'); 374 | 375 | id = id.toLowerCase().replace(/[^\w]+/g, '-'); 376 | 377 | return '<' + h + ' id="' + id + '">' + text + ''; 378 | }); 379 | 380 | fs.writeFileSync(file, html); 381 | }); 382 | 383 | // turn
into
384 | fs.readdirSync(dir).forEach(function(file) { 385 | var file = path.join(dir, file) 386 | , text = fs.readFileSync(file, 'utf8'); 387 | 388 | text = text.replace(/(<|<)hr\s*\/(>|>)/g, '$1hr$2'); 389 | 390 | fs.writeFileSync(file, text); 391 | }); 392 | 393 | // markdown does some strange things. 394 | // it does not encode naked `>`, marked does. 395 | (function() { 396 | var file = dir + '/amps_and_angles_encoding.html'; 397 | var html = fs.readFileSync(file, 'utf8') 398 | .replace('6 > 5.', '6 > 5.'); 399 | 400 | fs.writeFileSync(file, html); 401 | })(); 402 | 403 | // cp new/* tests/ 404 | fs.readdirSync(path.resolve(__dirname, 'new')).forEach(function(file) { 405 | fs.writeFileSync(path.resolve(__dirname, 'tests', file), 406 | fs.readFileSync(path.resolve(__dirname, 'new', file))); 407 | }); 408 | } 409 | 410 | /** 411 | * Argument Parsing 412 | */ 413 | 414 | function parseArg(argv) { 415 | var argv = process.argv.slice(2) 416 | , options = {} 417 | , orphans = [] 418 | , arg; 419 | 420 | function getarg() { 421 | var arg = argv.shift(); 422 | 423 | if (arg.indexOf('--') === 0) { 424 | // e.g. --opt 425 | arg = arg.split('='); 426 | if (arg.length > 1) { 427 | // e.g. --opt=val 428 | argv.unshift(arg.slice(1).join('=')); 429 | } 430 | arg = arg[0]; 431 | } else if (arg[0] === '-') { 432 | if (arg.length > 2) { 433 | // e.g. -abc 434 | argv = arg.substring(1).split('').map(function(ch) { 435 | return '-' + ch; 436 | }).concat(argv); 437 | arg = argv.shift(); 438 | } else { 439 | // e.g. -a 440 | } 441 | } else { 442 | // e.g. foo 443 | } 444 | 445 | return arg; 446 | } 447 | 448 | while (argv.length) { 449 | arg = getarg(); 450 | switch (arg) { 451 | case '-f': 452 | case '--fix': 453 | case 'fix': 454 | options.fix = true; 455 | break; 456 | case '-b': 457 | case '--bench': 458 | options.bench = true; 459 | break; 460 | case '-s': 461 | case '--stop': 462 | options.stop = true; 463 | break; 464 | case '-t': 465 | case '--time': 466 | options.time = true; 467 | break; 468 | default: 469 | if (arg.indexOf('--') === 0) { 470 | opt = camelize(arg.replace(/^--(no-)?/, '')); 471 | if (!marked.defaults.hasOwnProperty(opt)) { 472 | continue; 473 | } 474 | options.marked = options.marked || {}; 475 | if (arg.indexOf('--no-') === 0) { 476 | options.marked[opt] = typeof marked.defaults[opt] !== 'boolean' 477 | ? null 478 | : false; 479 | } else { 480 | options.marked[opt] = typeof marked.defaults[opt] !== 'boolean' 481 | ? argv.shift() 482 | : true; 483 | } 484 | } else { 485 | orphans.push(arg); 486 | } 487 | break; 488 | } 489 | } 490 | 491 | return options; 492 | } 493 | 494 | /** 495 | * Helpers 496 | */ 497 | 498 | function camelize(text) { 499 | return text.replace(/(\w)-(\w)/g, function(_, a, b) { 500 | return a + b.toUpperCase(); 501 | }); 502 | } 503 | 504 | /** 505 | * Main 506 | */ 507 | 508 | function main(argv) { 509 | var opt = parseArg(); 510 | 511 | if (opt.fix) { 512 | return fix(opt); 513 | } 514 | 515 | if (opt.bench) { 516 | return runBench(opt); 517 | } 518 | 519 | if (opt.time) { 520 | return time(opt); 521 | } 522 | 523 | return runTests(opt); 524 | } 525 | 526 | /** 527 | * Execute 528 | */ 529 | 530 | if (!module.parent) { 531 | process.title = 'marked'; 532 | process.exit(main(process.argv.slice()) ? 0 : 1); 533 | } else { 534 | exports = main; 535 | exports.main = main; 536 | exports.runTests = runTests; 537 | exports.runBench = runBench; 538 | exports.load = load; 539 | exports.bench = bench; 540 | module.exports = exports; 541 | } 542 | -------------------------------------------------------------------------------- /marked.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * marked - a markdown parser 3 | * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) 4 | * https://github.com/chjj/marked 5 | */ 6 | (function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script"||cap[1]==="style",text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(this.smartypants(cap[0]));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"
"+(escaped?code:escape(code,true))+"\n
"}return'
'+(escaped?code:escape(code,true))+"\n
\n"};Renderer.prototype.blockquote=function(quote){return"
\n"+quote+"
\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"'+text+"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"\n"};Renderer.prototype.listitem=function(text){return"
  • "+text+"
  • \n"};Renderer.prototype.paragraph=function(text){return"

    "+text+"

    \n"};Renderer.prototype.table=function(header,body){return"\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
    \n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+""};Renderer.prototype.br=function(){return this.options.xhtml?"
    ":"
    "};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0){return""}}var out='
    ";return out};Renderer.prototype.image=function(href,title,text){var out=''+text+'":">";return out};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occured:

    "+escape(e.message+"",true)+"
    "}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); -------------------------------------------------------------------------------- /lib/marked.js: -------------------------------------------------------------------------------- 1 | /** 2 | * marked - a markdown parser 3 | * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) 4 | * https://github.com/chjj/marked 5 | */ 6 | 7 | ;(function() { 8 | 9 | /** 10 | * Block-Level Grammar 11 | */ 12 | 13 | var block = { 14 | newline: /^\n+/, 15 | paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, 16 | text: /^[^\n]+/ 17 | }; 18 | 19 | block.bullet = /(?:[*+-]|\d+\.)/; 20 | block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; 21 | block.item = replace(block.item, 'gm') 22 | (/bull/g, block.bullet) 23 | (); 24 | 25 | block._tag = '(?!(?:' 26 | + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' 27 | + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' 28 | + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b'; 29 | 30 | block.paragraph = replace(block.paragraph) 31 | ('tag', '<' + block._tag) 32 | (); 33 | 34 | /** 35 | * Normal Block Grammar 36 | */ 37 | 38 | block.normal = merge({}, block); 39 | 40 | /** 41 | * GFM Block Grammar 42 | */ 43 | 44 | block.gfm = merge({}, block.normal, { 45 | fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/, 46 | paragraph: /^/ 47 | }); 48 | 49 | block.gfm.paragraph = replace(block.paragraph) 50 | ('(?!', '(?!')(); 51 | 52 | /** 53 | * GFM + Tables Block Grammar 54 | */ 55 | 56 | block.tables = merge({}, block.gfm, { 57 | nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/, 58 | table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/ 59 | }); 60 | 61 | /** 62 | * Block Lexer 63 | */ 64 | 65 | function Lexer(options) { 66 | this.tokens = []; 67 | this.tokens.links = {}; 68 | this.options = options || marked.defaults; 69 | this.rules = block.normal; 70 | 71 | if (this.options.gfm) { 72 | if (this.options.tables) { 73 | this.rules = block.tables; 74 | } else { 75 | this.rules = block.gfm; 76 | } 77 | } 78 | } 79 | 80 | /** 81 | * Expose Block Rules 82 | */ 83 | 84 | Lexer.rules = block; 85 | 86 | /** 87 | * Static Lex Method 88 | */ 89 | 90 | Lexer.lex = function(src, options) { 91 | var lexer = new Lexer(options); 92 | return lexer.lex(src); 93 | }; 94 | 95 | /** 96 | * Preprocessing 97 | */ 98 | 99 | Lexer.prototype.lex = function(src) { 100 | src = src 101 | .replace(/\r\n|\r/g, '\n') 102 | .replace(/\t/g, ' ') 103 | .replace(/\u00a0/g, ' ') 104 | .replace(/\u2424/g, '\n'); 105 | 106 | return this.token(src, true); 107 | }; 108 | 109 | /** 110 | * Lexing 111 | */ 112 | 113 | Lexer.prototype.token = function(src, top, bq) { 114 | var src = src.replace(/^ +$/gm, '') 115 | , next 116 | , loose 117 | , cap 118 | , bull 119 | , b 120 | , item 121 | , space 122 | , i 123 | , l; 124 | 125 | while (src) { 126 | // newline 127 | if (cap = this.rules.newline.exec(src)) { 128 | src = src.substring(cap[0].length); 129 | if (cap[0].length > 1) { 130 | this.tokens.push({ 131 | type: 'space' 132 | }); 133 | } 134 | } 135 | 136 | // top-level paragraph 137 | if (top && (cap = this.rules.paragraph.exec(src))) { 138 | src = src.substring(cap[0].length); 139 | this.tokens.push({ 140 | type: 'paragraph', 141 | text: cap[1].charAt(cap[1].length - 1) === '\n' 142 | ? cap[1].slice(0, -1) 143 | : cap[1] 144 | }); 145 | continue; 146 | } 147 | 148 | // text 149 | if (cap = this.rules.text.exec(src)) { 150 | // Top-level should never reach here. 151 | src = src.substring(cap[0].length); 152 | this.tokens.push({ 153 | type: 'text', 154 | text: cap[0] 155 | }); 156 | continue; 157 | } 158 | 159 | if (src) { 160 | throw new 161 | Error('Infinite loop on byte: ' + src.charCodeAt(0)); 162 | } 163 | } 164 | 165 | return this.tokens; 166 | }; 167 | 168 | /** 169 | * Inline-Level Grammar 170 | */ 171 | 172 | var inline = { 173 | escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, 174 | autolink: /^<([^ >]+(@|:\/)[^ >]+)>/, 175 | link: /^!?\[(inside)\]\(href\)/, 176 | reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, 177 | url: noop, 178 | tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/, 179 | nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/, 180 | strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, 181 | em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, 182 | br: /^ {2,}\n(?!\s*$)/, 183 | text: /^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/; 188 | 189 | inline.link = replace(inline.link) 190 | ('inside', inline._inside) 191 | ('href', inline._href) 192 | (); 193 | 194 | inline.reflink = replace(inline.reflink) 195 | ('inside', inline._inside) 196 | (); 197 | 198 | /** 199 | * Normal Inline Grammar 200 | */ 201 | 202 | inline.normal = merge({}, inline); 203 | 204 | /** 205 | * Pedantic Inline Grammar 206 | */ 207 | 208 | inline.pedantic = merge({}, inline.normal, { 209 | strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, 210 | em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/ 211 | }); 212 | 213 | /** 214 | * GFM Inline Grammar 215 | */ 216 | 217 | inline.gfm = merge({}, inline.normal, { 218 | escape: replace(inline.escape)('])', '~|])')(), 219 | url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/, 220 | text: replace(inline.text) 221 | (']|', '~]|') 222 | ('|', '|https?://|') 223 | () 224 | }); 225 | 226 | /** 227 | * GFM + Line Breaks Inline Grammar 228 | */ 229 | 230 | inline.breaks = merge({}, inline.gfm, { 231 | br: replace(inline.br)('{2,}', '*')(), 232 | text: replace(inline.gfm.text)('{2,}', '*')() 233 | }); 234 | 235 | /** 236 | * Inline Lexer & Compiler 237 | */ 238 | 239 | function InlineLexer(links, options) { 240 | this.options = options || marked.defaults; 241 | this.links = links; 242 | this.rules = inline.normal; 243 | this.renderer = this.options.renderer || new Renderer; 244 | this.renderer.options = this.options; 245 | 246 | if (!this.links) { 247 | throw new 248 | Error('Tokens array requires a `links` property.'); 249 | } 250 | 251 | if (this.options.gfm) { 252 | if (this.options.breaks) { 253 | this.rules = inline.breaks; 254 | } else { 255 | this.rules = inline.gfm; 256 | } 257 | } else if (this.options.pedantic) { 258 | this.rules = inline.pedantic; 259 | } 260 | } 261 | 262 | /** 263 | * Expose Inline Rules 264 | */ 265 | 266 | InlineLexer.rules = inline; 267 | 268 | /** 269 | * Static Lexing/Compiling Method 270 | */ 271 | 272 | InlineLexer.output = function(src, links, options) { 273 | var inline = new InlineLexer(links, options); 274 | return inline.output(src); 275 | }; 276 | 277 | /** 278 | * Lexing/Compiling 279 | */ 280 | 281 | InlineLexer.prototype.output = function(src) { 282 | var out = '' 283 | , link 284 | , text 285 | , href 286 | , cap; 287 | 288 | while (src) { 289 | // escape 290 | if (cap = this.rules.escape.exec(src)) { 291 | src = src.substring(cap[0].length); 292 | out += cap[1]; 293 | continue; 294 | } 295 | 296 | // autolink 297 | if (cap = this.rules.autolink.exec(src)) { 298 | src = src.substring(cap[0].length); 299 | if (cap[2] === '@') { 300 | text = cap[1].charAt(6) === ':' 301 | ? this.mangle(cap[1].substring(7)) 302 | : this.mangle(cap[1]); 303 | href = this.mangle('mailto:') + text; 304 | } else { 305 | text = escape(cap[1]); 306 | href = text; 307 | } 308 | out += this.renderer.link(href, null, text); 309 | continue; 310 | } 311 | 312 | // url (gfm) 313 | if (!this.inLink && (cap = this.rules.url.exec(src))) { 314 | src = src.substring(cap[0].length); 315 | text = escape(cap[1]); 316 | href = text; 317 | out += this.renderer.link(href, null, text); 318 | continue; 319 | } 320 | 321 | // link 322 | if (cap = this.rules.link.exec(src)) { 323 | src = src.substring(cap[0].length); 324 | this.inLink = true; 325 | out += this.outputLink(cap, { 326 | href: cap[2], 327 | title: cap[3] 328 | }); 329 | this.inLink = false; 330 | continue; 331 | } 332 | 333 | // reflink, nolink 334 | if ((cap = this.rules.reflink.exec(src)) 335 | || (cap = this.rules.nolink.exec(src))) { 336 | src = src.substring(cap[0].length); 337 | link = (cap[2] || cap[1]).replace(/\s+/g, ' '); 338 | link = this.links[link.toLowerCase()]; 339 | if (!link || !link.href) { 340 | out += cap[0].charAt(0); 341 | src = cap[0].substring(1) + src; 342 | continue; 343 | } 344 | this.inLink = true; 345 | out += this.outputLink(cap, link); 346 | this.inLink = false; 347 | continue; 348 | } 349 | 350 | // strong 351 | if (cap = this.rules.strong.exec(src)) { 352 | src = src.substring(cap[0].length); 353 | out += this.renderer.strong(this.output(cap[2] || cap[1])); 354 | continue; 355 | } 356 | 357 | // em 358 | if (cap = this.rules.em.exec(src)) { 359 | src = src.substring(cap[0].length); 360 | out += this.renderer.em(this.output(cap[2] || cap[1])); 361 | continue; 362 | } 363 | 364 | // br 365 | if (cap = this.rules.br.exec(src)) { 366 | src = src.substring(cap[0].length); 367 | out += this.renderer.br(); 368 | continue; 369 | } 370 | 371 | // text 372 | if (cap = this.rules.text.exec(src)) { 373 | src = src.substring(cap[0].length); 374 | out += escape(this.smartypants(cap[0])); 375 | continue; 376 | } 377 | 378 | if (src) { 379 | throw new 380 | Error('Infinite loop on byte: ' + src.charCodeAt(0)); 381 | } 382 | } 383 | 384 | return out; 385 | }; 386 | 387 | /** 388 | * Compile Link 389 | */ 390 | 391 | InlineLexer.prototype.outputLink = function(cap, link) { 392 | var href = escape(link.href) 393 | , title = link.title ? escape(link.title) : null; 394 | 395 | return cap[0].charAt(0) !== '!' 396 | ? this.renderer.link(href, title, this.output(cap[1])) 397 | : this.renderer.image(href, title, escape(cap[1])); 398 | }; 399 | 400 | /** 401 | * Smartypants Transformations 402 | */ 403 | 404 | InlineLexer.prototype.smartypants = function(text) { 405 | if (!this.options.smartypants) return text; 406 | return text 407 | // em-dashes 408 | .replace(/--/g, '\u2014') 409 | // opening singles 410 | .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018') 411 | // closing singles & apostrophes 412 | .replace(/'/g, '\u2019') 413 | // opening doubles 414 | .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c') 415 | // closing doubles 416 | .replace(/"/g, '\u201d') 417 | // ellipses 418 | .replace(/\.{3}/g, '\u2026'); 419 | }; 420 | 421 | /** 422 | * Mangle Links 423 | */ 424 | 425 | InlineLexer.prototype.mangle = function(text) { 426 | var out = '' 427 | , l = text.length 428 | , i = 0 429 | , ch; 430 | 431 | for (; i < l; i++) { 432 | ch = text.charCodeAt(i); 433 | if (Math.random() > 0.5) { 434 | ch = 'x' + ch.toString(16); 435 | } 436 | out += '&#' + ch + ';'; 437 | } 438 | 439 | return out; 440 | }; 441 | 442 | /** 443 | * Renderer 444 | */ 445 | 446 | function Renderer(options) { 447 | this.options = options || {}; 448 | } 449 | 450 | Renderer.prototype.code = function(code, lang, escaped) { 451 | if (this.options.highlight) { 452 | var out = this.options.highlight(code, lang); 453 | if (out != null && out !== code) { 454 | escaped = true; 455 | code = out; 456 | } 457 | } 458 | 459 | if (!lang) { 460 | return '
    '
    461 |       + (escaped ? code : escape(code, true))
    462 |       + '\n
    '; 463 | } 464 | 465 | return '
    '
    469 |     + (escaped ? code : escape(code, true))
    470 |     + '\n
    \n'; 471 | }; 472 | 473 | Renderer.prototype.blockquote = function(quote) { 474 | return '
    \n' + quote + '
    \n'; 475 | }; 476 | 477 | Renderer.prototype.html = function(html) { 478 | return html; 479 | }; 480 | 481 | Renderer.prototype.heading = function(text, level, raw) { 482 | return '' 488 | + text 489 | + '\n'; 492 | }; 493 | 494 | Renderer.prototype.hr = function() { 495 | return this.options.xhtml ? '
    \n' : '
    \n'; 496 | }; 497 | 498 | Renderer.prototype.list = function(body, ordered) { 499 | var type = ordered ? 'ol' : 'ul'; 500 | return '<' + type + '>\n' + body + '\n'; 501 | }; 502 | 503 | Renderer.prototype.listitem = function(text) { 504 | return '
  • ' + text + '
  • \n'; 505 | }; 506 | 507 | Renderer.prototype.paragraph = function(text) { 508 | return '

    ' + text + '

    \n'; 509 | }; 510 | 511 | Renderer.prototype.table = function(header, body) { 512 | return '\n' 513 | + '\n' 514 | + header 515 | + '\n' 516 | + '\n' 517 | + body 518 | + '\n' 519 | + '
    \n'; 520 | }; 521 | 522 | Renderer.prototype.tablerow = function(content) { 523 | return '\n' + content + '\n'; 524 | }; 525 | 526 | Renderer.prototype.tablecell = function(content, flags) { 527 | var type = flags.header ? 'th' : 'td'; 528 | var tag = flags.align 529 | ? '<' + type + ' style="text-align:' + flags.align + '">' 530 | : '<' + type + '>'; 531 | return tag + content + '\n'; 532 | }; 533 | 534 | // span level renderer 535 | Renderer.prototype.strong = function(text) { 536 | return '' + text + ''; 537 | }; 538 | 539 | Renderer.prototype.em = function(text) { 540 | return '' + text + ''; 541 | }; 542 | 543 | Renderer.prototype.codespan = function(text) { 544 | return '' + text + ''; 545 | }; 546 | 547 | Renderer.prototype.br = function() { 548 | return this.options.xhtml ? '
    ' : '
    '; 549 | }; 550 | 551 | Renderer.prototype.del = function(text) { 552 | return '' + text + ''; 553 | }; 554 | 555 | Renderer.prototype.link = function(href, title, text) { 556 | if (this.options.sanitize) { 557 | try { 558 | var prot = decodeURIComponent(unescape(href)) 559 | .replace(/[^\w:]/g, '') 560 | .toLowerCase(); 561 | } catch (e) { 562 | return ''; 563 | } 564 | if (prot.indexOf('javascript:') === 0) { 565 | return ''; 566 | } 567 | } 568 | if (!/^(http:\/\/|https:\/\/)/.test(href)) { 569 | href = "http://" + href; 570 | } 571 | var out = '
    '; 576 | return out; 577 | }; 578 | 579 | Renderer.prototype.image = function(href, title, text) { 580 | var out = '' + text + '' : '>'; 585 | return out; 586 | }; 587 | 588 | /** 589 | * Parsing & Compiling 590 | */ 591 | 592 | function Parser(options) { 593 | this.tokens = []; 594 | this.token = null; 595 | this.options = options || marked.defaults; 596 | this.options.renderer = this.options.renderer || new Renderer; 597 | this.renderer = this.options.renderer; 598 | this.renderer.options = this.options; 599 | } 600 | 601 | /** 602 | * Static Parse Method 603 | */ 604 | 605 | Parser.parse = function(src, options, renderer) { 606 | var parser = new Parser(options, renderer); 607 | return parser.parse(src); 608 | }; 609 | 610 | /** 611 | * Parse Loop 612 | */ 613 | 614 | Parser.prototype.parse = function(src) { 615 | this.inline = new InlineLexer(src.links, this.options, this.renderer); 616 | this.tokens = src.reverse(); 617 | 618 | var out = ''; 619 | while (this.next()) { 620 | out += this.tok(); 621 | } 622 | 623 | return out; 624 | }; 625 | 626 | /** 627 | * Next Token 628 | */ 629 | 630 | Parser.prototype.next = function() { 631 | return this.token = this.tokens.pop(); 632 | }; 633 | 634 | /** 635 | * Preview Next Token 636 | */ 637 | 638 | Parser.prototype.peek = function() { 639 | return this.tokens[this.tokens.length - 1] || 0; 640 | }; 641 | 642 | /** 643 | * Parse Text Tokens 644 | */ 645 | 646 | Parser.prototype.parseText = function() { 647 | var body = this.token.text; 648 | 649 | while (this.peek().type === 'text') { 650 | body += '\n' + this.next().text; 651 | } 652 | 653 | return this.inline.output(body); 654 | }; 655 | 656 | /** 657 | * Parse Current Token 658 | */ 659 | 660 | Parser.prototype.tok = function() { 661 | switch (this.token.type) { 662 | case 'space': { 663 | return ''; 664 | } 665 | case 'html': { 666 | var html = !this.token.pre && !this.options.pedantic 667 | ? this.inline.output(this.token.text) 668 | : this.token.text; 669 | return this.renderer.html(html); 670 | } 671 | case 'paragraph': { 672 | return this.renderer.paragraph(this.inline.output(this.token.text)); 673 | } 674 | case 'text': { 675 | return this.renderer.paragraph(this.parseText()); 676 | } 677 | } 678 | }; 679 | 680 | /** 681 | * Helpers 682 | */ 683 | 684 | function escape(html, encode) { 685 | return html 686 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') 687 | .replace(//g, '>') 689 | .replace(/"/g, '"') 690 | .replace(/'/g, '''); 691 | } 692 | 693 | function unescape(html) { 694 | return html.replace(/&([#\w]+);/g, function(_, n) { 695 | n = n.toLowerCase(); 696 | if (n === 'colon') return ':'; 697 | if (n.charAt(0) === '#') { 698 | return n.charAt(1) === 'x' 699 | ? String.fromCharCode(parseInt(n.substring(2), 16)) 700 | : String.fromCharCode(+n.substring(1)); 701 | } 702 | return ''; 703 | }); 704 | } 705 | 706 | function replace(regex, opt) { 707 | regex = regex.source; 708 | opt = opt || ''; 709 | return function self(name, val) { 710 | if (!name) return new RegExp(regex, opt); 711 | val = val.source || val; 712 | val = val.replace(/(^|[^\[])\^/g, '$1'); 713 | regex = regex.replace(name, val); 714 | return self; 715 | }; 716 | } 717 | 718 | function noop() {} 719 | noop.exec = noop; 720 | 721 | function merge(obj) { 722 | var i = 1 723 | , target 724 | , key; 725 | 726 | for (; i < arguments.length; i++) { 727 | target = arguments[i]; 728 | for (key in target) { 729 | if (Object.prototype.hasOwnProperty.call(target, key)) { 730 | obj[key] = target[key]; 731 | } 732 | } 733 | } 734 | 735 | return obj; 736 | } 737 | 738 | 739 | /** 740 | * Marked 741 | */ 742 | 743 | function marked(src, opt, callback) { 744 | if (callback || typeof opt === 'function') { 745 | if (!callback) { 746 | callback = opt; 747 | opt = null; 748 | } 749 | 750 | opt = merge({}, marked.defaults, opt || {}); 751 | 752 | var highlight = opt.highlight 753 | , tokens 754 | , pending 755 | , i = 0; 756 | 757 | try { 758 | tokens = Lexer.lex(src, opt) 759 | } catch (e) { 760 | return callback(e); 761 | } 762 | 763 | pending = tokens.length; 764 | 765 | var done = function(err) { 766 | if (err) { 767 | opt.highlight = highlight; 768 | return callback(err); 769 | } 770 | 771 | var out; 772 | 773 | try { 774 | out = Parser.parse(tokens, opt); 775 | } catch (e) { 776 | err = e; 777 | } 778 | 779 | opt.highlight = highlight; 780 | 781 | return err 782 | ? callback(err) 783 | : callback(null, out); 784 | }; 785 | 786 | if (!highlight || highlight.length < 3) { 787 | return done(); 788 | } 789 | 790 | delete opt.highlight; 791 | 792 | if (!pending) return done(); 793 | 794 | for (; i < tokens.length; i++) { 795 | (function(token) { 796 | if (token.type !== 'code') { 797 | return --pending || done(); 798 | } 799 | return highlight(token.text, token.lang, function(err, code) { 800 | if (err) return done(err); 801 | if (code == null || code === token.text) { 802 | return --pending || done(); 803 | } 804 | token.text = code; 805 | token.escaped = true; 806 | --pending || done(); 807 | }); 808 | })(tokens[i]); 809 | } 810 | 811 | return; 812 | } 813 | try { 814 | if (opt) opt = merge({}, marked.defaults, opt); 815 | return Parser.parse(Lexer.lex(src, opt), opt); 816 | } catch (e) { 817 | e.message += '\nPlease report this to https://github.com/chjj/marked.'; 818 | if ((opt || marked.defaults).silent) { 819 | return '

    An error occured:

    '
    820 |         + escape(e.message + '', true)
    821 |         + '
    '; 822 | } 823 | throw e; 824 | } 825 | } 826 | 827 | /** 828 | * Options 829 | */ 830 | 831 | marked.options = 832 | marked.setOptions = function(opt) { 833 | merge(marked.defaults, opt); 834 | return marked; 835 | }; 836 | 837 | marked.defaults = { 838 | gfm: true, 839 | tables: true, 840 | breaks: false, 841 | pedantic: false, 842 | sanitize: false, 843 | smartLists: false, 844 | silent: false, 845 | highlight: null, 846 | langPrefix: 'lang-', 847 | smartypants: false, 848 | headerPrefix: '', 849 | renderer: new Renderer, 850 | xhtml: false 851 | }; 852 | 853 | /** 854 | * Expose 855 | */ 856 | 857 | marked.Parser = Parser; 858 | marked.parser = Parser.parse; 859 | 860 | marked.Renderer = Renderer; 861 | 862 | marked.Lexer = Lexer; 863 | marked.lexer = Lexer.lex; 864 | 865 | marked.InlineLexer = InlineLexer; 866 | marked.inlineLexer = InlineLexer.output; 867 | 868 | marked.parse = marked; 869 | 870 | if (typeof module !== 'undefined' && typeof exports === 'object') { 871 | module.exports = marked; 872 | } else if (typeof define === 'function' && define.amd) { 873 | define(function() { return marked; }); 874 | } else { 875 | this.marked = marked; 876 | } 877 | 878 | }).call(function() { 879 | return this || (typeof window !== 'undefined' ? window : global); 880 | }()); 881 | --------------------------------------------------------------------------------