From 73e265d8fd050ae3daa67472b4465a5c49d68910 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Sat, 20 Apr 2019 15:18:33 +0300 Subject: Include to Wekan packages directory contents, so that meteor command would build all directly. This also simplifies build scripts. Thanks to xet7 ! --- packages/markdown/.gitignore | 1 + packages/markdown/README.md | 40 + packages/markdown/markdown.js | 9 + packages/markdown/marked/.editorconfig | 16 + packages/markdown/marked/.eslintignore | 1 + packages/markdown/marked/.eslintrc.json | 29 + packages/markdown/marked/.gitattributes | 2 + packages/markdown/marked/.github/ISSUE_TEMPLATE.md | 42 + .../marked/.github/ISSUE_TEMPLATE/Bug_report.md | 27 + .../.github/ISSUE_TEMPLATE/Feature_request.md | 14 + .../marked/.github/ISSUE_TEMPLATE/Proposal.md | 11 + .../marked/.github/PULL_REQUEST_TEMPLATE.md | 53 + .../marked/.github/PULL_REQUEST_TEMPLATE/badges.md | 50 + .../.github/PULL_REQUEST_TEMPLATE/release.md | 25 + packages/markdown/marked/.gitignore | 3 + packages/markdown/marked/.travis.yml | 46 + packages/markdown/marked/LICENSE.md | 43 + packages/markdown/marked/Makefile | 15 + packages/markdown/marked/README.md | 76 + packages/markdown/marked/bin/marked | 215 + packages/markdown/marked/bower.json | 23 + packages/markdown/marked/component.json | 10 + packages/markdown/marked/docs/AUTHORS.md | 269 + packages/markdown/marked/docs/CNAME | 1 + packages/markdown/marked/docs/CODE_OF_CONDUCT.md | 74 + packages/markdown/marked/docs/CONTRIBUTING.md | 92 + packages/markdown/marked/docs/PUBLISHING.md | 24 + packages/markdown/marked/docs/README.md | 85 + packages/markdown/marked/docs/USING_ADVANCED.md | 78 + packages/markdown/marked/docs/USING_PRO.md | 163 + packages/markdown/marked/docs/broken.md | 426 ++ packages/markdown/marked/docs/demo/demo.css | 72 + packages/markdown/marked/docs/demo/demo.js | 534 ++ packages/markdown/marked/docs/demo/index.html | 78 + packages/markdown/marked/docs/demo/initial.md | 36 + packages/markdown/marked/docs/demo/preview.html | 12 + packages/markdown/marked/docs/demo/quickref.md | 167 + packages/markdown/marked/docs/demo/worker.js | 105 + .../marked/docs/img/logo-black-and-white.svg | 133 + packages/markdown/marked/docs/img/logo-black.svg | 32 + packages/markdown/marked/docs/index.html | 269 + packages/markdown/marked/index.js | 1 + packages/markdown/marked/jasmine.json | 11 + packages/markdown/marked/lib/marked.js | 1689 +++++++ packages/markdown/marked/man/marked.1 | 114 + packages/markdown/marked/man/marked.1.txt | 99 + packages/markdown/marked/marked.min.js | 6 + packages/markdown/marked/package.json | 69 + packages/markdown/marked/test/README | 10 + packages/markdown/marked/test/browser/index.html | 5 + packages/markdown/marked/test/browser/index.js | 39 + packages/markdown/marked/test/browser/test.js | 66 + packages/markdown/marked/test/helpers/helpers.js | 26 + .../markdown/marked/test/helpers/html-differ.js | 38 + packages/markdown/marked/test/index.js | 551 ++ packages/markdown/marked/test/json-to-files.js | 62 + .../markdown/marked/test/new/adjacent_lists.html | 9 + .../markdown/marked/test/new/adjacent_lists.md | 5 + .../markdown/marked/test/new/autolink_lines.html | 3 + .../markdown/marked/test/new/autolink_lines.md | 2 + packages/markdown/marked/test/new/autolinks.html | 15 + packages/markdown/marked/test/new/autolinks.md | 15 + .../marked/test/new/blockquote_list_item.html | 3 + .../marked/test/new/blockquote_list_item.md | 4 + .../marked/test/new/case_insensitive_refs.html | 1 + .../marked/test/new/case_insensitive_refs.md | 3 + .../markdown/marked/test/new/cm_autolinks.html | 91 + packages/markdown/marked/test/new/cm_autolinks.md | 96 + .../markdown/marked/test/new/cm_blockquotes.html | 233 + .../markdown/marked/test/new/cm_blockquotes.md | 189 + .../markdown/marked/test/new/cm_html_blocks.html | 300 ++ .../markdown/marked/test/new/cm_html_blocks.md | 312 ++ .../markdown/marked/test/new/cm_link_defs.html | 115 + packages/markdown/marked/test/new/cm_link_defs.md | 157 + packages/markdown/marked/test/new/cm_links.html | 397 ++ packages/markdown/marked/test/new/cm_links.md | 515 ++ packages/markdown/marked/test/new/cm_raw_html.html | 77 + packages/markdown/marked/test/new/cm_raw_html.md | 78 + .../markdown/marked/test/new/cm_strong_and_em.html | 7 + .../markdown/marked/test/new/cm_strong_and_em.md | 7 + .../marked/test/new/cm_thematic_breaks.html | 106 + .../markdown/marked/test/new/cm_thematic_breaks.md | 98 + packages/markdown/marked/test/new/code_spans.html | 3 + packages/markdown/marked/test/new/code_spans.md | 3 + packages/markdown/marked/test/new/def_blocks.html | 30 + packages/markdown/marked/test/new/def_blocks.md | 21 + packages/markdown/marked/test/new/double_link.html | 5 + packages/markdown/marked/test/new/double_link.md | 5 + packages/markdown/marked/test/new/em_2char.html | 25 + packages/markdown/marked/test/new/em_2char.md | 25 + .../marked/test/new/emphasis_extra tests.html | 1 + .../marked/test/new/emphasis_extra tests.md | 1 + .../markdown/marked/test/new/escaped_angles.html | 1 + .../markdown/marked/test/new/escaped_angles.md | 1 + .../markdown/marked/test/new/gfm_autolinks.html | 83 + packages/markdown/marked/test/new/gfm_autolinks.md | 83 + packages/markdown/marked/test/new/gfm_break.html | 1 + packages/markdown/marked/test/new/gfm_break.md | 6 + packages/markdown/marked/test/new/gfm_code.html | 21 + packages/markdown/marked/test/new/gfm_code.md | 43 + .../markdown/marked/test/new/gfm_code_hr_list.html | 52 + .../markdown/marked/test/new/gfm_code_hr_list.md | 53 + packages/markdown/marked/test/new/gfm_em.html | 1 + packages/markdown/marked/test/new/gfm_em.md | 1 + packages/markdown/marked/test/new/gfm_hashtag.html | 5 + packages/markdown/marked/test/new/gfm_hashtag.md | 8 + .../marked/test/new/gfm_links_invalid.html | 1 + .../markdown/marked/test/new/gfm_links_invalid.md | 4 + packages/markdown/marked/test/new/gfm_tables.html | 37 + packages/markdown/marked/test/new/gfm_tables.md | 21 + packages/markdown/marked/test/new/headings_id.html | 13 + packages/markdown/marked/test/new/headings_id.md | 14 + .../markdown/marked/test/new/hr_list_break.html | 10 + packages/markdown/marked/test/new/hr_list_break.md | 6 + .../markdown/marked/test/new/html_comments.html | 57 + packages/markdown/marked/test/new/html_comments.md | 56 + .../markdown/marked/test/new/html_no_new_line.html | 1 + .../markdown/marked/test/new/html_no_new_line.md | 1 + packages/markdown/marked/test/new/images.html | 5 + packages/markdown/marked/test/new/images.md | 12 + .../markdown/marked/test/new/lazy_blockquotes.html | 4 + .../markdown/marked/test/new/lazy_blockquotes.md | 2 + packages/markdown/marked/test/new/link_lt.html | 1 + packages/markdown/marked/test/new/link_lt.md | 1 + .../markdown/marked/test/new/link_tick_redos.html | 31 + .../markdown/marked/test/new/link_tick_redos.md | 31 + packages/markdown/marked/test/new/links.html | 3 + packages/markdown/marked/test/new/links.md | 5 + .../markdown/marked/test/new/list_item_text.html | 1 + .../markdown/marked/test/new/list_item_text.md | 5 + packages/markdown/marked/test/new/list_table.html | 44 + packages/markdown/marked/test/new/list_table.md | 13 + packages/markdown/marked/test/new/main.html | 4 + packages/markdown/marked/test/new/main.md | 55 + packages/markdown/marked/test/new/mangle_xss.html | 3 + packages/markdown/marked/test/new/mangle_xss.md | 7 + packages/markdown/marked/test/new/nested_code.html | 9 + packages/markdown/marked/test/new/nested_code.md | 9 + packages/markdown/marked/test/new/nested_em.html | 3 + packages/markdown/marked/test/new/nested_em.md | 3 + .../marked/test/new/nested_square_link.html | 3 + .../markdown/marked/test/new/nested_square_link.md | 3 + .../markdown/marked/test/new/nogfm_hashtag.html | 5 + packages/markdown/marked/test/new/nogfm_hashtag.md | 8 + packages/markdown/marked/test/new/not_a_link.html | 1 + packages/markdown/marked/test/new/not_a_link.md | 1 + packages/markdown/marked/test/new/ref_paren.html | 1 + packages/markdown/marked/test/new/ref_paren.md | 3 + .../markdown/marked/test/new/relative_urls.html | 35 + packages/markdown/marked/test/new/relative_urls.md | 30 + packages/markdown/marked/test/new/same_bullet.html | 5 + packages/markdown/marked/test/new/same_bullet.md | 3 + .../markdown/marked/test/new/sanitize_links.html | 5 + .../markdown/marked/test/new/sanitize_links.md | 12 + packages/markdown/marked/test/new/smartypants.html | 6 + packages/markdown/marked/test/new/smartypants.md | 9 + .../markdown/marked/test/new/smartypants_code.html | 11 + .../markdown/marked/test/new/smartypants_code.md | 15 + packages/markdown/marked/test/new/table_cells.html | 27 + packages/markdown/marked/test/new/table_cells.md | 55 + .../marked/test/new/toplevel_paragraphs.html | 34 + .../marked/test/new/toplevel_paragraphs.md | 41 + packages/markdown/marked/test/new/tricky_list.html | 23 + packages/markdown/marked/test/new/tricky_list.md | 15 + .../markdown/marked/test/new/uppercase_hex.html | 2 + packages/markdown/marked/test/new/uppercase_hex.md | 5 + .../test/original/amps_and_angles_encoding.html | 17 + .../test/original/amps_and_angles_encoding.md | 25 + .../markdown/marked/test/original/auto_links.html | 18 + .../markdown/marked/test/original/auto_links.md | 13 + .../marked/test/original/backslash_escapes.html | 118 + .../marked/test/original/backslash_escapes.md | 120 + .../original/blockquotes_with_code_blocks.html | 15 + .../test/original/blockquotes_with_code_blocks.md | 11 + .../markdown/marked/test/original/code_blocks.html | 18 + .../markdown/marked/test/original/code_blocks.md | 14 + .../markdown/marked/test/original/code_spans.html | 6 + .../markdown/marked/test/original/code_spans.md | 6 + ...rd_wrapped_paragraphs_with_list_like_lines.html | 8 + ...hard_wrapped_paragraphs_with_list_like_lines.md | 8 + .../marked/test/original/horizontal_rules.html | 85 + .../marked/test/original/horizontal_rules.md | 94 + .../marked/test/original/inline_html_advanced.html | 15 + .../marked/test/original/inline_html_advanced.md | 15 + .../marked/test/original/inline_html_comments.html | 13 + .../marked/test/original/inline_html_comments.md | 13 + .../marked/test/original/inline_html_simple.html | 72 + .../marked/test/original/inline_html_simple.md | 69 + .../marked/test/original/links_inline_style.html | 15 + .../marked/test/original/links_inline_style.md | 19 + .../test/original/links_reference_style.html | 52 + .../marked/test/original/links_reference_style.md | 75 + .../test/original/links_shortcut_references.html | 9 + .../test/original/links_shortcut_references.md | 24 + .../test/original/literal_quotes_in_titles.html | 3 + .../test/original/literal_quotes_in_titles.md | 11 + .../original/markdown_documentation_basics.html | 314 ++ .../test/original/markdown_documentation_basics.md | 310 ++ .../original/markdown_documentation_syntax.html | 942 ++++ .../test/original/markdown_documentation_syntax.md | 892 ++++ .../marked/test/original/nested_blockquotes.html | 9 + .../marked/test/original/nested_blockquotes.md | 5 + .../test/original/ordered_and_unordered_lists.html | 164 + .../test/original/ordered_and_unordered_lists.md | 144 + .../test/original/strong_and_em_together.html | 7 + .../marked/test/original/strong_and_em_together.md | 7 + packages/markdown/marked/test/original/tabs.html | 25 + packages/markdown/marked/test/original/tabs.md | 21 + .../markdown/marked/test/original/tidyness.html | 8 + packages/markdown/marked/test/original/tidyness.md | 5 + .../markdown/marked/test/redos/link_redos.html | 5 + packages/markdown/marked/test/redos/link_redos.md | 2 + .../markdown/marked/test/redos/quadratic_br.js | 4 + .../markdown/marked/test/redos/quadratic_email.js | 4 + .../marked/test/redos/redos_html_closing.html | 1 + .../marked/test/redos/redos_html_closing.md | 1 + .../markdown/marked/test/redos/redos_nolink.html | 1 + .../markdown/marked/test/redos/redos_nolink.md | 1 + .../test/specs/commonmark/commonmark.0.29.json | 5327 ++++++++++++++++++++ .../marked/test/specs/commonmark/getSpecs.js | 24 + .../markdown/marked/test/specs/gfm/getSpecs.js | 44 + .../markdown/marked/test/specs/gfm/gfm.0.29.json | 147 + .../marked/test/specs/original/specs-spec.js | 12 + packages/markdown/marked/test/specs/redos-spec.js | 24 + packages/markdown/marked/test/specs/run-spec.js | 52 + packages/markdown/marked/test/unit/marked-spec.js | 73 + packages/markdown/package.js | 24 + packages/markdown/smart.json | 9 + packages/markdown/template-integration.js | 16 + 229 files changed, 19938 insertions(+) create mode 100755 packages/markdown/.gitignore create mode 100755 packages/markdown/README.md create mode 100755 packages/markdown/markdown.js create mode 100644 packages/markdown/marked/.editorconfig create mode 100644 packages/markdown/marked/.eslintignore create mode 100644 packages/markdown/marked/.eslintrc.json create mode 100644 packages/markdown/marked/.gitattributes create mode 100644 packages/markdown/marked/.github/ISSUE_TEMPLATE.md create mode 100644 packages/markdown/marked/.github/ISSUE_TEMPLATE/Bug_report.md create mode 100644 packages/markdown/marked/.github/ISSUE_TEMPLATE/Feature_request.md create mode 100644 packages/markdown/marked/.github/ISSUE_TEMPLATE/Proposal.md create mode 100644 packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/badges.md create mode 100644 packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/release.md create mode 100644 packages/markdown/marked/.gitignore create mode 100644 packages/markdown/marked/.travis.yml create mode 100644 packages/markdown/marked/LICENSE.md create mode 100644 packages/markdown/marked/Makefile create mode 100644 packages/markdown/marked/README.md create mode 100755 packages/markdown/marked/bin/marked create mode 100644 packages/markdown/marked/bower.json create mode 100644 packages/markdown/marked/component.json create mode 100644 packages/markdown/marked/docs/AUTHORS.md create mode 100644 packages/markdown/marked/docs/CNAME create mode 100644 packages/markdown/marked/docs/CODE_OF_CONDUCT.md create mode 100644 packages/markdown/marked/docs/CONTRIBUTING.md create mode 100644 packages/markdown/marked/docs/PUBLISHING.md create mode 100644 packages/markdown/marked/docs/README.md create mode 100644 packages/markdown/marked/docs/USING_ADVANCED.md create mode 100644 packages/markdown/marked/docs/USING_PRO.md create mode 100644 packages/markdown/marked/docs/broken.md create mode 100644 packages/markdown/marked/docs/demo/demo.css create mode 100644 packages/markdown/marked/docs/demo/demo.js create mode 100644 packages/markdown/marked/docs/demo/index.html create mode 100644 packages/markdown/marked/docs/demo/initial.md create mode 100644 packages/markdown/marked/docs/demo/preview.html create mode 100644 packages/markdown/marked/docs/demo/quickref.md create mode 100644 packages/markdown/marked/docs/demo/worker.js create mode 100644 packages/markdown/marked/docs/img/logo-black-and-white.svg create mode 100644 packages/markdown/marked/docs/img/logo-black.svg create mode 100644 packages/markdown/marked/docs/index.html create mode 100644 packages/markdown/marked/index.js create mode 100644 packages/markdown/marked/jasmine.json create mode 100644 packages/markdown/marked/lib/marked.js create mode 100644 packages/markdown/marked/man/marked.1 create mode 100644 packages/markdown/marked/man/marked.1.txt create mode 100644 packages/markdown/marked/marked.min.js create mode 100644 packages/markdown/marked/package.json create mode 100644 packages/markdown/marked/test/README create mode 100644 packages/markdown/marked/test/browser/index.html create mode 100644 packages/markdown/marked/test/browser/index.js create mode 100644 packages/markdown/marked/test/browser/test.js create mode 100644 packages/markdown/marked/test/helpers/helpers.js create mode 100644 packages/markdown/marked/test/helpers/html-differ.js create mode 100644 packages/markdown/marked/test/index.js create mode 100644 packages/markdown/marked/test/json-to-files.js create mode 100644 packages/markdown/marked/test/new/adjacent_lists.html create mode 100644 packages/markdown/marked/test/new/adjacent_lists.md create mode 100644 packages/markdown/marked/test/new/autolink_lines.html create mode 100644 packages/markdown/marked/test/new/autolink_lines.md create mode 100644 packages/markdown/marked/test/new/autolinks.html create mode 100644 packages/markdown/marked/test/new/autolinks.md create mode 100644 packages/markdown/marked/test/new/blockquote_list_item.html create mode 100644 packages/markdown/marked/test/new/blockquote_list_item.md create mode 100644 packages/markdown/marked/test/new/case_insensitive_refs.html create mode 100644 packages/markdown/marked/test/new/case_insensitive_refs.md create mode 100644 packages/markdown/marked/test/new/cm_autolinks.html create mode 100644 packages/markdown/marked/test/new/cm_autolinks.md create mode 100644 packages/markdown/marked/test/new/cm_blockquotes.html create mode 100644 packages/markdown/marked/test/new/cm_blockquotes.md create mode 100644 packages/markdown/marked/test/new/cm_html_blocks.html create mode 100644 packages/markdown/marked/test/new/cm_html_blocks.md create mode 100644 packages/markdown/marked/test/new/cm_link_defs.html create mode 100644 packages/markdown/marked/test/new/cm_link_defs.md create mode 100644 packages/markdown/marked/test/new/cm_links.html create mode 100644 packages/markdown/marked/test/new/cm_links.md create mode 100644 packages/markdown/marked/test/new/cm_raw_html.html create mode 100644 packages/markdown/marked/test/new/cm_raw_html.md create mode 100644 packages/markdown/marked/test/new/cm_strong_and_em.html create mode 100644 packages/markdown/marked/test/new/cm_strong_and_em.md create mode 100644 packages/markdown/marked/test/new/cm_thematic_breaks.html create mode 100644 packages/markdown/marked/test/new/cm_thematic_breaks.md create mode 100644 packages/markdown/marked/test/new/code_spans.html create mode 100644 packages/markdown/marked/test/new/code_spans.md create mode 100644 packages/markdown/marked/test/new/def_blocks.html create mode 100644 packages/markdown/marked/test/new/def_blocks.md create mode 100644 packages/markdown/marked/test/new/double_link.html create mode 100644 packages/markdown/marked/test/new/double_link.md create mode 100644 packages/markdown/marked/test/new/em_2char.html create mode 100644 packages/markdown/marked/test/new/em_2char.md create mode 100644 packages/markdown/marked/test/new/emphasis_extra tests.html create mode 100644 packages/markdown/marked/test/new/emphasis_extra tests.md create mode 100644 packages/markdown/marked/test/new/escaped_angles.html create mode 100644 packages/markdown/marked/test/new/escaped_angles.md create mode 100644 packages/markdown/marked/test/new/gfm_autolinks.html create mode 100644 packages/markdown/marked/test/new/gfm_autolinks.md create mode 100644 packages/markdown/marked/test/new/gfm_break.html create mode 100644 packages/markdown/marked/test/new/gfm_break.md create mode 100644 packages/markdown/marked/test/new/gfm_code.html create mode 100644 packages/markdown/marked/test/new/gfm_code.md create mode 100644 packages/markdown/marked/test/new/gfm_code_hr_list.html create mode 100644 packages/markdown/marked/test/new/gfm_code_hr_list.md create mode 100644 packages/markdown/marked/test/new/gfm_em.html create mode 100644 packages/markdown/marked/test/new/gfm_em.md create mode 100644 packages/markdown/marked/test/new/gfm_hashtag.html create mode 100644 packages/markdown/marked/test/new/gfm_hashtag.md create mode 100644 packages/markdown/marked/test/new/gfm_links_invalid.html create mode 100644 packages/markdown/marked/test/new/gfm_links_invalid.md create mode 100644 packages/markdown/marked/test/new/gfm_tables.html create mode 100644 packages/markdown/marked/test/new/gfm_tables.md create mode 100644 packages/markdown/marked/test/new/headings_id.html create mode 100644 packages/markdown/marked/test/new/headings_id.md create mode 100644 packages/markdown/marked/test/new/hr_list_break.html create mode 100644 packages/markdown/marked/test/new/hr_list_break.md create mode 100644 packages/markdown/marked/test/new/html_comments.html create mode 100644 packages/markdown/marked/test/new/html_comments.md create mode 100644 packages/markdown/marked/test/new/html_no_new_line.html create mode 100644 packages/markdown/marked/test/new/html_no_new_line.md create mode 100644 packages/markdown/marked/test/new/images.html create mode 100644 packages/markdown/marked/test/new/images.md create mode 100644 packages/markdown/marked/test/new/lazy_blockquotes.html create mode 100644 packages/markdown/marked/test/new/lazy_blockquotes.md create mode 100644 packages/markdown/marked/test/new/link_lt.html create mode 100644 packages/markdown/marked/test/new/link_lt.md create mode 100644 packages/markdown/marked/test/new/link_tick_redos.html create mode 100644 packages/markdown/marked/test/new/link_tick_redos.md create mode 100644 packages/markdown/marked/test/new/links.html create mode 100644 packages/markdown/marked/test/new/links.md create mode 100644 packages/markdown/marked/test/new/list_item_text.html create mode 100644 packages/markdown/marked/test/new/list_item_text.md create mode 100644 packages/markdown/marked/test/new/list_table.html create mode 100644 packages/markdown/marked/test/new/list_table.md create mode 100644 packages/markdown/marked/test/new/main.html create mode 100644 packages/markdown/marked/test/new/main.md create mode 100644 packages/markdown/marked/test/new/mangle_xss.html create mode 100644 packages/markdown/marked/test/new/mangle_xss.md create mode 100644 packages/markdown/marked/test/new/nested_code.html create mode 100644 packages/markdown/marked/test/new/nested_code.md create mode 100644 packages/markdown/marked/test/new/nested_em.html create mode 100644 packages/markdown/marked/test/new/nested_em.md create mode 100644 packages/markdown/marked/test/new/nested_square_link.html create mode 100644 packages/markdown/marked/test/new/nested_square_link.md create mode 100644 packages/markdown/marked/test/new/nogfm_hashtag.html create mode 100644 packages/markdown/marked/test/new/nogfm_hashtag.md create mode 100644 packages/markdown/marked/test/new/not_a_link.html create mode 100644 packages/markdown/marked/test/new/not_a_link.md create mode 100644 packages/markdown/marked/test/new/ref_paren.html create mode 100644 packages/markdown/marked/test/new/ref_paren.md create mode 100644 packages/markdown/marked/test/new/relative_urls.html create mode 100644 packages/markdown/marked/test/new/relative_urls.md create mode 100644 packages/markdown/marked/test/new/same_bullet.html create mode 100644 packages/markdown/marked/test/new/same_bullet.md create mode 100644 packages/markdown/marked/test/new/sanitize_links.html create mode 100644 packages/markdown/marked/test/new/sanitize_links.md create mode 100644 packages/markdown/marked/test/new/smartypants.html create mode 100644 packages/markdown/marked/test/new/smartypants.md create mode 100644 packages/markdown/marked/test/new/smartypants_code.html create mode 100644 packages/markdown/marked/test/new/smartypants_code.md create mode 100644 packages/markdown/marked/test/new/table_cells.html create mode 100644 packages/markdown/marked/test/new/table_cells.md create mode 100644 packages/markdown/marked/test/new/toplevel_paragraphs.html create mode 100644 packages/markdown/marked/test/new/toplevel_paragraphs.md create mode 100644 packages/markdown/marked/test/new/tricky_list.html create mode 100644 packages/markdown/marked/test/new/tricky_list.md create mode 100644 packages/markdown/marked/test/new/uppercase_hex.html create mode 100644 packages/markdown/marked/test/new/uppercase_hex.md create mode 100644 packages/markdown/marked/test/original/amps_and_angles_encoding.html create mode 100644 packages/markdown/marked/test/original/amps_and_angles_encoding.md create mode 100644 packages/markdown/marked/test/original/auto_links.html create mode 100644 packages/markdown/marked/test/original/auto_links.md create mode 100644 packages/markdown/marked/test/original/backslash_escapes.html create mode 100644 packages/markdown/marked/test/original/backslash_escapes.md create mode 100644 packages/markdown/marked/test/original/blockquotes_with_code_blocks.html create mode 100644 packages/markdown/marked/test/original/blockquotes_with_code_blocks.md create mode 100644 packages/markdown/marked/test/original/code_blocks.html create mode 100644 packages/markdown/marked/test/original/code_blocks.md create mode 100644 packages/markdown/marked/test/original/code_spans.html create mode 100644 packages/markdown/marked/test/original/code_spans.md create mode 100644 packages/markdown/marked/test/original/hard_wrapped_paragraphs_with_list_like_lines.html create mode 100644 packages/markdown/marked/test/original/hard_wrapped_paragraphs_with_list_like_lines.md create mode 100644 packages/markdown/marked/test/original/horizontal_rules.html create mode 100644 packages/markdown/marked/test/original/horizontal_rules.md create mode 100644 packages/markdown/marked/test/original/inline_html_advanced.html create mode 100644 packages/markdown/marked/test/original/inline_html_advanced.md create mode 100644 packages/markdown/marked/test/original/inline_html_comments.html create mode 100644 packages/markdown/marked/test/original/inline_html_comments.md create mode 100644 packages/markdown/marked/test/original/inline_html_simple.html create mode 100644 packages/markdown/marked/test/original/inline_html_simple.md create mode 100644 packages/markdown/marked/test/original/links_inline_style.html create mode 100644 packages/markdown/marked/test/original/links_inline_style.md create mode 100644 packages/markdown/marked/test/original/links_reference_style.html create mode 100644 packages/markdown/marked/test/original/links_reference_style.md create mode 100644 packages/markdown/marked/test/original/links_shortcut_references.html create mode 100644 packages/markdown/marked/test/original/links_shortcut_references.md create mode 100644 packages/markdown/marked/test/original/literal_quotes_in_titles.html create mode 100644 packages/markdown/marked/test/original/literal_quotes_in_titles.md create mode 100644 packages/markdown/marked/test/original/markdown_documentation_basics.html create mode 100644 packages/markdown/marked/test/original/markdown_documentation_basics.md create mode 100644 packages/markdown/marked/test/original/markdown_documentation_syntax.html create mode 100644 packages/markdown/marked/test/original/markdown_documentation_syntax.md create mode 100644 packages/markdown/marked/test/original/nested_blockquotes.html create mode 100644 packages/markdown/marked/test/original/nested_blockquotes.md create mode 100644 packages/markdown/marked/test/original/ordered_and_unordered_lists.html create mode 100644 packages/markdown/marked/test/original/ordered_and_unordered_lists.md create mode 100644 packages/markdown/marked/test/original/strong_and_em_together.html create mode 100644 packages/markdown/marked/test/original/strong_and_em_together.md create mode 100644 packages/markdown/marked/test/original/tabs.html create mode 100644 packages/markdown/marked/test/original/tabs.md create mode 100644 packages/markdown/marked/test/original/tidyness.html create mode 100644 packages/markdown/marked/test/original/tidyness.md create mode 100644 packages/markdown/marked/test/redos/link_redos.html create mode 100644 packages/markdown/marked/test/redos/link_redos.md create mode 100644 packages/markdown/marked/test/redos/quadratic_br.js create mode 100644 packages/markdown/marked/test/redos/quadratic_email.js create mode 100644 packages/markdown/marked/test/redos/redos_html_closing.html create mode 100644 packages/markdown/marked/test/redos/redos_html_closing.md create mode 100644 packages/markdown/marked/test/redos/redos_nolink.html create mode 100644 packages/markdown/marked/test/redos/redos_nolink.md create mode 100644 packages/markdown/marked/test/specs/commonmark/commonmark.0.29.json create mode 100644 packages/markdown/marked/test/specs/commonmark/getSpecs.js create mode 100644 packages/markdown/marked/test/specs/gfm/getSpecs.js create mode 100644 packages/markdown/marked/test/specs/gfm/gfm.0.29.json create mode 100644 packages/markdown/marked/test/specs/original/specs-spec.js create mode 100644 packages/markdown/marked/test/specs/redos-spec.js create mode 100644 packages/markdown/marked/test/specs/run-spec.js create mode 100644 packages/markdown/marked/test/unit/marked-spec.js create mode 100755 packages/markdown/package.js create mode 100755 packages/markdown/smart.json create mode 100755 packages/markdown/template-integration.js (limited to 'packages/markdown') diff --git a/packages/markdown/.gitignore b/packages/markdown/.gitignore new file mode 100755 index 00000000..677a6fc2 --- /dev/null +++ b/packages/markdown/.gitignore @@ -0,0 +1 @@ +.build* diff --git a/packages/markdown/README.md b/packages/markdown/README.md new file mode 100755 index 00000000..96c5725e --- /dev/null +++ b/packages/markdown/README.md @@ -0,0 +1,40 @@ +markdown +======== + +GitHub flavored markdown parser for Meteor based on marked.js newest version, updated by xet7. + +GFM tables and linebreaks are enabled by default. + + +Usage +----- + +Anywhere inside your template add markdown block and write markdown inside. + +Example: + +``` +{{#markdown}} + +...markdown text here... + +{{/markdown}} +``` + +That's it! + + +Thanks to: +---------- + +- Christopher Jeffrey for marked.js + +- Bozhao Yu for original meteor-markdown package (I just made this package compatible with Meteor 0.9+) + +- Bernhard Millauer - for contributions to this package + +- xet7 for updating to newest GFM package. + +License +------- +MIT diff --git a/packages/markdown/markdown.js b/packages/markdown/markdown.js new file mode 100755 index 00000000..bb015cc4 --- /dev/null +++ b/packages/markdown/markdown.js @@ -0,0 +1,9 @@ +var mark = marked; + +mark.setOptions({ + gfm: true, + tables: true, + breaks: true +}); + +Markdown = mark; diff --git a/packages/markdown/marked/.editorconfig b/packages/markdown/marked/.editorconfig new file mode 100644 index 00000000..97ff4e8a --- /dev/null +++ b/packages/markdown/marked/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*.{json,js}] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.md, !test/*.md] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = 4 \ No newline at end of file diff --git a/packages/markdown/marked/.eslintignore b/packages/markdown/marked/.eslintignore new file mode 100644 index 00000000..121531af --- /dev/null +++ b/packages/markdown/marked/.eslintignore @@ -0,0 +1 @@ +*.min.js diff --git a/packages/markdown/marked/.eslintrc.json b/packages/markdown/marked/.eslintrc.json new file mode 100644 index 00000000..1800cb72 --- /dev/null +++ b/packages/markdown/marked/.eslintrc.json @@ -0,0 +1,29 @@ +{ + "extends": "standard", + "plugins": [ + "standard" + ], + "parserOptions": { "ecmaVersion": 5 }, + "rules": { + "semi": ["error", "always"], + "indent": ["warn", 2, { + "VariableDeclarator": { "var": 2 }, + "SwitchCase": 1, + "outerIIFEBody": 0 + }], + "space-before-function-paren": "off", + "object-curly-spacing": "off", + "operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }], + "no-cond-assign": "off", + "no-useless-escape": "off", + "no-return-assign": "off", + "one-var": "off", + "no-control-regex": "off" + }, + "env": { + "node": true, + "browser": true, + "amd": true, + "jasmine": true + } +} diff --git a/packages/markdown/marked/.gitattributes b/packages/markdown/marked/.gitattributes new file mode 100644 index 00000000..8f2d8c35 --- /dev/null +++ b/packages/markdown/marked/.gitattributes @@ -0,0 +1,2 @@ +test/* linguist-vendored + diff --git a/packages/markdown/marked/.github/ISSUE_TEMPLATE.md b/packages/markdown/marked/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..9df84eaf --- /dev/null +++ b/packages/markdown/marked/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,42 @@ +**Marked version:** + +**Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a + + + + + +## Expectation + +**CommonMark Demo:** [demo](https://spec.commonmark.org/dingus/) + + + + +## Result + +**Marked Demo:** [demo](https://marked.js.org/demo/) + + + + +## What was attempted + + + + diff --git a/packages/markdown/marked/.github/ISSUE_TEMPLATE/Bug_report.md b/packages/markdown/marked/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 00000000..d8042b4d --- /dev/null +++ b/packages/markdown/marked/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Marked says it does this thing but does not + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + + + + + + + +**Expected behavior** +A clear and concise description of what you expected to happen. diff --git a/packages/markdown/marked/.github/ISSUE_TEMPLATE/Feature_request.md b/packages/markdown/marked/.github/ISSUE_TEMPLATE/Feature_request.md new file mode 100644 index 00000000..745d4b43 --- /dev/null +++ b/packages/markdown/marked/.github/ISSUE_TEMPLATE/Feature_request.md @@ -0,0 +1,14 @@ +--- +name: Feature request +about: Marked doesn't do this thing and I think it should + +--- + +**Describe the feature** +A clear and concise description of what you would like. + +**Why is this feature necessary?** +A clear and concise description of why. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. diff --git a/packages/markdown/marked/.github/ISSUE_TEMPLATE/Proposal.md b/packages/markdown/marked/.github/ISSUE_TEMPLATE/Proposal.md new file mode 100644 index 00000000..aa94da3a --- /dev/null +++ b/packages/markdown/marked/.github/ISSUE_TEMPLATE/Proposal.md @@ -0,0 +1,11 @@ +--- +name: Proposal +about: Marked doesn't do this thing and I think it should + +--- + +**What pain point are you perceiving?.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. diff --git a/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE.md b/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..8274e607 --- /dev/null +++ b/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,53 @@ + + + +**Marked version:** + + + +**Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a + +## Description + +- Fixes #### (if fixing a known issue; otherwise, describe issue using the following format) + + + +## Contributor + +- [ ] Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or, +- [ ] no tests required for this PR. +- [ ] If submitting new feature, it has been documented in the appropriate places. + +## Committer + +In most cases, this should be a different person than the contributor. + +- [ ] Draft GitHub release notes have been updated. +- [ ] CI is green (no forced merge required). +- [ ] Merge PR diff --git a/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/badges.md b/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/badges.md new file mode 100644 index 00000000..2078243d --- /dev/null +++ b/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/badges.md @@ -0,0 +1,50 @@ +**@mention the contributor:** + +## Recommendation to: + +- [ ] Change user group +- [ ] Add a badge +- [ ] Remove a badge + + + +## As the one mentioned, I would like to: + +- [ ] accept the recommendation; or, +- [ ] graciously decline; or, +- [ ] dispute the recommendation + +within 30 days, if you have not indicated which option you are taking one of the following will happen: + +1. If adding a badge, we will assume you are graciously declining. +2. If removing a badge, we will assume you do not want to dispute the recommendation; therefore, the badge will be removed. + + + +Note: All committers must approve via review before merging, the disapproving committer can simply close the PR. \ No newline at end of file diff --git a/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/release.md b/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/release.md new file mode 100644 index 00000000..29cd7f2e --- /dev/null +++ b/packages/markdown/marked/.github/PULL_REQUEST_TEMPLATE/release.md @@ -0,0 +1,25 @@ +## Publisher + +- [ ] `$ npm version` has been run. +- [ ] Release notes in [draft GitHub release](https://github.com/markedjs/marked/releases) are up to date +- [ ] Release notes include which flavors and versions of Markdown are supported by this release +- [ ] Committer checklist is complete. +- [ ] Merge PR. +- [ ] Publish GitHub release using `master` with correct version number. +- [ ] `$ npm publish` has been run. +- [ ] Create draft GitHub release to prepare next release. + +Note: If merges to `master` occur after submitting this PR and before running `$ npm pubish` you should be able to + +1. pull from `upstream/master` (`git pull upstream master`) into the branch holding this version, +2. run `$ npm run build` to regenerate the `min` file, and +3. commit and push the updated changes. + +## Committer + +In most cases, this should be someone different than the publisher. + +- [ ] Version in `package.json` has been updated (see [PUBLISHING.md](https://github.com/markedjs/marked/blob/master/docs/PUBLISHING.md)). +- [ ] The `marked.min.js` has been updated; or, +- [ ] release does not change library. +- [ ] CI is green (no forced merge required). diff --git a/packages/markdown/marked/.gitignore b/packages/markdown/marked/.gitignore new file mode 100644 index 00000000..68ccf75d --- /dev/null +++ b/packages/markdown/marked/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +node_modules/ +test/compiled_tests diff --git a/packages/markdown/marked/.travis.yml b/packages/markdown/marked/.travis.yml new file mode 100644 index 00000000..8ff71da4 --- /dev/null +++ b/packages/markdown/marked/.travis.yml @@ -0,0 +1,46 @@ +language: node_js + +jobs: + fast_finish: true + allow_failures: + - stage: security scan 🔐 + + include: + - stage: unit tests 👩🏽‍💻 + script: npm run test:unit + node_js: lts/* + + - stage: spec tests 👩🏽‍💻 + script: npm run test:specs + node_js: v4 + - node_js: lts/* + - node_js: node + + - stage: lint ✨ + script: npm run test:lint + node_js: lts/* + + - stage: minify 🗜️ + script: | + npm run build + if ! git diff --quiet; then + git config --global user.email "travis@travis-ci.org" + git config --global user.name "Travis-CI" + git config credential.helper "store --file=.git/credentials" + echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials + git commit -am '🗜️ minify [skip ci]' + git push origin HEAD:${TRAVIS_BRANCH} + fi + node_js: lts/* + if: branch = master AND type = push + + - stage: security scan 🔐 + script: npm run test:redos + node_js: lts/* + +cache: + directories: + - node_modules + +git: + depth: 3 diff --git a/packages/markdown/marked/LICENSE.md b/packages/markdown/marked/LICENSE.md new file mode 100644 index 00000000..64b41a0e --- /dev/null +++ b/packages/markdown/marked/LICENSE.md @@ -0,0 +1,43 @@ +# License information + +## Contribution License Agreement + +If you contribute code to this project, you are implicitly allowing your code +to be distributed under the MIT license. You are also implicitly verifying that +all code is your original work. `` + +## Marked + +Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +## Markdown + +Copyright © 2004, John Gruber +http://daringfireball.net/ +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. diff --git a/packages/markdown/marked/Makefile b/packages/markdown/marked/Makefile new file mode 100644 index 00000000..7deead54 --- /dev/null +++ b/packages/markdown/marked/Makefile @@ -0,0 +1,15 @@ +all: + @cp lib/marked.js marked.js + @uglifyjs --comments '/\*[^\0]+?Copyright[^\0]+?\*/' -o marked.min.js lib/marked.js + +clean: + @rm marked.js + @rm marked.min.js + +bench: + @node test --bench + +man/marked.1.txt: + groff -man -Tascii man/marked.1 | col -b > man/marked.1.txt + +.PHONY: clean all diff --git a/packages/markdown/marked/README.md b/packages/markdown/marked/README.md new file mode 100644 index 00000000..2dfd5cd1 --- /dev/null +++ b/packages/markdown/marked/README.md @@ -0,0 +1,76 @@ + + + + +# Marked + +[![npm](https://badgen.net/npm/v/marked)](https://www.npmjs.com/package/marked) +[![gzip size](https://badgen.net/badgesize/gzip/https://cdn.jsdelivr.net/npm/marked/marked.min.js)](https://cdn.jsdelivr.net/npm/marked/marked.min.js) +[![install size](https://badgen.net/packagephobia/install/marked)](https://packagephobia.now.sh/result?p=marked) +[![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked) +[![dep](https://badgen.net/david/dep/markedjs/marked?label=deps)](https://david-dm.org/markedjs/marked) +[![dev dep](https://badgen.net/david/dev/markedjs/marked?label=devDeps)](https://david-dm.org/markedjs/marked?type=dev) +[![travis](https://badgen.net/travis/markedjs/marked)](https://travis-ci.org/markedjs/marked) +[![snyk](https://snyk.io/test/npm/marked/badge.svg)](https://snyk.io/test/npm/marked) + +- ⚡ built for speed +- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time +- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications +- 🌐 works in a browser, on a server, or from a command line interface (CLI) + +## Demo + +Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️ + +## Docs + +Our [documentation pages](https://marked.js.org) are also rendered using marked 💯 + +Also read about: + +* [Options](https://marked.js.org/#/USING_ADVANCED.md) +* [Extensibility](https://marked.js.org/#/USING_PRO.md) + +## Installation + +**CLI:** `npm install -g marked` + +**In-browser:** `npm install marked` + +## Usage + +### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/#/USING_ADVANCED.md#options) the output HTML by default 🚨 + +**CLI** + +``` bash +$ marked -o hello.html +hello world +^D +$ cat hello.html +

hello world

+``` + +**Browser** + +```html + + + + + Marked in the browser + + +
+ + + + +``` + +## License + +Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License) diff --git a/packages/markdown/marked/bin/marked b/packages/markdown/marked/bin/marked new file mode 100755 index 00000000..0ea63c54 --- /dev/null +++ b/packages/markdown/marked/bin/marked @@ -0,0 +1,215 @@ +#!/usr/bin/env node + +/** + * Marked CLI + * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License) + */ + +var fs = require('fs'), + path = require('path'), + marked = require('../'); + +/** + * Man Page + */ + +function help() { + var spawn = require('child_process').spawn; + + var options = { + cwd: process.cwd(), + env: process.env, + setsid: false, + stdio: 'inherit' + }; + + spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options) + .on('error', function() { + fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) { + if (err) throw err; + console.log(data); + }); + }); +} + +function version() { + var pkg = require('../package.json'); + console.log(pkg.version); +} + +/** + * Main + */ + +function main(argv, callback) { + var files = [], + options = {}, + input, + output, + string, + arg, + tokens, + opt; + + function getarg() { + var arg = argv.shift(); + + if (arg.indexOf('--') === 0) { + // e.g. --opt + arg = arg.split('='); + if (arg.length > 1) { + // e.g. --opt=val + argv.unshift(arg.slice(1).join('=')); + } + arg = arg[0]; + } else if (arg[0] === '-') { + if (arg.length > 2) { + // e.g. -abc + argv = arg.substring(1).split('').map(function(ch) { + return '-' + ch; + }).concat(argv); + arg = argv.shift(); + } else { + // e.g. -a + } + } else { + // e.g. foo + } + + return arg; + } + + while (argv.length) { + arg = getarg(); + switch (arg) { + case '--test': + return require('../test').main(process.argv.slice()); + case '-o': + case '--output': + output = argv.shift(); + break; + case '-i': + case '--input': + input = argv.shift(); + break; + case '-s': + case '--string': + string = argv.shift(); + break; + case '-t': + case '--tokens': + tokens = true; + break; + case '-h': + case '--help': + return help(); + case '-v': + case '--version': + return version(); + default: + if (arg.indexOf('--') === 0) { + opt = camelize(arg.replace(/^--(no-)?/, '')); + if (!marked.defaults.hasOwnProperty(opt)) { + continue; + } + if (arg.indexOf('--no-') === 0) { + options[opt] = typeof marked.defaults[opt] !== 'boolean' + ? null + : false; + } else { + options[opt] = typeof marked.defaults[opt] !== 'boolean' + ? argv.shift() + : true; + } + } else { + files.push(arg); + } + break; + } + } + + function getData(callback) { + if (!input) { + if (files.length <= 2) { + if (string) { + return callback(null, string); + } + return getStdin(callback); + } + input = files.pop(); + } + return fs.readFile(input, 'utf8', callback); + } + + return getData(function(err, data) { + if (err) return callback(err); + + data = tokens + ? JSON.stringify(marked.lexer(data, options), null, 2) + : marked(data, options); + + if (!output) { + process.stdout.write(data + '\n'); + return callback(); + } + + return fs.writeFile(output, data, callback); + }); +} + +/** + * Helpers + */ + +function getStdin(callback) { + var stdin = process.stdin, + buff = ''; + + stdin.setEncoding('utf8'); + + stdin.on('data', function(data) { + buff += data; + }); + + stdin.on('error', function(err) { + return callback(err); + }); + + stdin.on('end', function() { + return callback(null, buff); + }); + + try { + stdin.resume(); + } catch (e) { + callback(e); + } +} + +function camelize(text) { + return text.replace(/(\w)-(\w)/g, function(_, a, b) { + return a + b.toUpperCase(); + }); +} + +function handleError(err) { + if (err.code === 'ENOENT') { + console.error(`marked: output to ${err.path}: No such directory`); + return process.exit(1); + } + throw err; +} + +/** + * Expose / Entry Point + */ + +if (!module.parent) { + process.title = 'marked'; + main(process.argv.slice(), function(err, code) { + if (err) return handleError(err); + return process.exit(code || 0); + }); +} else { + module.exports = main; +} diff --git a/packages/markdown/marked/bower.json b/packages/markdown/marked/bower.json new file mode 100644 index 00000000..57c91f03 --- /dev/null +++ b/packages/markdown/marked/bower.json @@ -0,0 +1,23 @@ +{ + "name": "marked", + "homepage": "https://github.com/markedjs/marked", + "authors": [ + "Christopher Jeffrey " + ], + "description": "A markdown parser built for speed", + "keywords": [ + "markdown", + "markup", + "html" + ], + "main": "lib/marked.js", + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "app/bower_components", + "test", + "tests" + ] +} diff --git a/packages/markdown/marked/component.json b/packages/markdown/marked/component.json new file mode 100644 index 00000000..7ebd0356 --- /dev/null +++ b/packages/markdown/marked/component.json @@ -0,0 +1,10 @@ +{ + "name": "marked", + "version": "0.3.4", + "repo": "markedjs/marked", + "description": "A markdown parser built for speed", + "keywords": ["markdown", "markup", "html"], + "scripts": ["lib/marked.js"], + "main": "lib/marked.js", + "license": "MIT" +} diff --git a/packages/markdown/marked/docs/AUTHORS.md b/packages/markdown/marked/docs/AUTHORS.md new file mode 100644 index 00000000..dd914095 --- /dev/null +++ b/packages/markdown/marked/docs/AUTHORS.md @@ -0,0 +1,269 @@ +# Authors + +Marked takes an encompassing approach to its community. As such, you can think of these as [concentric circles](https://medium.com/the-node-js-collection/healthy-open-source-967fa8be7951), where each group encompases the following groups. + + + + + + + + + + + + + + +
+ + + +
+ Christopher Jeffrey +
Original Author
+ Started the fire +
+ + + +
+ Josh Bruce +
Publisher
+ Release Wrangler; Humaning Helper; Heckler of Hypertext +
+ + + +
+ Steven +
Publisher
+ Release Wrangler; Dr. Docs; Open source, of course; GitHub Guru; Humaning Helper +
+ + + +
+ Jamie Davis +
Committer
+ Seeker of Security +
+ + + +
+ Tony Brix +
Publisher
+ Release Wrangler; Titan of the test harness; Dr. DevOps +
+   +
+ + + + + + + + + + + + + + + + +
+ + + +
+ Brandon der Blätter +
Contributor
+ Curious Contributor +
+ + + +
+ Carlos Valle +
Contributor
+ Maker of the Marked mark from 2018 to present +
+ + + +
+ Federico Soave +
Contributor
+ Regent of the Regex; Master of Marked +
+ + + +
+ Karen Yavine +
Contributor
+ Snyk's Security Saint +
+ + + +
+ Костя Третяк +
Contributor
+ +
+ + + +
+ Tom Theisen +
Contributor
+ Defibrillator +
+ + + +
+ Mateus Craveiro +
Contributor
+ Defibrillator +
+
+ +## Publishers + +Publishers are admins who also have the responsibility, privilege, and burden of publishing the new releases to NPM and performing outreach and external stakeholder communications. Further, when things go pear-shaped, they're the ones taking most of the heat. Finally, when things go well, they're the primary ones praising the contributors who made it possible. + +(In other words, while Admins are focused primarily on the internal workings of the project, Publishers are focused on internal *and* external concerns.) + +**Should not exceed 2:** Having more people with the authority to publish a release can quickly turn into a consensus seeking nightmare (design by committee). Having only one is preferred (Directly Responsible Individual); however, given the nature of the project and its history, having an immediate fallback, and a potential deep fallback (Original author) is probably a good idea. + +[Details on badges](#badges) + +## Admins + +Admins are committers who also have the responsibility, privilege, and burden of selecting committers and making sure the project itself runs smoothly, which includes community maintenance, governance, dispute resolution, and so on. (Letting the contributors easily enter into, and work within, the project to begin contributing, with as little friction as possible.) + +**Should not exceed 3:** When there are too many people with the ability to resolve disputes, the dispute itself can quickly turn into a dispute amongst the admins themselves; therefore, we want this group to be small enough to commit to action and large enough to not put too much burden on one person. (Should ensure faster resolution and responsiveness.) + +To be listed: Admins are usually selected from the pool of committers (or they volunteer, using the same process) who demonstrate good understanding of the marked culture, operations, and do their best to help new contributors get up to speed on how to contribute effectively to the project. + +To be removed: You can remove yourself through the [GitHub UI](https://help.github.com/articles/removing-yourself-from-a-collaborator-s-repository/). + +[Details on badges](#badges) + +## Committers + +Committers are contributors who also have the responsibility, privilege, some might even say burden of being able to review and merge contributions (just usually not their own). + +A note on "decision making authority". This is related to submitting PRs and the [advice process](http://www.reinventingorganizationswiki.com/Decision_Making). The person marked as having decision making authority over a certain area should be sought for advice in that area before committing to a course of action. + +**Should not exceed 5:** For larger PRs affecting more of the codebase and, most likely, review by more people, we try to keep this pool small and responsive and let those with decision making authority have final say without negative repercussions from the other committers. + +To be listed: Committers are usually selected (or they volunteer, using the same process) from contributors who enter the discussions regarding the future direction of Marked (maybe even doing informal reviews of contributions despite not being able to merge them yourself). + +To be removed: You can remove yourself through the [GitHub UI](https://help.github.com/articles/removing-yourself-from-a-collaborator-s-repository/). + +A note on volunteering: + +1. Please do not volunteer unless you believe you can demonstrate to your peers you can do the work required. +2. Please do not overcommit yourself; we count on those committed to the project to be responsive. Really consider, with all you have going on, wehther you able to really commit to it. +3. Don't let the previous frighten you away, it can always be changed later by you or your peers. + +[Details on badges](#badges) + +## Contributors + +Contributors are users who submit a [PR](https://github.com/markedjs/marked/pulls), [Issue](https://github.com/markedjs/marked/issues), or collaborate in making Marked a better product and experience for all the users. + +To be listed: make a contribution and, if it has significant impact, the committers may be able to add you here. + +To be removed: please let us know or submit a PR. + +[Details on badges](#badges) + +## Users + +Users are anyone using Marked in some fashion, without them, there's no reason for us to exist. + +|Individual or Organization |Website |Project |Submitted by | +|:--------------------------|:-----------------------|:------------------------------------|:---------------------------------------------------| +|MarkedJS |https://marked.js.org |https://github.com/markedjs/marked |The marked committers | + +To be listed: All fields are optional. Contact any of the committers or, more timely, submit a pull request with the following (using the first row as an example): + +- **Individual or Organization:** The name you would like associated with the record. +- **Website:** A URL to a standalone website for the project. +- **Project:** A URL for the repository of the project using marked. +- **Submitted by:** The name and optional honorifics for the person adding the listing. + +To be removed: Same as above. Only instead of requesting addition request deletion or delete the row yourself. + +

Badges

+ +Badges? You don't *need* no stinkin' badges. + +Movie references aside. (It was either that or, "Let's play a game", but that would have been creepy…that's why it will most likely come later.) + +Badges? If you *want* 'em, we got 'em, and here's how you get 'em (and…dramatic pause…why not two dramatic pauses for emphasis?… how they can be taken away). + +- [ ] Add the appropriate badge to the desired contributor in the desired column of this page, even if they're not listed here yet. +- [ ] Submit a PR (we're big on PRs around here, if you haven't noticed, help us help you). +- [ ] Follow the instructions for submitting a badge PR. (There are more details to find within. Come on. Everybody likes surprises, right? No? Actually, we just try to put documentation where it belongs, closer to the code and part of the sequence of events.) + +### Badges at play: + +
+
Curious Contributor
+
A contributor with less than one year on this page who is actively engaged in submitting PRs, Issues, making recommendations, sharing thoughts…without being too annoying about it (let's be clear, submitting 100 Issues recommending the Marked Committers send everyone candy is trying for the badge, not honestly earning it).
+
Dr. DevOps
+
+

Someone who understands and contributes to improving the developer experience and flow of Marked into the world.

+
+ "The main characteristic of the DevOps movement is to strongly advocate automation and monitoring at all steps of software construction, from integration, testing, releasing to deployment and infrastructure management. DevOps aims at shorter development cycles, increased deployment frequency, more dependable releases, in close alignment with business objectives." ~ Wikipedia +
+
+
Dr. Docs
+
Someone who has contributed a great deal to the creation and maintainance of the non-code areas of marked.
+
Eye for the CLI
+
At this point? Pretty much anyone who can update that `man` file to the current Marked version without regression in the CLI tool itself.
+
GitHub Guru
+
Someone who always seems to be able to tell you easier ways to do things with GitHub.
+
Humaning Helper
+
Someone who goes out of their way to help contributors feel welcomed and valued. Further, someone who takes the extra steps(s) necessary to help new contributors get up to speed. Finally, they maintain composure even in times of disagreement and dispute resolution.
+
Heckler of Hypertext
+
Someone who demonstrates an esoteric level of knowledge when it comes to HTML. In other words, someone who says things like, "Did you know most Markdown flavors don't have a way to render a description list (`dl`)? All the more reason Markdown `!==` HTML."
+
Markdown Maestro
+
You know that person who knows about way too many different flavors of Markdown? The one who maybe seems a little too obsessed with the possibilities of Markdown beyond HTML? Come on. You know who they are. Or, at least you could, if you give them this badge.
+
Master of Marked
+
Someone who demonstrates they know the ins and outs of the codebase for Marked.
+
Open source, of course
+
Someone who advocates for and has a proven understanding of how to operate within open source communities.
+
Regent of the Regex
+

Can you demonstrate you understand the following without Google and Stackoverflow?

+

/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/

+

Because this author can't yet. That's who gets these.

+
+
Seeker of Security
+
Someone who has demonstrated a high degree of expertise or authority when it comes to software security.
+
Titan of the Test Harness
+
Someone who demonstrates high-levels of understanding regarding Marked's test harness.
+
Totally Tron
+
Someone who demonstrates they are willing and able to "fight for the users", both developers dependent on marked to do their jobs as well as end-users interacting with the output (particularly in the realm of those with the disabilities).
+
+ +### Special badges that come with the job: + +
+
Defibrillator
+
A contributor who stepped up to help bring Marked back to life by contriuting solutions to help Marked pass when compared against the CommonMark and GitHub Flavored Markdown specifications.
+
Maker of the Marked mark
+
This badge is given to the person or oganization credited with creating the logo (or logotype) used in Marked communications for a given period of time. **Maker of the Marked mark from 2017 to present**, for example.
+
Release Wrangler
+
This is a badge given to all Publishers.
+
Snyk's Security Saint
+
This is a badge given to whomever primarily reaches out from Snyk to let us know about security issues.
+
diff --git a/packages/markdown/marked/docs/CNAME b/packages/markdown/marked/docs/CNAME new file mode 100644 index 00000000..c92fdfcb --- /dev/null +++ b/packages/markdown/marked/docs/CNAME @@ -0,0 +1 @@ +marked.js.org diff --git a/packages/markdown/marked/docs/CODE_OF_CONDUCT.md b/packages/markdown/marked/docs/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..5335399b --- /dev/null +++ b/packages/markdown/marked/docs/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to block temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team by submitting a PR with changes to the [AUTHORS](#/AUTHORS.md) page (or emailing josh@8fold.com). All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version [1.4][version]. + +[homepage]: https://www.contributor-covenant.org/ +[version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html diff --git a/packages/markdown/marked/docs/CONTRIBUTING.md b/packages/markdown/marked/docs/CONTRIBUTING.md new file mode 100644 index 00000000..ac88ba15 --- /dev/null +++ b/packages/markdown/marked/docs/CONTRIBUTING.md @@ -0,0 +1,92 @@ +# Contributing to Marked + +- [ ] Fork `markedjs/marked`. +- [ ] Clone the library locally using GitHub Desktop or the command line. +- [ ] Make sure you are on the `master` branch. +- [ ] Be sure to run `npm install` or `npm update`. +- [ ] Create a branch. +- [ ] Make as small a change as possible. +- [ ] Run `npm test`, fix any broken things (for linting, you can run `npm run lint` to have the linter fix them for you). +- [ ] Submit a PR. + +## Design principles + +Marked tends to favor following the SOLID set of software design and development principles; mainly the [single responsibility](https://en.wikipedia.org/wiki/Single_responsibility_principle) and [open/closed principles](https://en.wikipedia.org/wiki/Open/closed_principle): + +- **Single responsibility:** Marked, and the components of Marked, have the single responsibility of converting Markdown strings into HTML. +- **Open/closed:** Marked favors giving developers the means to easily extend the library and its components over changing Marked's behavior through configuration options. + +## Priorities + +We think we have our priorities sorted to build quality in. + +The following table lists the ticket type labels we use when there is work to be done on the code either through an Issue or a PR; in priority order. + +|Ticket type label |Description | +|:----------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +|L0 - security |A security vulnerability within the Marked library is discovered. | +|L1 - broken |Valid usage results in incorrect output compared to [supported specifications](#/README.md#specifications) OR causes marked to crash AND there is no known workaround for the issue. | +|L2 - annoying |Similar to L1 - broken only there is a known workaround available for the issue. | +|RR - refactor and re-engineer |Results in an improvement to developers using Marked (improved readability) or end-users (faster performance) or both. | +|NFS - new feature (spec related) |A capability Marked does not currently provide but is in one of the [supported specifications](#/README.md#specifications) | +|NFU - new feature (user requested) |A capability Marked does not currently provide but has been requested by users of Marked. | + +## Test early, often, and everything + +We try to write test cases to validate output (writing tests based on the [supported specifications](#/README.md#specifications)) and minimize regression (writing tests for issues fixed). Therefore, if you would like to contribute, some things you should know regarding the test harness. + +|Location |Description | +|:-------------|:---------------------------------------------------| +|/test/browser |For testing Marked in a client-side implementation. | +|/test/new |Tests not related to the original `markdown.pl`. | +|/test/original|Tests validating against the original `markdown.pl`.| + +If your test uses features or options, assuming `gfm` is set to `false`, for example, you can add [front-matter](https://www.npmjs.com/package/front-matter) to the top of +your `.md` file + +``` yml +--- +gfm: false +--- +``` + +## Submitting PRs and Issues + +Marked provides templates for submitting both pull requests and issues. When you begin creating a new PR or issue, you will see instructions on using the template. + +The PR templates include checklists for both the submitter and the reviewer, which, in most cases, will not be the same person. + +## Scripts + +When it comes to NPM commands, we try to use the native scripts provided by the NPM framework. + +To run the tests: + +``` bash +npm test +``` + +To test whether you are using the standard syntax rules for the project: + +```bash +npm run test:lint +``` + +To see time comparisons between Marked and other popular Markdown libraries: + +```bash +npm run bench +``` + +To check for (and fix) standardized syntax (lint): + +```bash +npm run lint +``` + +To build your own minified version of Marked: + +```bash +npm run build +``` + diff --git a/packages/markdown/marked/docs/PUBLISHING.md b/packages/markdown/marked/docs/PUBLISHING.md new file mode 100644 index 00000000..27937c2f --- /dev/null +++ b/packages/markdown/marked/docs/PUBLISHING.md @@ -0,0 +1,24 @@ +# Releasing Marked + +- [ ] See [contributing](#/CONTRIBUTING.md) +- [ ] Create release branch from `master` (`release-x.y.z`) +- [ ] Submit PR with minimal name: Release x.y.z +- [ ] Complete PR checklists + +## Overall strategy + +**Master is always shippable:** We try to merge PRs in such a way that `master` is the only branch to really be concerned about *and* `master` can always be released. This allows smoother flow between new fetures, bug fixes, and so on. (Almost a continuous deployment setup, without automation.) + +## Versioning + +We follow [semantic versioning](https://semver.org) where the following sequence is true `[major].[minor].[patch]`; therefore, consider the following implications of the release you are preparing: + +1. **Major:** There is at least one change not deemed backward compatible. +2. **Minor:** There is at least one new feature added to the release. +3. **Patch:** No breaking changes, no new features. + +What to expect while Marked is a zero-major (0.x.y): + +1. The major will remain at zero; thereby, alerting consumers to the potentially volatile nature of the package. +2. The minor will tend to be more analagous to a `major` release. +3. The patch will tend to be more analagous to a `minor` release or a collection of bug fixes (patches). diff --git a/packages/markdown/marked/docs/README.md b/packages/markdown/marked/docs/README.md new file mode 100644 index 00000000..261e4f3b --- /dev/null +++ b/packages/markdown/marked/docs/README.md @@ -0,0 +1,85 @@ +Marked is + +1. built for speed.* +2. a low-level markdown compiler for parsing markdown without caching or blocking for long periods of time.** +3. light-weight while implementing all markdown features from the supported flavors & specifications.*** +4. available as a command line interface (CLI) and running in client- or server-side JavaScript projects. + +

* Still working on metrics for comparative analysis and definition.
+** As few dependencies as possible.
+*** Strict compliance could result in slower processing when running comparative benchmarking.

+ + +

Demo

+ +Checkout the [demo page](./demo/) to see marked in action ⛹️ + +These documentation pages are also rendered using marked 💯 + + +

Installation

+ +**CLI:** `npm install -g marked` + +**In-browser:** `npm install marked` + +

Usage

+ +### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/#/USING_ADVANCED.md#options) the output HTML by default 🚨 + +**CLI** + +``` bash +$ marked -o hello.html +hello world +^D +$ cat hello.html +

hello world

+``` + +``` bash +$ marked -s "*hello world*" +

hello world

+``` + +**Browser** + +```html + + + + + Marked in the browser + + +
+ + + + +``` + + +Marked offers [advanced configurations](#/USING_ADVANCED.md) and [extensibility](#/USING_PRO.md) as well. + +

Supported Markdown specifications

+ +We actively support the features of the following [Markdown flavors](https://github.com/commonmark/CommonMark/wiki/Markdown-Flavors). + +|Flavor |Version | +|:----------------------------------------------------------|:----------| +|The original markdown.pl |-- | +|[CommonMark](http://spec.commonmark.org/0.28/) |0.28 | +|[GitHub Flavored Markdown](https://github.github.com/gfm/) |0.28 | + +By supporting the above Markdown flavors, it's possible that Marked can help you use other flavors as well; however, these are not actively supported by the community. + +

Security

+ +The only completely secure system is the one that doesn't exist in the first place. Having said that, we take the security of Marked very seriously. + +Therefore, please disclose potential security issues by email to the project [committers](#/AUTHORS.md) as well as the [listed owners within NPM](https://docs.npmjs.com/cli/owner). We will provide an initial assessment of security reports within 48 hours and should apply patches within 2 weeks (also, feel free to contribute a fix for the issue). + diff --git a/packages/markdown/marked/docs/USING_ADVANCED.md b/packages/markdown/marked/docs/USING_ADVANCED.md new file mode 100644 index 00000000..6490caa7 --- /dev/null +++ b/packages/markdown/marked/docs/USING_ADVANCED.md @@ -0,0 +1,78 @@ +## The `marked` function + +```js +marked(markdownString [,options] [,callback]) +``` + +|Argument |Type |Notes | +|:---------------------|:------------|:----------------------------------------------------------------------------------------------------| +|markdownString |`string` |String of markdown source to be compiled. | +|options|`object`|Hash of options. Can also use `marked.setOptions`. | +|callback |`function` |Called when `markdownString` has been parsed. Can be used as second argument if no `options` present.| + +### Alternative using reference + +```js +// Create reference instance +var myMarked = require('marked'); + +// Set options +// `highlight` example uses `highlight.js` +myMarked.setOptions({ + renderer: new myMarked.Renderer(), + highlight: function(code) { + return require('highlight.js').highlightAuto(code).value; + }, + pedantic: false, + gfm: true, + tables: true, + breaks: false, + sanitize: false, + smartLists: true, + smartypants: false, + xhtml: false +}); + +// Compile +console.log(myMarked('I am using __markdown__.')); +``` + +

Options

+ +|Member |Type |Default |Since |Notes | +|:-----------|:---------|:--------|:--------|:-------------| +|baseUrl |`string` |`null` |0.3.9 |A prefix url for any relative link. | +|breaks |`boolean` |`false` |v0.2.7 |If true, add `
` on a single line break (copies GitHub). Requires `gfm` be `true`.| +|gfm |`boolean` |`true` |v0.2.1 |If true, use approved [GitHub Flavored Markdown (GFM) specification](https://github.github.com/gfm/).| +|headerIds |`boolean` |`true` |v0.4.0 |If true, include an `id` attribute when emitting headings (h1, h2, h3, etc).| +|headerPrefix|`string` |`''` |v0.3.0 |A string to prefix the `id` attribute when emitting headings (h1, h2, h3, etc).| +|highlight |`function`|`null` |v0.3.0 |A function to highlight code blocks, see Asynchronous highlighting.| +|langPrefix |`string` |`'language-'`|v0.3.0|A string to prefix the className in a `` block. Useful for syntax highlighting.| +|mangle |`boolean` |`true` |v0.3.4 |If true, autolinked email address is escaped with HTML character references.| +|pedantic |`boolean` |`false` |v0.2.1 |If true, conform to the original `markdown.pl` as much as possible. Don't fix original markdown bugs or behavior. Turns off and overrides `gfm`.| +|renderer |`object` |`new Renderer()`|v0.3.0|An object containing functions to render tokens to HTML. See [extensibility](USING_PRO.md) for more details.| +|sanitize |`boolean` |`false` |v0.2.1 |If true, sanitize the HTML passed into `markdownString` with the `sanitizer` function.| +|sanitizer |`function`|`null` |v0.3.4 |A function to sanitize the HTML passed into `markdownString`.| +|silent |`boolean` |`false` |v0.2.7 |If true, the parser does not throw any exception.| +|smartLists |`boolean` |`false` |v0.2.8 |If true, use smarter list behavior than those found in `markdown.pl`.| +|smartypants |`boolean` |`false` |v0.2.9 |If true, use "smart" typographic punctuation for things like quotes and dashes.| +|tables |`boolean` |`true` |v0.2.7 |If true and `gfm` is true, use [GFM Tables extension](https://github.github.com/gfm/#tables-extension-).| +|xhtml |`boolean` |`false` |v0.3.2 |If true, emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.| + +

Asynchronous highlighting

+ +Unlike `highlight.js` the `pygmentize.js` library uses asynchronous highlighting. This example demonstrates that marked is agnostic when it comes to the highlighter you use. + +```js +myMarked.setOptions({ + highlight: function(code, lang, callback) { + require('pygmentize-bundled') ({ lang: lang, format: 'html' }, code, function (err, result) { + callback(err, result.toString()); + }); + } +}); + +console.log(myMarked(markdownString)); +``` + +In both examples, `code` is a `string` representing the section of code to pass to the highlighter. In this example, `lang` is a `string` informing the highlighter what programming lnaguage to use for the `code` and `callback` is the `function` the asynchronous highlighter will call once complete. diff --git a/packages/markdown/marked/docs/USING_PRO.md b/packages/markdown/marked/docs/USING_PRO.md new file mode 100644 index 00000000..861caa2d --- /dev/null +++ b/packages/markdown/marked/docs/USING_PRO.md @@ -0,0 +1,163 @@ +## Extending Marked + +To champion the single-responsibility and open/closed prinicples, we have tried to make it relatively painless to extend marked. If you are looking to add custom functionality, this is the place to start. + +

The renderer

+ +The renderer is... + +**Example:** Overriding default heading token by adding an embedded anchor tag like on GitHub. + +```js +// Create reference instance +var myMarked = require('marked'); + +// Get reference +var renderer = new myMarked.Renderer(); + +// Override function +renderer.heading = function (text, level) { + var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-'); + + return ` + + + + + ${text} + `; +}; + +// Run marked +console.log(myMarked('# heading+', { renderer: renderer })); +``` + +**Output:** + +```html +

+ + + + heading+ +

+``` + +### Block level renderer methods + +- code(*string* code, *string* infostring, *boolean* escaped) +- blockquote(*string* quote) +- html(*string* html) +- heading(*string* text, *number* level, *string* raw, *Slugger* slugger) +- hr() +- list(*string* body, *boolean* ordered, *number* start) +- listitem(*string* text, *boolean* task, *boolean* checked) +- checkbox(*boolean* checked) +- paragraph(*string* text) +- table(*string* header, *string* body) +- tablerow(*string* content) +- tablecell(*string* content, *object* flags) + +`slugger` has the `slug` method to create an unique id from value: + +```js +slugger.slug('foo') // foo +slugger.slug('foo') // foo-1 +slugger.slug('foo') // foo-2 +slugger.slug('foo 1') // foo-1-1 +slugger.slug('foo-1') // foo-1-2 +... +``` + +`flags` has the following properties: + +```js +{ + header: true || false, + align: 'center' || 'left' || 'right' +} +``` + +### Inline level renderer methods + +- strong(*string* text) +- em(*string* text) +- codespan(*string* code) +- br() +- del(*string* text) +- link(*string* href, *string* title, *string* text) +- image(*string* href, *string* title, *string* text) +- text(*string* text) + +

The lexer

+ +The lexer is... + + +

The parser

+ +The parser is... + +*** + +

Access to lexer and parser

+ +You also have direct access to the lexer and parser if you so desire. + +``` js +var tokens = marked.lexer(text, options); +console.log(marked.parser(tokens)); +``` + +``` js +var lexer = new marked.Lexer(options); +var tokens = lexer.lex(text); +console.log(tokens); +console.log(lexer.rules); +``` + +``` bash +$ node +> require('marked').lexer('> i am using marked.') +[ { type: 'blockquote_start' }, + { type: 'paragraph', + text: 'i am using marked.' }, + { type: 'blockquote_end' }, + links: {} ] +``` + +The Lexers build an array of tokens, which will be passed to their respective +Parsers. The Parsers process each token in the token arrays, +which are removed from the array of tokens: + +``` js +const marked = require('marked'); + +const md = ` + # heading + + [link][1] + + [1]: #heading "heading" +`; + +const tokens = marked.lexer(md); +console.log(tokens); + +const html = marked.parser(tokens); +console.log(html); + +console.log(tokens); +``` + +``` bash +[ { type: 'heading', depth: 1, text: 'heading' }, + { type: 'paragraph', text: ' [link][1]' }, + { type: 'space' }, + links: { '1': { href: '#heading', title: 'heading' } } ] + +

heading

+

link

+ +[ links: { '1': { href: '#heading', title: 'heading' } } ] +``` diff --git a/packages/markdown/marked/docs/broken.md b/packages/markdown/marked/docs/broken.md new file mode 100644 index 00000000..7bfa49e8 --- /dev/null +++ b/packages/markdown/marked/docs/broken.md @@ -0,0 +1,426 @@ +# Markdown is broken + +I have a lot of scraps of markdown engine oddities that I've collected over the +years. What you see below is slightly messy, but it's what I've managed to +cobble together to illustrate the differences between markdown engines, and +why, if there ever is a markdown specification, it has to be absolutely +thorough. There are a lot more of these little differences I have documented +elsewhere. I know I will find them lingering on my disk one day, but until +then, I'll continue to add whatever strange nonsensical things I find. + +Some of these examples may only mention a particular engine compared to marked. +However, the examples with markdown.pl could easily be swapped out for +discount, upskirt, or markdown.js, and you would very easily see even more +inconsistencies. + +A lot of this was written when I was very unsatisfied with the inconsistencies +between markdown engines. Please excuse the frustration noticeable in my +writing. + +## Examples of markdown's "stupid" list parsing + +``` +$ markdown.pl + + * item1 + + * item2 + + text +^D +
    +
  • item1

    + +
      +
    • item2
    • +
    + +

    text

  • +

+``` + + +``` +$ marked + * item1 + + * item2 + + text +^D +
    +
  • item1

    +
      +
    • item2
    • +
    +

    text

    +
  • +
+``` + +Which looks correct to you? + +- - - + +``` +$ markdown.pl +* hello + > world +^D +

    +
  • hello

    + +
    +

    world

  • +

+ +``` + +``` +$ marked +* hello + > world +^D +
    +
  • hello
    +

    world

    +
    +
  • +
+``` + +Again, which looks correct to you? + +- - - + +EXAMPLE: + +``` +$ markdown.pl +* hello + * world + * hi + code +^D +
    +
  • hello +
      +
    • world
    • +
    • hi + code
    • +
  • +
+``` + +The code isn't a code block even though it's after the bullet margin. I know, +lets give it two more spaces, effectively making it 8 spaces past the bullet. + +``` +$ markdown.pl +* hello + * world + * hi + code +^D +
    +
  • hello +
      +
    • world
    • +
    • hi + code
    • +
  • +
+``` + +And, it's still not a code block. Did you also notice that the 3rd item isn't +even its own list? Markdown screws that up too because of its indentation +unaware parsing. + +- - - + +Let's look at some more examples of markdown's list parsing: + +``` +$ markdown.pl + + * item1 + + * item2 + + text +^D +
    +
  • item1

    + +
      +
    • item2
    • +
    + +

    text

  • +

+``` + +Misnested tags. + + +``` +$ marked + * item1 + + * item2 + + text +^D +
    +
  • item1

    +
      +
    • item2
    • +
    +

    text

    +
  • +
+``` + +Which looks correct to you? + +- - - + +``` +$ markdown.pl +* hello + > world +^D +

    +
  • hello

    + +
    +

    world

  • +

+ +``` + +More misnested tags. + + +``` +$ marked +* hello + > world +^D +
    +
  • hello
    +

    world

    +
    +
  • +
+``` + +Again, which looks correct to you? + +- - - + +# Why quality matters - Part 2 + +``` bash +$ markdown.pl +* hello + > world +^D +

    +
  • hello

    + +
    +

    world

  • +

+ +``` + +``` bash +$ sundown # upskirt +* hello + > world +^D +
    +
  • hello +> world
  • +
+``` + +``` bash +$ marked +* hello + > world +^D +
  • hello

    world

+``` + +Which looks correct to you? + +- - - + +See: https://github.com/evilstreak/markdown-js/issues/23 + +``` bash +$ markdown.pl # upskirt/markdown.js/discount +* hello + var a = 1; +* world +^D +
    +
  • hello +var a = 1;
  • +
  • world
  • +
+``` + +``` bash +$ marked +* hello + var a = 1; +* world +^D +
+``` + +Which looks more reasonable? Why shouldn't code blocks be able to appear in +list items in a sane way? + +- - - + +``` bash +$ markdown.js +
hello
+ +hello +^D +

<div>hello</div>

+ +

<span>hello</span>

+``` + +``` bash +$ marked +
hello
+ +hello +^D +
hello
+ + +

hello +

+``` + +- - - + +See: https://github.com/evilstreak/markdown-js/issues/27 + +``` bash +$ markdown.js +[![an image](/image)](/link) +^D +

![an image

+``` + +``` bash +$ marked +[![an image](/image)](/link) +^D +

an image +

+``` + +- - - + +See: https://github.com/evilstreak/markdown-js/issues/24 + +``` bash +$ markdown.js +> a + +> b + +> c +^D +

a

bundefined> c

+``` + +``` bash +$ marked +> a + +> b + +> c +^D +

a + +

+

b + +

+

c +

+``` + +- - - + +``` bash +$ markdown.pl +* hello + * world + how + + are + you + + * today +* hi +^D + +``` + +``` bash +$ marked +* hello + * world + how + + are + you + + * today +* hi +^D + +``` diff --git a/packages/markdown/marked/docs/demo/demo.css b/packages/markdown/marked/docs/demo/demo.css new file mode 100644 index 00000000..398c663a --- /dev/null +++ b/packages/markdown/marked/docs/demo/demo.css @@ -0,0 +1,72 @@ +html, body { + margin: 0; + padding: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #333; + background-color: #fbfbfb; + height: 100%; +} + +textarea { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + font-size: 12px; + resize: none; +} + +header { + padding-top: 10px; + display: flex; + height: 58px; +} + +header h1 { + margin: 0; +} + +.github-ribbon { + position: absolute; + top: 0; + right: 0; + border: 0; + z-index: 1000; +} + +.containers { + display: flex; + height: calc(100vh - 68px); +} + +.container { + flex-basis: 50%; + padding: 5px; + display: flex; + flex-direction: column; + height: 100%; + box-sizing: border-box; +} + +.pane, .inputPane { + margin-top: 5px; + padding: 0.6em; + border: 1px solid #ccc; + overflow: auto; + flex-grow: 1; + flex-shrink: 1; +} + +#preview { + display: flex; +} + +#preview iframe { + flex-grow: 1; +} + +#main { + display: none; +} + +.error { + border-color: red; + background-color: #FEE +} diff --git a/packages/markdown/marked/docs/demo/demo.js b/packages/markdown/marked/docs/demo/demo.js new file mode 100644 index 00000000..e7d97c59 --- /dev/null +++ b/packages/markdown/marked/docs/demo/demo.js @@ -0,0 +1,534 @@ +/* globals marked, unfetch, ES6Promise */ + +if (!window.Promise) { + window.Promise = ES6Promise; +} +if (!window.fetch) { + window.fetch = unfetch; +} + +onunhandledrejection = function (e) { + throw e.reason; +}; + +var $loadingElem = document.querySelector('#loading'); +var $mainElem = document.querySelector('#main'); +var $markdownElem = document.querySelector('#markdown'); +var $markedVerElem = document.querySelector('#markedVersion'); +var $commitVerElem = document.querySelector('#commitVersion'); +var $markedVer = document.querySelector('#markedCdn'); +var $optionsElem = document.querySelector('#options'); +var $outputTypeElem = document.querySelector('#outputType'); +var $inputTypeElem = document.querySelector('#inputType'); +var $responseTimeElem = document.querySelector('#responseTime'); +var $previewElem = document.querySelector('#preview'); +var $previewIframe = document.querySelector('#preview iframe'); +var $permalinkElem = document.querySelector('#permalink'); +var $clearElem = document.querySelector('#clear'); +var $htmlElem = document.querySelector('#html'); +var $lexerElem = document.querySelector('#lexer'); +var $panes = document.querySelectorAll('.pane'); +var $inputPanes = document.querySelectorAll('.inputPane'); +var lastInput = ''; +var inputDirty = true; +var $activeOutputElem = null; +var search = searchToObject(); +var markedVersions = { + master: 'https://cdn.jsdelivr.net/gh/markedjs/marked/lib/marked.js' +}; +var markedVersionCache = {}; +var delayTime = 1; +var checkChangeTimeout = null; +var markedWorker; + +$previewIframe.addEventListener('load', handleIframeLoad); + +$outputTypeElem.addEventListener('change', handleOutputChange, false); + +$inputTypeElem.addEventListener('change', handleInputChange, false); + +$markedVerElem.addEventListener('change', handleVersionChange, false); + +$markdownElem.addEventListener('change', handleInput, false); +$markdownElem.addEventListener('keyup', handleInput, false); +$markdownElem.addEventListener('keypress', handleInput, false); +$markdownElem.addEventListener('keydown', handleInput, false); + +$optionsElem.addEventListener('change', handleInput, false); +$optionsElem.addEventListener('keyup', handleInput, false); +$optionsElem.addEventListener('keypress', handleInput, false); +$optionsElem.addEventListener('keydown', handleInput, false); + +$commitVerElem.style.display = 'none'; +$commitVerElem.addEventListener('keypress', handleAddVersion, false); + +$clearElem.addEventListener('click', handleClearClick, false); + +Promise.all([ + setInitialQuickref(), + setInitialOutputType(), + setInitialText(), + setInitialVersion() + .then(setInitialOptions) +]).then(function () { + handleInputChange(); + handleOutputChange(); + checkForChanges(); + setScrollPercent(0); + $loadingElem.style.display = 'none'; + $mainElem.style.display = 'block'; +}); + +function setInitialText() { + if ('text' in search) { + $markdownElem.value = search.text; + } else { + return fetch('./initial.md') + .then(function (res) { return res.text(); }) + .then(function (text) { + if ($markdownElem.value === '') { + $markdownElem.value = text; + } + }); + } +} + +function setInitialQuickref() { + return fetch('./quickref.md') + .then(function (res) { return res.text(); }) + .then(function (text) { + document.querySelector('#quickref').value = text; + }); +} + +function setInitialVersion() { + return fetch('https://data.jsdelivr.com/v1/package/npm/marked') + .then(function (res) { + return res.json(); + }) + .then(function (json) { + for (var i = 0; i < json.versions.length; i++) { + var ver = json.versions[i]; + markedVersions[ver] = 'https://cdn.jsdelivr.net/npm/marked@' + ver + '/lib/marked.js'; + var opt = document.createElement('option'); + opt.textContent = ver; + opt.value = ver; + $markedVerElem.appendChild(opt); + } + }) + .then(function () { + return fetch('https://api.github.com/repos/markedjs/marked/commits') + .then(function (res) { + return res.json(); + }) + .then(function (json) { + markedVersions['master'] = 'https://cdn.jsdelivr.net/gh/markedjs/marked@' + json[0].sha + '/lib/marked.js'; + }) + .catch(function () { + // do nothing + // uses url without commit + }); + }) + .then(function () { + if (search.version) { + if (markedVersions[search.version]) { + return search.version; + } else { + var match = search.version.match(/^(\w+):(.+)$/); + if (match) { + switch (match[1]) { + case 'commit': + addCommitVersion(search.version, match[2].substring(0, 7), match[2]); + return search.version; + case 'pr': + return getPrCommit(match[2]) + .then(function (commit) { + if (!commit) { + return 'master'; + } + addCommitVersion(search.version, 'PR #' + match[2], commit); + return search.version; + }); + } + } + } + } + + return 'master'; + }) + .then(function (version) { + $markedVerElem.value = version; + }) + .then(updateVersion); +} + +function setInitialOptions() { + if ('options' in search) { + $optionsElem.value = search.options; + } else { + setDefaultOptions(); + } +} + +function setInitialOutputType() { + if (search.outputType) { + $outputTypeElem.value = search.outputType; + } +} + +function handleIframeLoad() { + lastInput = ''; + inputDirty = true; +} + +function handleInput() { + inputDirty = true; +}; + +function handleVersionChange() { + if ($markedVerElem.value === 'commit' || $markedVerElem.value === 'pr') { + $commitVerElem.style.display = ''; + } else { + $commitVerElem.style.display = 'none'; + updateVersion(); + } +} + +function handleClearClick() { + $markdownElem.value = ''; + $markedVerElem.value = 'master'; + $commitVerElem.style.display = 'none'; + updateVersion().then(setDefaultOptions); +} + +function handleAddVersion(e) { + if (e.which === 13) { + switch ($markedVerElem.value) { + case 'commit': + var commit = $commitVerElem.value.toLowerCase(); + if (!commit.match(/^[0-9a-f]{40}$/)) { + alert('That is not a valid commit'); + return; + } + addCommitVersion('commit:' + commit, commit.substring(0, 7), commit); + $markedVerElem.value = 'commit:' + commit; + $commitVerElem.style.display = 'none'; + $commitVerElem.value = ''; + updateVersion(); + break; + case 'pr': + $commitVerElem.disabled = true; + var pr = $commitVerElem.value.replace(/\D/g, ''); + getPrCommit(pr) + .then(function (commit) { + $commitVerElem.disabled = false; + if (!commit) { + alert('That is not a valid PR'); + return; + } + addCommitVersion('pr:' + pr, 'PR #' + pr, commit); + $markedVerElem.value = 'pr:' + pr; + $commitVerElem.style.display = 'none'; + $commitVerElem.value = ''; + updateVersion(); + }); + } + } +} + +function handleInputChange() { + handleChange($inputPanes, $inputTypeElem.value); +} + +function handleOutputChange() { + $activeOutputElem = handleChange($panes, $outputTypeElem.value); + updateLink(); +} + +function handleChange(panes, visiblePane) { + var active = null; + for (var i = 0; i < panes.length; i++) { + if (panes[i].id === visiblePane) { + panes[i].style.display = ''; + active = panes[i]; + } else { + panes[i].style.display = 'none'; + } + } + return active; +}; + +function addCommitVersion(value, text, commit) { + if (markedVersions[value]) { + return; + } + markedVersions[value] = 'https://cdn.jsdelivr.net/gh/markedjs/marked@' + commit + '/lib/marked.js'; + var opt = document.createElement('option'); + opt.textContent = text; + opt.value = value; + $markedVerElem.insertBefore(opt, $markedVerElem.firstChild); +} + +function getPrCommit(pr) { + return fetch('https://api.github.com/repos/markedjs/marked/pulls/' + pr + '/commits') + .then(function (res) { + return res.json(); + }) + .then(function (json) { + return json[json.length - 1].sha; + }).catch(function () { + // return undefined + }); +} + +function setDefaultOptions() { + if (window.Worker) { + messageWorker({ + task: 'defaults', + version: markedVersions[$markedVerElem.value] + }); + } else { + var defaults = marked.getDefaults(); + setOptions(defaults); + } +} + +function setOptions(opts) { + $optionsElem.value = JSON.stringify( + opts, + function (key, value) { + if (value && typeof value === 'object' && Object.getPrototypeOf(value) !== Object.prototype) { + return undefined; + } + return value; + }, ' '); +} + +function searchToObject() { + // modified from https://stackoverflow.com/a/7090123/806777 + var pairs = location.search.slice(1).split('&'); + var obj = {}; + + for (var i = 0; i < pairs.length; i++) { + if (pairs[i] === '') { + continue; + } + + var pair = pairs[i].split('='); + + obj[decodeURIComponent(pair.shift())] = decodeURIComponent(pair.join('=')); + } + + return obj; +} + +function jsonString(input) { + var output = (input + '') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\t/g, '\\t') + .replace(/\f/g, '\\f') + .replace(/[\\"']/g, '\\$&') + .replace(/\u0000/g, '\\0'); + return '"' + output + '"'; +}; + +function getScrollSize() { + var e = $activeOutputElem; + + return e.scrollHeight - e.clientHeight; +}; + +function getScrollPercent() { + var size = getScrollSize(); + + if (size <= 0) { + return 1; + } + + return $activeOutputElem.scrollTop / size; +}; + +function setScrollPercent(percent) { + $activeOutputElem.scrollTop = percent * getScrollSize(); +}; + +function updateLink() { + var outputType = ''; + if ($outputTypeElem.value !== 'preview') { + outputType = 'outputType=' + $outputTypeElem.value + '&'; + } + + $permalinkElem.href = '?' + outputType + 'text=' + encodeURIComponent($markdownElem.value) + + '&options=' + encodeURIComponent($optionsElem.value) + + '&version=' + encodeURIComponent($markedVerElem.value); + history.replaceState('', document.title, $permalinkElem.href); +} + +function updateVersion() { + if (window.Worker) { + handleInput(); + return Promise.resolve(); + } + var promise; + if (markedVersionCache[$markedVerElem.value]) { + promise = Promise.resolve(markedVersionCache[$markedVerElem.value]); + } else { + promise = fetch(markedVersions[$markedVerElem.value]) + .then(function (res) { return res.text(); }) + .then(function (text) { + markedVersionCache[$markedVerElem.value] = text; + return text; + }); + } + return promise.then(function (text) { + var script = document.createElement('script'); + script.textContent = text; + + $markedVer.parentNode.replaceChild(script, $markedVer); + $markedVer = script; + }).then(handleInput); +} + +function checkForChanges() { + if (inputDirty && $markedVerElem.value !== 'commit' && $markedVerElem.value !== 'pr' && (typeof marked !== 'undefined' || window.Worker)) { + inputDirty = false; + + updateLink(); + + var options = {}; + var optionsString = $optionsElem.value || '{}'; + try { + var newOptions = JSON.parse(optionsString); + options = newOptions; + $optionsElem.classList.remove('error'); + } catch (err) { + $optionsElem.classList.add('error'); + } + + var version = markedVersions[$markedVerElem.value]; + var markdown = $markdownElem.value; + var hash = version + markdown + optionsString; + if (lastInput !== hash) { + lastInput = hash; + if (window.Worker) { + delayTime = 100; + messageWorker({ + task: 'parse', + version: version, + markdown: markdown, + options: options + }); + } else { + var startTime = new Date(); + var lexed = marked.lexer(markdown, options); + var lexedList = []; + for (var i = 0; i < lexed.length; i++) { + var lexedLine = []; + for (var j in lexed[i]) { + lexedLine.push(j + ':' + jsonString(lexed[i][j])); + } + lexedList.push('{' + lexedLine.join(', ') + '}'); + } + var parsed = marked.parser(lexed, options); + var scrollPercent = getScrollPercent(); + setParsed(parsed, lexedList.join('\n')); + setScrollPercent(scrollPercent); + var endTime = new Date(); + delayTime = endTime - startTime; + setResponseTime(delayTime); + if (delayTime < 50) { + delayTime = 50; + } else if (delayTime > 500) { + delayTime = 1000; + } + } + } + } + checkChangeTimeout = window.setTimeout(checkForChanges, delayTime); +}; + +function setResponseTime(ms) { + var amount = ms; + var suffix = 'ms'; + if (ms > 1000 * 60 * 60) { + amount = 'Too Long'; + suffix = ''; + } else if (ms > 1000 * 60) { + amount = '>' + Math.floor(ms / (1000 * 60)); + suffix = 'm'; + } else if (ms > 1000) { + amount = '>' + Math.floor(ms / 1000); + suffix = 's'; + } + $responseTimeElem.textContent = amount + suffix; +} + +function setParsed(parsed, lexed) { + try { + $previewIframe.contentDocument.body.innerHTML = parsed; + } catch (ex) {} + $htmlElem.value = parsed; + $lexerElem.value = lexed; +} + +function messageWorker(message) { + if (!markedWorker || markedWorker.working) { + if (markedWorker) { + clearTimeout(markedWorker.timeout); + markedWorker.terminate(); + } + markedWorker = new Worker('worker.js'); + markedWorker.onmessage = function (e) { + clearTimeout(markedWorker.timeout); + markedWorker.working = false; + switch (e.data.task) { + case 'defaults': + setOptions(e.data.defaults); + break; + case 'parse': + $previewElem.classList.remove('error'); + $htmlElem.classList.remove('error'); + $lexerElem.classList.remove('error'); + var scrollPercent = getScrollPercent(); + setParsed(e.data.parsed, e.data.lexed); + setScrollPercent(scrollPercent); + setResponseTime(e.data.time); + break; + } + clearTimeout(checkChangeTimeout); + delayTime = 10; + checkForChanges(); + }; + markedWorker.onerror = markedWorker.onmessageerror = function (err) { + clearTimeout(markedWorker.timeout); + var error = 'There was an error in the Worker'; + if (err) { + if (err.message) { + error = err.message; + } else { + error = err; + } + } + error = error.replace(/^Uncaught Error: /, ''); + $previewElem.classList.add('error'); + $htmlElem.classList.add('error'); + $lexerElem.classList.add('error'); + setParsed(error, error); + setScrollPercent(0); + }; + } + if (message.task !== 'defaults') { + markedWorker.working = true; + workerTimeout(0); + } + markedWorker.postMessage(message); +} + +function workerTimeout(seconds) { + markedWorker.timeout = setTimeout(function () { + seconds++; + markedWorker.onerror('Marked has taken longer than ' + seconds + ' second' + (seconds > 1 ? 's' : '') + ' to respond...'); + workerTimeout(seconds); + }, 1000); +} diff --git a/packages/markdown/marked/docs/demo/index.html b/packages/markdown/marked/docs/demo/index.html new file mode 100644 index 00000000..96a8ec14 --- /dev/null +++ b/packages/markdown/marked/docs/demo/index.html @@ -0,0 +1,78 @@ + + + + + Marked Demo + + + + + + Fork me on GitHub + + +
+ + + +

Marked Demo

+
+ +
Loading...
+
+
+
+
+ Input · + · + Version: + + · + + +
+ + +
+ +
+
+ · + Response Time: + +
+ +
+ + +
+ + + + + + +
+
+
+ + + + + + + diff --git a/packages/markdown/marked/docs/demo/initial.md b/packages/markdown/marked/docs/demo/initial.md new file mode 100644 index 00000000..d2b7d77c --- /dev/null +++ b/packages/markdown/marked/docs/demo/initial.md @@ -0,0 +1,36 @@ +Marked - Markdown Parser +======================== + +[Marked] lets you convert [Markdown] into HTML. Markdown is a simple text format whose goal is to be very easy to read and write, even when not converted to HTML. This demo page will let you type anything you like and see how it gets converted. Live. No more waiting around. + +How To Use The Demo +------------------- + +1. Type in stuff on the left. +2. See the live updates on the right. + +That's it. Pretty simple. There's also a drop-down option in the upper right to switch between various views: + +- **Preview:** A live display of the generated HTML as it would render in a browser. +- **HTML Source:** The generated HTML before your browser makes it pretty. +- **Lexer Data:** What [marked] uses internally, in case you like gory stuff like this. +- **Quick Reference:** A brief run-down of how to format things using markdown. + +Why Markdown? +------------- + +It's easy. It's not overly bloated, unlike HTML. Also, as the creator of [markdown] says, + +> The overriding design goal for Markdown's +> formatting syntax is to make it as readable +> as possible. The idea is that a +> Markdown-formatted document should be +> publishable as-is, as plain text, without +> looking like it's been marked up with tags +> or formatting instructions. + +Ready to start writing? Either start changing stuff on the left or +[clear everything](/demo/?text=) with a simple click. + +[Marked]: https://github.com/markedjs/marked/ +[Markdown]: http://daringfireball.net/projects/markdown/ diff --git a/packages/markdown/marked/docs/demo/preview.html b/packages/markdown/marked/docs/demo/preview.html new file mode 100644 index 00000000..7e8c89fe --- /dev/null +++ b/packages/markdown/marked/docs/demo/preview.html @@ -0,0 +1,12 @@ + + + + + + marked.js preview + + + + + + diff --git a/packages/markdown/marked/docs/demo/quickref.md b/packages/markdown/marked/docs/demo/quickref.md new file mode 100644 index 00000000..10f09bda --- /dev/null +++ b/packages/markdown/marked/docs/demo/quickref.md @@ -0,0 +1,167 @@ +Markdown Quick Reference +======================== + +This guide is a very brief overview, with examples, of the syntax that [Markdown] supports. It is itself written in Markdown and you can copy the samples over to the left-hand pane for experimentation. It's shown as *text* and not *rendered HTML*. + +[Markdown]: http://daringfireball.net/projects/markdown/ + + +Simple Text Formatting +====================== + +First thing is first. You can use *stars* or _underscores_ for italics. **Double stars** and __double underscores__ do bold. ***Three together*** do ___both___. + +Paragraphs are pretty easy too. Just have a blank line between chunks of text. + +> This chunk of text is in a block quote. Its multiple lines will all be +> indended a bit from the rest of the text. +> +> > Multiple levels of block quotes also work. + +Sometimes you want to include some code, such as when you are explaining how `

` HTML tags work, or maybe you are a programmer and you are discussing `someMethod()`. + +If you want to include some code and have +newlines preserved, indent the line with a tab +or at least four spaces. + Extra spaces work here too. +This is also called preformatted text and it is useful for showing examples. +The text will stay as text, so any *markdown* or HTML you add will +not show up formatted. This way you can show markdown examples in a +markdown document. + +> You can also use preformatted text with your blockquotes +> as long as you add at least five spaces. + + +Headings +======== + +There are a couple of ways to make headings. Using three or more equals signs on a line under a heading makes it into an "h1" style. Three or more hyphens under a line makes it "h2" (slightly smaller). You can also use multiple pound symbols before and after a heading. Pounds after the title are ignored. Here's some examples: + +This is H1 +========== + +This is H2 +---------- + +# This is H1 +## This is H2 +### This is H3 with some extra pounds ### +#### You get the idea #### +##### I don't need extra pounds at the end +###### H6 is the max + + +Links +===== + +Let's link to a few sites. First, let's use the bare URL, like . Great for text, but ugly for HTML. +Next is an inline link to [Google](http://www.google.com). A little nicer. +This is a reference-style link to [Wikipedia] [1]. +Lastly, here's a pretty link to [Yahoo]. The reference-style and pretty links both automatically use the links defined below, but they could be defined *anywhere* in the markdown and are removed from the HTML. The names are also case insensitive, so you can use [YaHoO] and have it link properly. + +[1]: http://www.wikipedia.org/ +[Yahoo]: http://www.yahoo.com/ + +Title attributes may be added to links by adding text after a link. +This is the [inline link](http://www.bing.com "Bing") with a "Bing" title. +You can also go to [W3C] [2] and maybe visit a [friend]. + +[2]: http://w3c.org (The W3C puts out specs for web-based things) +[Friend]: http://facebook.com/ "Facebook!" + +Email addresses in plain text are not linked: test@example.com. +Email addresses wrapped in angle brackets are linked: . +They are also obfuscated so that email harvesting spam robots hopefully won't get them. + + +Lists +===== + +* This is a bulleted list +* Great for shopping lists +- You can also use hyphens ++ Or plus symbols + +The above is an "unordered" list. Now, on for a bit of order. + +1. Numbered lists are also easy +2. Just start with a number +3738762. However, the actual number doesn't matter when converted to HTML. +1. This will still show up as 4. + +You might want a few advanced lists: + +- This top-level list is wrapped in paragraph tags +- This generates an extra space between each top-level item. + +- You do it by adding a blank line + +- This nested list also has blank lines between the list items. + +- How to create nested lists +1. Start your regular list +2. Indent nested lists with four spaces +3. Further nesting means you should indent with four more spaces + * This line is indented with eight spaces. + +- List items can be quite lengthy. You can keep typing and either continue +them on the next line with no indentation. + +- Alternately, if that looks ugly, you can also +indent the next line a bit for a prettier look. + +- You can put large blocks of text in your list by just indenting with four spaces. + +This is formatted the same as code, but you can inspect the HTML +and find that it's just wrapped in a `

` tag and *won't* be shown +as preformatted text. + +You can keep adding more and more paragraphs to a single +list item by adding the traditional blank line and then keep +on indenting the paragraphs with four spaces. You really need +to only indent the first line, but that looks ugly. + +- Lists support blockquotes + +> Just like this example here. By the way, you can +> nest lists inside blockquotes! +> - Fantastic! + +- Lists support preformatted text + + You just need to indent eight spaces. + + +Even More +========= + +Horizontal Rule +--------------- + +If you need a horizontal rule you just need to put at least three hyphens, asterisks, or underscores on a line by themselves. You can also even put spaces between the characters. + +--- +**************************** +_ _ _ _ _ _ _ + +Those three all produced horizontal lines. Keep in mind that three hyphens under any text turns that text into a heading, so add a blank like if you use hyphens. + +Images +------ + +Images work exactly like links, but they have exclamation points in front. They work with references and titles too. + +![Google Logo](http://www.google.com/images/errors/logo_sm.gif) and ![Happy]. + +[Happy]: http://www.wpclipart.com/smiley/simple_smiley/smiley_face_simple_green_small.png ("Smiley face") + + +Inline HTML +----------- + +If markdown is too limiting, you can just insert your own crazy HTML. Span-level HTML can *still* use markdown. Block level elements must be separated from text by a blank line and must not have any spaces before the opening and closing HTML. + +

+It is a pity, but markdown does **not** work in here for most markdown parsers. [Marked] handles it pretty well. +
diff --git a/packages/markdown/marked/docs/demo/worker.js b/packages/markdown/marked/docs/demo/worker.js new file mode 100644 index 00000000..06b8befe --- /dev/null +++ b/packages/markdown/marked/docs/demo/worker.js @@ -0,0 +1,105 @@ +/* globals marked, unfetch, ES6Promise */ +if (!self.Promise) { + self.importScripts('https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.js'); + self.Promise = ES6Promise; +} +if (!self.fetch) { + self.importScripts('https://cdn.jsdelivr.net/npm/unfetch/dist/unfetch.umd.js'); + self.fetch = unfetch; +} + +var versionCache = {}; +var currentVersion; + +onunhandledrejection = function (e) { + throw e.reason; +}; + +onmessage = function (e) { + if (e.data.version === currentVersion) { + parse(e); + } else { + loadVersion(e.data.version).then(function () { + parse(e); + }); + } +}; + +function parse(e) { + switch (e.data.task) { + case 'defaults': + + var defaults = {}; + if (typeof marked.getDefaults === 'function') { + defaults = marked.getDefaults(); + delete defaults.renderer; + } else if ('defaults' in marked) { + for (var prop in marked.defaults) { + if (prop !== 'renderer') { + defaults[prop] = marked.defaults[prop]; + } + } + } + postMessage({ + task: e.data.task, + defaults: defaults + }); + break; + case 'parse': + var startTime = new Date(); + var lexed = marked.lexer(e.data.markdown, e.data.options); + var lexedList = []; + for (var i = 0; i < lexed.length; i++) { + var lexedLine = []; + for (var j in lexed[i]) { + lexedLine.push(j + ':' + jsonString(lexed[i][j])); + } + lexedList.push('{' + lexedLine.join(', ') + '}'); + } + var parsed = marked.parser(lexed, e.data.options); + var endTime = new Date(); + // setTimeout(function () { + postMessage({ + task: e.data.task, + lexed: lexedList.join('\n'), + parsed: parsed, + time: endTime - startTime + }); + // }, 10000); + break; + } +} + +function jsonString(input) { + var output = (input + '') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\t/g, '\\t') + .replace(/\f/g, '\\f') + .replace(/[\\"']/g, '\\$&') + .replace(/\u0000/g, '\\0'); + return '"' + output + '"'; +}; + +function loadVersion(ver) { + var promise; + if (versionCache[ver]) { + promise = Promise.resolve(versionCache[ver]); + } else { + promise = fetch(ver) + .then(function (res) { return res.text(); }) + .then(function (text) { + versionCache[ver] = text; + return text; + }); + } + return promise.then(function (text) { + try { + // eslint-disable-next-line no-new-func + Function(text)(); + } catch (err) { + throw new Error('Cannot load that version of marked'); + } + currentVersion = ver; + }); +} diff --git a/packages/markdown/marked/docs/img/logo-black-and-white.svg b/packages/markdown/marked/docs/img/logo-black-and-white.svg new file mode 100644 index 00000000..5f6c0b78 --- /dev/null +++ b/packages/markdown/marked/docs/img/logo-black-and-white.svg @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/markdown/marked/docs/img/logo-black.svg b/packages/markdown/marked/docs/img/logo-black.svg new file mode 100644 index 00000000..a67fb80e --- /dev/null +++ b/packages/markdown/marked/docs/img/logo-black.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/markdown/marked/docs/index.html b/packages/markdown/marked/docs/index.html new file mode 100644 index 00000000..07a4d5ee --- /dev/null +++ b/packages/markdown/marked/docs/index.html @@ -0,0 +1,269 @@ + + + + + Marked.js Documentation + + + + + + +
+
+ + + +

Marked.js Documentation

+
+ +
+ + + + + + diff --git a/packages/markdown/marked/index.js b/packages/markdown/marked/index.js new file mode 100644 index 00000000..a12f9056 --- /dev/null +++ b/packages/markdown/marked/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/marked'); diff --git a/packages/markdown/marked/jasmine.json b/packages/markdown/marked/jasmine.json new file mode 100644 index 00000000..bec42542 --- /dev/null +++ b/packages/markdown/marked/jasmine.json @@ -0,0 +1,11 @@ +{ + "spec_dir": "test", + "spec_files": [ + "**/*-spec.js" + ], + "helpers": [ + "helpers/helpers.js" + ], + "stopSpecOnExpectationFailure": false, + "random": true +} diff --git a/packages/markdown/marked/lib/marked.js b/packages/markdown/marked/lib/marked.js new file mode 100644 index 00000000..39c25f26 --- /dev/null +++ b/packages/markdown/marked/lib/marked.js @@ -0,0 +1,1689 @@ +/** + * marked - a markdown parser + * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed) + * https://github.com/markedjs/marked + */ + +;(function(root) { +'use strict'; + +/** + * Block-Level Grammar + */ + +var block = { + newline: /^\n+/, + code: /^( {4}[^\n]+\n*)+/, + fences: noop, + hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/, + heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/, + nptable: noop, + blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/, + list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, + html: '^ {0,3}(?:' // optional indentation + + '<(script|pre|style)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)' // (1) + + '|comment[^\\n]*(\\n+|$)' // (2) + + '|<\\?[\\s\\S]*?\\?>\\n*' // (3) + + '|\\n*' // (4) + + '|\\n*' // (5) + + '|)[\\s\\S]*?(?:\\n{2,}|$)' // (6) + + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag + + '|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag + + ')', + def: /^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/, + table: noop, + lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, + paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/, + text: /^[^\n]+/ +}; + +block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/; +block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/; +block.def = edit(block.def) + .replace('label', block._label) + .replace('title', block._title) + .getRegex(); + +block.bullet = /(?:[*+-]|\d{1,9}\.)/; +block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/; +block.item = edit(block.item, 'gm') + .replace(/bull/g, block.bullet) + .getRegex(); + +block.list = edit(block.list) + .replace(/bull/g, block.bullet) + .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))') + .replace('def', '\\n+(?=' + block.def.source + ')') + .getRegex(); + +block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + + '|track|ul'; +block._comment = //; +block.html = edit(block.html, 'i') + .replace('comment', block._comment) + .replace('tag', block._tag) + .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/) + .getRegex(); + +block.paragraph = edit(block.paragraph) + .replace('hr', block.hr) + .replace('heading', block.heading) + .replace('lheading', block.lheading) + .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks + .getRegex(); + +block.blockquote = edit(block.blockquote) + .replace('paragraph', block.paragraph) + .getRegex(); + +/** + * Normal Block Grammar + */ + +block.normal = merge({}, block); + +/** + * GFM Block Grammar + */ + +block.gfm = merge({}, block.normal, { + fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/, + paragraph: /^/, + heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/ +}); + +block.gfm.paragraph = edit(block.paragraph) + .replace('(?!', '(?!' + + block.gfm.fences.source.replace('\\1', '\\2') + '|' + + block.list.source.replace('\\1', '\\3') + '|') + .getRegex(); + +/** + * GFM + Tables Block Grammar + */ + +block.tables = merge({}, block.gfm, { + nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/, + table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/ +}); + +/** + * Pedantic grammar + */ + +block.pedantic = merge({}, block.normal, { + html: edit( + '^ *(?:comment *(?:\\n|\\s*$)' + + '|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)' // closed tag + + '|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))') + .replace('comment', block._comment) + .replace(/tag/g, '(?!(?:' + + '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') + .getRegex(), + def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/ +}); + +/** + * Block Lexer + */ + +function Lexer(options) { + this.tokens = []; + this.tokens.links = Object.create(null); + this.options = options || marked.defaults; + this.rules = block.normal; + + if (this.options.pedantic) { + this.rules = block.pedantic; + } else if (this.options.gfm) { + if (this.options.tables) { + this.rules = block.tables; + } else { + this.rules = block.gfm; + } + } +} + +/** + * Expose Block Rules + */ + +Lexer.rules = block; + +/** + * Static Lex Method + */ + +Lexer.lex = function(src, options) { + var lexer = new Lexer(options); + return lexer.lex(src); +}; + +/** + * Preprocessing + */ + +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); +}; + +/** + * Lexing + */ + +Lexer.prototype.token = function(src, top) { + src = src.replace(/^ +$/gm, ''); + var next, + loose, + cap, + bull, + b, + item, + listStart, + listItems, + t, + space, + i, + tag, + l, + isordered, + istask, + ischecked; + + while (src) { + // newline + if (cap = this.rules.newline.exec(src)) { + src = src.substring(cap[0].length); + if (cap[0].length > 1) { + this.tokens.push({ + type: 'space' + }); + } + } + + // code + 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 + ? rtrim(cap, '\n') + : cap + }); + continue; + } + + // fences (gfm) + if (cap = this.rules.fences.exec(src)) { + src = src.substring(cap[0].length); + this.tokens.push({ + type: 'code', + lang: cap[2] ? cap[2].trim() : cap[2], + text: cap[3] || '' + }); + continue; + } + + // heading + 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; + } + + // table no leading pipe (gfm) + if (cap = this.rules.nptable.exec(src)) { + item = { + type: 'table', + header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')), + align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), + cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [] + }; + + if (item.header.length === item.align.length) { + src = src.substring(cap[0].length); + + for (i = 0; i < item.align.length; i++) { + if (/^ *-+: *$/.test(item.align[i])) { + item.align[i] = 'right'; + } else if (/^ *:-+: *$/.test(item.align[i])) { + item.align[i] = 'center'; + } else if (/^ *:-+ *$/.test(item.align[i])) { + item.align[i] = 'left'; + } else { + item.align[i] = null; + } + } + + for (i = 0; i < item.cells.length; i++) { + item.cells[i] = splitCells(item.cells[i], item.header.length); + } + + this.tokens.push(item); + + continue; + } + } + + // hr + if (cap = this.rules.hr.exec(src)) { + src = src.substring(cap[0].length); + this.tokens.push({ + type: 'hr' + }); + continue; + } + + // blockquote + if (cap = this.rules.blockquote.exec(src)) { + src = src.substring(cap[0].length); + + this.tokens.push({ + type: 'blockquote_start' + }); + + cap = cap[0].replace(/^ *> ?/gm, ''); + + // Pass `top` to keep the current + // "toplevel" state. This is exactly + // how markdown.pl works. + this.token(cap, top); + + this.tokens.push({ + type: 'blockquote_end' + }); + + continue; + } + + // list + if (cap = this.rules.list.exec(src)) { + src = src.substring(cap[0].length); + bull = cap[2]; + isordered = bull.length > 1; + + listStart = { + type: 'list_start', + ordered: isordered, + start: isordered ? +bull : '', + loose: false + }; + + this.tokens.push(listStart); + + // Get each top-level item. + cap = cap[0].match(this.rules.item); + + listItems = []; + next = false; + l = cap.length; + i = 0; + + for (; i < l; i++) { + item = cap[i]; + + // Remove the list item's bullet + // so it is seen as the next token. + space = item.length; + item = item.replace(/^ *([*+-]|\d+\.) */, ''); + + // Outdent whatever the + // list item contains. Hacky. + if (~item.indexOf('\n ')) { + space -= item.length; + item = !this.options.pedantic + ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') + : item.replace(/^ {1,4}/gm, ''); + } + + // Determine whether the next list item belongs here. + // Backpedal if it does not belong in this list. + if (i !== l - 1) { + b = block.bullet.exec(cap[i + 1])[0]; + if (bull.length > 1 ? b.length === 1 + : (b.length > 1 || (this.options.smartLists && b !== bull))) { + src = cap.slice(i + 1).join('\n') + src; + i = l - 1; + } + } + + // Determine whether item is loose or not. + // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/ + // for discount behavior. + loose = next || /\n\n(?!\s*$)/.test(item); + if (i !== l - 1) { + next = item.charAt(item.length - 1) === '\n'; + if (!loose) loose = next; + } + + if (loose) { + listStart.loose = true; + } + + // Check for task list items + istask = /^\[[ xX]\] /.test(item); + ischecked = undefined; + if (istask) { + ischecked = item[1] !== ' '; + item = item.replace(/^\[[ xX]\] +/, ''); + } + + t = { + type: 'list_item_start', + task: istask, + checked: ischecked, + loose: loose + }; + + listItems.push(t); + this.tokens.push(t); + + // Recurse. + this.token(item, false); + + this.tokens.push({ + type: 'list_item_end' + }); + } + + if (listStart.loose) { + l = listItems.length; + i = 0; + for (; i < l; i++) { + listItems[i].loose = true; + } + } + + this.tokens.push({ + type: 'list_end' + }); + + continue; + } + + // html + if (cap = this.rules.html.exec(src)) { + src = src.substring(cap[0].length); + this.tokens.push({ + type: this.options.sanitize + ? 'paragraph' + : 'html', + pre: !this.options.sanitizer + && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'), + text: cap[0] + }); + continue; + } + + // def + if (top && (cap = this.rules.def.exec(src))) { + src = src.substring(cap[0].length); + if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1); + tag = cap[1].toLowerCase().replace(/\s+/g, ' '); + if (!this.tokens.links[tag]) { + this.tokens.links[tag] = { + href: cap[2], + title: cap[3] + }; + } + continue; + } + + // table (gfm) + if (cap = this.rules.table.exec(src)) { + item = { + type: 'table', + header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')), + align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), + cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [] + }; + + if (item.header.length === item.align.length) { + src = src.substring(cap[0].length); + + for (i = 0; i < item.align.length; i++) { + if (/^ *-+: *$/.test(item.align[i])) { + item.align[i] = 'right'; + } else if (/^ *:-+: *$/.test(item.align[i])) { + item.align[i] = 'center'; + } else if (/^ *:-+ *$/.test(item.align[i])) { + item.align[i] = 'left'; + } else { + item.align[i] = null; + } + } + + for (i = 0; i < item.cells.length; i++) { + item.cells[i] = splitCells( + item.cells[i].replace(/^ *\| *| *\| *$/g, ''), + item.header.length); + } + + this.tokens.push(item); + + continue; + } + } + + // lheading + if (cap = this.rules.lheading.exec(src)) { + src = src.substring(cap[0].length); + this.tokens.push({ + type: 'heading', + depth: cap[2] === '=' ? 1 : 2, + text: cap[1] + }); + continue; + } + + // top-level paragraph + if (top && (cap = this.rules.paragraph.exec(src))) { + src = src.substring(cap[0].length); + this.tokens.push({ + type: 'paragraph', + text: cap[1].charAt(cap[1].length - 1) === '\n' + ? cap[1].slice(0, -1) + : cap[1] + }); + continue; + } + + // text + if (cap = this.rules.text.exec(src)) { + // Top-level should never reach here. + src = src.substring(cap[0].length); + this.tokens.push({ + type: 'text', + text: cap[0] + }); + continue; + } + + if (src) { + throw new Error('Infinite loop on byte: ' + src.charCodeAt(0)); + } + } + + return this.tokens; +}; + +/** + * Inline-Level Grammar + */ + +var inline = { + escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, + autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/, + url: noop, + tag: '^comment' + + '|^' // self-closing tag + + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag + + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. + + '|^' // declaration, e.g. + + '|^', // CDATA section + link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/, + reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/, + nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/, + strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/, + em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/, + code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, + br: /^( {2,}|\\)\n(?!\s*$)/, + del: noop, + text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\?@\\[^_{|}~'; +inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex(); + +inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g; + +inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/; +inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/; +inline.autolink = edit(inline.autolink) + .replace('scheme', inline._scheme) + .replace('email', inline._email) + .getRegex(); + +inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/; + +inline.tag = edit(inline.tag) + .replace('comment', block._comment) + .replace('attribute', inline._attribute) + .getRegex(); + +inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|`(?!`)|[^\[\]\\`])*?/; +inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*)/; +inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/; + +inline.link = edit(inline.link) + .replace('label', inline._label) + .replace('href', inline._href) + .replace('title', inline._title) + .getRegex(); + +inline.reflink = edit(inline.reflink) + .replace('label', inline._label) + .getRegex(); + +/** + * Normal Inline Grammar + */ + +inline.normal = merge({}, inline); + +/** + * Pedantic Inline Grammar + */ + +inline.pedantic = merge({}, inline.normal, { + strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, + em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/, + link: edit(/^!?\[(label)\]\((.*?)\)/) + .replace('label', inline._label) + .getRegex(), + reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/) + .replace('label', inline._label) + .getRegex() +}); + +/** + * GFM Inline Grammar + */ + +inline.gfm = merge({}, inline.normal, { + escape: edit(inline.escape).replace('])', '~|])').getRegex(), + _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/, + url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, + _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/, + del: /^~+(?=\S)([\s\S]*?\S)~+/, + text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\/i.test(cap[0])) { + this.inLink = false; + } + if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.inRawBlock = true; + } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.inRawBlock = false; + } + + src = src.substring(cap[0].length); + out += this.options.sanitize + ? this.options.sanitizer + ? this.options.sanitizer(cap[0]) + : escape(cap[0]) + : cap[0]; + continue; + } + + // link + if (cap = this.rules.link.exec(src)) { + var lastParenIndex = findClosingBracket(cap[2], '()'); + if (lastParenIndex > -1) { + var linkLen = cap[0].length - (cap[2].length - lastParenIndex) - (cap[3] || '').length; + cap[2] = cap[2].substring(0, lastParenIndex); + cap[0] = cap[0].substring(0, linkLen).trim(); + cap[3] = ''; + } + src = src.substring(cap[0].length); + this.inLink = true; + href = cap[2]; + if (this.options.pedantic) { + link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href); + + if (link) { + href = link[1]; + title = link[3]; + } else { + title = ''; + } + } else { + title = cap[3] ? cap[3].slice(1, -1) : ''; + } + href = href.trim().replace(/^<([\s\S]*)>$/, '$1'); + out += this.outputLink(cap, { + href: InlineLexer.escapes(href), + title: InlineLexer.escapes(title) + }); + this.inLink = false; + continue; + } + + // reflink, nolink + 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; + } + + // strong + if (cap = this.rules.strong.exec(src)) { + src = src.substring(cap[0].length); + out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1])); + continue; + } + + // em + if (cap = this.rules.em.exec(src)) { + src = src.substring(cap[0].length); + out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1])); + continue; + } + + // code + if (cap = this.rules.code.exec(src)) { + src = src.substring(cap[0].length); + out += this.renderer.codespan(escape(cap[2].trim(), true)); + continue; + } + + // br + if (cap = this.rules.br.exec(src)) { + src = src.substring(cap[0].length); + out += this.renderer.br(); + continue; + } + + // del (gfm) + if (cap = this.rules.del.exec(src)) { + src = src.substring(cap[0].length); + out += this.renderer.del(this.output(cap[1])); + continue; + } + + // autolink + if (cap = this.rules.autolink.exec(src)) { + src = src.substring(cap[0].length); + if (cap[2] === '@') { + text = escape(this.mangle(cap[1])); + href = 'mailto:' + text; + } else { + text = escape(cap[1]); + href = text; + } + out += this.renderer.link(href, null, text); + continue; + } + + // url (gfm) + if (!this.inLink && (cap = this.rules.url.exec(src))) { + if (cap[2] === '@') { + text = escape(cap[0]); + href = 'mailto:' + text; + } else { + // do extended autolink path validation + do { + prevCapZero = cap[0]; + cap[0] = this.rules._backpedal.exec(cap[0])[0]; + } while (prevCapZero !== cap[0]); + text = escape(cap[0]); + if (cap[1] === 'www.') { + href = 'http://' + text; + } else { + href = text; + } + } + src = src.substring(cap[0].length); + out += this.renderer.link(href, null, text); + continue; + } + + // text + if (cap = this.rules.text.exec(src)) { + src = src.substring(cap[0].length); + if (this.inRawBlock) { + out += this.renderer.text(cap[0]); + } else { + out += this.renderer.text(escape(this.smartypants(cap[0]))); + } + continue; + } + + if (src) { + throw new Error('Infinite loop on byte: ' + src.charCodeAt(0)); + } + } + + return out; +}; + +InlineLexer.escapes = function(text) { + return text ? text.replace(InlineLexer.rules._escapes, '$1') : text; +}; + +/** + * Compile Link + */ + +InlineLexer.prototype.outputLink = function(cap, link) { + var href = 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])); +}; + +/** + * Smartypants Transformations + */ + +InlineLexer.prototype.smartypants = function(text) { + if (!this.options.smartypants) return text; + return text + // em-dashes + .replace(/---/g, '\u2014') + // en-dashes + .replace(/--/g, '\u2013') + // opening singles + .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018') + // closing singles & apostrophes + .replace(/'/g, '\u2019') + // opening doubles + .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c') + // closing doubles + .replace(/"/g, '\u201d') + // ellipses + .replace(/\.{3}/g, '\u2026'); +}; + +/** + * Mangle Links + */ + +InlineLexer.prototype.mangle = function(text) { + if (!this.options.mangle) return text; + var out = '', + l = text.length, + i = 0, + ch; + + for (; i < l; i++) { + ch = text.charCodeAt(i); + if (Math.random() > 0.5) { + ch = 'x' + ch.toString(16); + } + out += '&#' + ch + ';'; + } + + return out; +}; + +/** + * Renderer + */ + +function Renderer(options) { + this.options = options || marked.defaults; +} + +Renderer.prototype.code = function(code, infostring, escaped) { + var lang = (infostring || '').match(/\S*/)[0]; + 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))
+      + '
'; + } + + return '
'
+    + (escaped ? code : escape(code, true))
+    + '
\n'; +}; + +Renderer.prototype.blockquote = function(quote) { + return '
\n' + quote + '
\n'; +}; + +Renderer.prototype.html = function(html) { + return html; +}; + +Renderer.prototype.heading = function(text, level, raw, slugger) { + if (this.options.headerIds) { + return '' + + text + + '\n'; + } + // ignore IDs + return '' + text + '\n'; +}; + +Renderer.prototype.hr = function() { + return this.options.xhtml ? '
\n' : '
\n'; +}; + +Renderer.prototype.list = function(body, ordered, start) { + var type = ordered ? 'ol' : 'ul', + startatt = (ordered && start !== 1) ? (' start="' + start + '"') : ''; + return '<' + type + startatt + '>\n' + body + '\n'; +}; + +Renderer.prototype.listitem = function(text) { + return '
  • ' + text + '
  • \n'; +}; + +Renderer.prototype.checkbox = function(checked) { + return ' '; +}; + +Renderer.prototype.paragraph = function(text) { + return '

    ' + text + '

    \n'; +}; + +Renderer.prototype.table = function(header, body) { + if (body) body = '' + body + ''; + + return '\n' + + '\n' + + header + + '\n' + + body + + '
    \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 + ' align="' + flags.align + '">' + : '<' + type + '>'; + return tag + content + '\n'; +}; + +// span level renderer +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) { + href = cleanUrl(this.options.sanitize, this.options.baseUrl, href); + if (href === null) { + return text; + } + var out = ''; + return out; +}; + +Renderer.prototype.image = function(href, title, text) { + href = cleanUrl(this.options.sanitize, this.options.baseUrl, href); + if (href === null) { + return text; + } + + var out = '' + text + '' : '>'; + return out; +}; + +Renderer.prototype.text = function(text) { + return text; +}; + +/** + * TextRenderer + * returns only the textual part of the token + */ + +function TextRenderer() {} + +// no need for block level renderers + +TextRenderer.prototype.strong = +TextRenderer.prototype.em = +TextRenderer.prototype.codespan = +TextRenderer.prototype.del = +TextRenderer.prototype.text = function (text) { + return text; +}; + +TextRenderer.prototype.link = +TextRenderer.prototype.image = function(href, title, text) { + return '' + text; +}; + +TextRenderer.prototype.br = function() { + return ''; +}; + +/** + * Parsing & Compiling + */ + +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; + this.slugger = new Slugger(); +} + +/** + * Static Parse Method + */ + +Parser.parse = function(src, options) { + var parser = new Parser(options); + return parser.parse(src); +}; + +/** + * Parse Loop + */ + +Parser.prototype.parse = function(src) { + this.inline = new InlineLexer(src.links, this.options); + // use an InlineLexer with a TextRenderer to extract pure text + this.inlineText = new InlineLexer( + src.links, + merge({}, this.options, {renderer: new TextRenderer()}) + ); + this.tokens = src.reverse(); + + var out = ''; + while (this.next()) { + out += this.tok(); + } + + return out; +}; + +/** + * Next Token + */ + +Parser.prototype.next = function() { + return this.token = this.tokens.pop(); +}; + +/** + * Preview Next Token + */ + +Parser.prototype.peek = function() { + return this.tokens[this.tokens.length - 1] || 0; +}; + +/** + * Parse Text Tokens + */ + +Parser.prototype.parseText = function() { + var body = this.token.text; + + while (this.peek().type === 'text') { + body += '\n' + this.next().text; + } + + return this.inline.output(body); +}; + +/** + * Parse Current Token + */ + +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, + unescape(this.inlineText.output(this.token.text)), + this.slugger); + } + case 'code': { + return this.renderer.code(this.token.text, + this.token.lang, + this.token.escaped); + } + case 'table': { + var header = '', + body = '', + i, + row, + cell, + j; + + // header + cell = ''; + for (i = 0; i < this.token.header.length; i++) { + cell += this.renderer.tablecell( + this.inline.output(this.token.header[i]), + { header: true, align: this.token.align[i] } + ); + } + header += this.renderer.tablerow(cell); + + for (i = 0; i < this.token.cells.length; i++) { + row = this.token.cells[i]; + + cell = ''; + for (j = 0; j < row.length; j++) { + cell += this.renderer.tablecell( + this.inline.output(row[j]), + { header: false, align: this.token.align[j] } + ); + } + + body += this.renderer.tablerow(cell); + } + return this.renderer.table(header, body); + } + case 'blockquote_start': { + body = ''; + + while (this.next().type !== 'blockquote_end') { + body += this.tok(); + } + + return this.renderer.blockquote(body); + } + case 'list_start': { + body = ''; + var ordered = this.token.ordered, + start = this.token.start; + + while (this.next().type !== 'list_end') { + body += this.tok(); + } + + return this.renderer.list(body, ordered, start); + } + case 'list_item_start': { + body = ''; + var loose = this.token.loose; + var checked = this.token.checked; + var task = this.token.task; + + if (this.token.task) { + body += this.renderer.checkbox(checked); + } + + while (this.next().type !== 'list_item_end') { + body += !loose && this.token.type === 'text' + ? this.parseText() + : this.tok(); + } + return this.renderer.listitem(body, task, checked); + } + case 'html': { + // TODO parse inline content if parameter markdown=1 + return this.renderer.html(this.token.text); + } + case 'paragraph': { + return this.renderer.paragraph(this.inline.output(this.token.text)); + } + case 'text': { + return this.renderer.paragraph(this.parseText()); + } + default: { + var errMsg = 'Token with "' + this.token.type + '" type was not found.'; + if (this.options.silent) { + console.log(errMsg); + } else { + throw new Error(errMsg); + } + } + } +}; + +/** + * Slugger generates header id + */ + +function Slugger () { + this.seen = {}; +} + +/** + * Convert string to unique id + */ + +Slugger.prototype.slug = function (value) { + var slug = value + .toLowerCase() + .trim() + .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '') + .replace(/\s/g, '-'); + + if (this.seen.hasOwnProperty(slug)) { + var originalSlug = slug; + do { + this.seen[originalSlug]++; + slug = originalSlug + '-' + this.seen[originalSlug]; + } while (this.seen.hasOwnProperty(slug)); + } + this.seen[slug] = 0; + + return slug; +}; + +/** + * Helpers + */ + +function escape(html, encode) { + if (encode) { + if (escape.escapeTest.test(html)) { + return html.replace(escape.escapeReplace, function (ch) { return escape.replacements[ch]; }); + } + } else { + if (escape.escapeTestNoEncode.test(html)) { + return html.replace(escape.escapeReplaceNoEncode, function (ch) { return escape.replacements[ch]; }); + } + } + + return html; +} + +escape.escapeTest = /[&<>"']/; +escape.escapeReplace = /[&<>"']/g; +escape.replacements = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' +}; + +escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/; +escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g; + +function unescape(html) { + // explicitly match decimal, hex, and named HTML entities + return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, 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 edit(regex, opt) { + regex = regex.source || regex; + opt = opt || ''; + return { + replace: function(name, val) { + val = val.source || val; + val = val.replace(/(^|[^\[])\^/g, '$1'); + regex = regex.replace(name, val); + return this; + }, + getRegex: function() { + return new RegExp(regex, opt); + } + }; +} + +function cleanUrl(sanitize, base, href) { + if (sanitize) { + try { + var prot = decodeURIComponent(unescape(href)) + .replace(/[^\w:]/g, '') + .toLowerCase(); + } catch (e) { + return null; + } + if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) { + return null; + } + } + if (base && !originIndependentUrl.test(href)) { + href = resolveUrl(base, href); + } + try { + href = encodeURI(href).replace(/%25/g, '%'); + } catch (e) { + return null; + } + return href; +} + +function resolveUrl(base, href) { + if (!baseUrls[' ' + base]) { + // we can ignore everything in base after the last slash of its path component, + // but we might need to add _that_ + // https://tools.ietf.org/html/rfc3986#section-3 + if (/^[^:]+:\/*[^/]*$/.test(base)) { + baseUrls[' ' + base] = base + '/'; + } else { + baseUrls[' ' + base] = rtrim(base, '/', true); + } + } + base = baseUrls[' ' + base]; + + if (href.slice(0, 2) === '//') { + return base.replace(/:[\s\S]*/, ':') + href; + } else if (href.charAt(0) === '/') { + return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href; + } else { + return base + href; + } +} +var baseUrls = {}; +var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i; + +function noop() {} +noop.exec = noop; + +function merge(obj) { + var i = 1, + target, + key; + + for (; i < arguments.length; i++) { + target = arguments[i]; + for (key in target) { + if (Object.prototype.hasOwnProperty.call(target, key)) { + obj[key] = target[key]; + } + } + } + + return obj; +} + +function splitCells(tableRow, count) { + // ensure that every cell-delimiting pipe has a space + // before it to distinguish it from an escaped pipe + var row = tableRow.replace(/\|/g, function (match, offset, str) { + var escaped = false, + curr = offset; + while (--curr >= 0 && str[curr] === '\\') escaped = !escaped; + if (escaped) { + // odd number of slashes means | is escaped + // so we leave it alone + return '|'; + } else { + // add space before unescaped | + return ' |'; + } + }), + cells = row.split(/ \|/), + i = 0; + + if (cells.length > count) { + cells.splice(count); + } else { + while (cells.length < count) cells.push(''); + } + + for (; i < cells.length; i++) { + // leading or trailing whitespace is ignored per the gfm spec + cells[i] = cells[i].trim().replace(/\\\|/g, '|'); + } + return cells; +} + +// Remove trailing 'c's. Equivalent to str.replace(/c*$/, ''). +// /c*$/ is vulnerable to REDOS. +// invert: Remove suffix of non-c chars instead. Default falsey. +function rtrim(str, c, invert) { + if (str.length === 0) { + return ''; + } + + // Length of suffix matching the invert condition. + var suffLen = 0; + + // Step left until we fail to match the invert condition. + while (suffLen < str.length) { + var currChar = str.charAt(str.length - suffLen - 1); + if (currChar === c && !invert) { + suffLen++; + } else if (currChar !== c && invert) { + suffLen++; + } else { + break; + } + } + + return str.substr(0, str.length - suffLen); +} + +function findClosingBracket(str, b) { + if (str.indexOf(b[1]) === -1) { + return -1; + } + var level = 0; + for (var i = 0; i < str.length; i++) { + if (str[i] === '\\') { + i++; + } else if (str[i] === b[0]) { + level++; + } else if (str[i] === b[1]) { + level--; + if (level < 0) { + return i; + } + } + } + return -1; +} + +/** + * Marked + */ + +function marked(src, opt, callback) { + // throw error in case of non string input + if (typeof src === 'undefined' || src === null) { + throw new Error('marked(): input parameter is undefined or null'); + } + if (typeof src !== 'string') { + throw new Error('marked(): input parameter is of type ' + + Object.prototype.toString.call(src) + ', string expected'); + } + + if (callback || typeof opt === 'function') { + if (!callback) { + callback = opt; + opt = null; + } + + opt = merge({}, marked.defaults, opt || {}); + + var highlight = opt.highlight, + tokens, + pending, + i = 0; + + try { + tokens = Lexer.lex(src, opt); + } catch (e) { + return callback(e); + } + + pending = tokens.length; + + var done = function(err) { + if (err) { + opt.highlight = highlight; + return callback(err); + } + + var out; + + try { + out = Parser.parse(tokens, opt); + } catch (e) { + err = e; + } + + opt.highlight = highlight; + + return err + ? callback(err) + : callback(null, out); + }; + + if (!highlight || highlight.length < 3) { + return done(); + } + + delete opt.highlight; + + if (!pending) return done(); + + for (; i < tokens.length; i++) { + (function(token) { + if (token.type !== 'code') { + return --pending || done(); + } + return highlight(token.text, token.lang, function(err, code) { + if (err) return done(err); + if (code == null || code === token.text) { + return --pending || done(); + } + token.text = code; + token.escaped = true; + --pending || done(); + }); + })(tokens[i]); + } + + return; + } + try { + if (opt) opt = merge({}, marked.defaults, opt); + return Parser.parse(Lexer.lex(src, opt), opt); + } catch (e) { + e.message += '\nPlease report this to https://github.com/markedjs/marked.'; + if ((opt || marked.defaults).silent) { + return '

    An error occurred:

    '
    +        + escape(e.message + '', true)
    +        + '
    '; + } + throw e; + } +} + +/** + * Options + */ + +marked.options = +marked.setOptions = function(opt) { + merge(marked.defaults, opt); + return marked; +}; + +marked.getDefaults = function () { + return { + baseUrl: null, + breaks: false, + gfm: true, + headerIds: true, + headerPrefix: '', + highlight: null, + langPrefix: 'language-', + mangle: true, + pedantic: false, + renderer: new Renderer(), + sanitize: false, + sanitizer: null, + silent: false, + smartLists: false, + smartypants: false, + tables: true, + xhtml: false + }; +}; + +marked.defaults = marked.getDefaults(); + +/** + * Expose + */ + +marked.Parser = Parser; +marked.parser = Parser.parse; + +marked.Renderer = Renderer; +marked.TextRenderer = TextRenderer; + +marked.Lexer = Lexer; +marked.lexer = Lexer.lex; + +marked.InlineLexer = InlineLexer; +marked.inlineLexer = InlineLexer.output; + +marked.Slugger = Slugger; + +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 { + root.marked = marked; +} +})(this || (typeof window !== 'undefined' ? window : global)); diff --git a/packages/markdown/marked/man/marked.1 b/packages/markdown/marked/man/marked.1 new file mode 100644 index 00000000..848b4424 --- /dev/null +++ b/packages/markdown/marked/man/marked.1 @@ -0,0 +1,114 @@ +.ds q \N'34' +.TH marked 1 + +.SH NAME +marked \- a javascript markdown parser + +.SH SYNOPSIS +.B marked +[\-o \fI\fP] [\-i \fI\fP] [\-\-help] +[\-\-tokens] [\-\-pedantic] [\-\-gfm] +[\-\-breaks] [\-\-tables] [\-\-sanitize] +[\-\-smart\-lists] [\-\-lang\-prefix \fI\fP] +[\-\-no\-etc...] [\-\-silent] [\fIfilename\fP] + +.SH DESCRIPTION +.B marked +is a full-featured javascript markdown parser, built for speed. +It also includes multiple GFM features. + +.SH EXAMPLES +.TP +cat in.md | marked > out.html +.TP +echo "hello *world*" | marked +.TP +marked \-o out.html \-i in.md \-\-gfm +.TP +marked \-\-output="hello world.html" \-i in.md \-\-no-breaks + +.SH OPTIONS +.TP +.BI \-o,\ \-\-output\ [\fIoutput\fP] +Specify file output. If none is specified, write to stdout. +.TP +.BI \-i,\ \-\-input\ [\fIinput\fP] +Specify file input, otherwise use last argument as input file. +If no input file is specified, read from stdin. +.TP +.BI \-\-test +Makes sure the test(s) pass. +.RS +.PP +.B \-\-glob [\fIfile\fP] +Specify which test to use. +.PP +.B \-\-fix +Fixes tests. +.PP +.B \-\-bench +Benchmarks the test(s). +.PP +.B \-\-time +Times The test(s). +.PP +.B \-\-minified +Runs test file(s) as minified. +.PP +.B \-\-stop +Stop process if a test fails. +.RE +.TP +.BI \-t,\ \-\-tokens +Output a token stream instead of html. +.TP +.BI \-\-pedantic +Conform to obscure parts of markdown.pl as much as possible. +Don't fix original markdown bugs. +.TP +.BI \-\-gfm +Enable github flavored markdown. +.TP +.BI \-\-breaks +Enable GFM line breaks. Only works with the gfm option. +.TP +.BI \-\-tables +Enable GFM tables. Only works with the gfm option. +.TP +.BI \-\-sanitize +Sanitize output. Ignore any HTML input. +.TP +.BI \-\-smart\-lists +Use smarter list behavior than the original markdown. +.TP +.BI \-\-lang\-prefix\ [\fIprefix\fP] +Set the prefix for code block classes. +.TP +.BI \-\-mangle +Mangle email addresses. +.TP +.BI \-\-no\-sanitize,\ \-no-etc... +The inverse of any of the marked options above. +.TP +.BI \-\-silent +Silence error output. +.TP +.BI \-h,\ \-\-help +Display help information. + +.SH CONFIGURATION +For configuring and running programmatically. + +.B Example + + require('marked')('*foo*', { gfm: true }); + +.SH BUGS +Please report any bugs to https://github.com/markedjs/marked. + +.SH LICENSE +Copyright (c) 2011-2014, Christopher Jeffrey (MIT License). + +.SH "SEE ALSO" +.BR markdown(1), +.BR node.js(1) diff --git a/packages/markdown/marked/man/marked.1.txt b/packages/markdown/marked/man/marked.1.txt new file mode 100644 index 00000000..ea07ad36 --- /dev/null +++ b/packages/markdown/marked/man/marked.1.txt @@ -0,0 +1,99 @@ +marked(1) General Commands Manual marked(1) + +NAME + marked - a javascript markdown parser + +SYNOPSIS + marked [-o ] [-i ] [--help] [--tokens] + [--pedantic] [--gfm] [--breaks] [--tables] [--sanitize] + [--smart-lists] [--lang-prefix ] [--no-etc...] [--silent] + [filename] + +DESCRIPTION + marked is a full-featured javascript markdown parser, built for speed. + It also includes multiple GFM features. + +EXAMPLES + cat in.md | marked > out.html + + echo "hello *world*" | marked + + marked -o out.html -i in.md --gfm + + marked --output="hello world.html" -i in.md --no-breaks + +OPTIONS + -o, --output [output] + Specify file output. If none is specified, write to stdout. + + -i, --input [input] + Specify file input, otherwise use last argument as input file. + If no input file is specified, read from stdin. + + --test Makes sure the test(s) pass. + + --glob [file] Specify which test to use. + + --fix Fixes tests. + + --bench Benchmarks the test(s). + + --time Times The test(s). + + --minified Runs test file(s) as minified. + + --stop Stop process if a test fails. + + -t, --tokens + Output a token stream instead of html. + + --pedantic + Conform to obscure parts of markdown.pl as much as possible. + Don't fix original markdown bugs. + + --gfm Enable github flavored markdown. + + --breaks + Enable GFM line breaks. Only works with the gfm option. + + --tables + Enable GFM tables. Only works with the gfm option. + + --sanitize + Sanitize output. Ignore any HTML input. + + --smart-lists + Use smarter list behavior than the original markdown. + + --lang-prefix [prefix] + Set the prefix for code block classes. + + --mangle + Mangle email addresses. + + --no-sanitize, -no-etc... + The inverse of any of the marked options above. + + --silent + Silence error output. + + -h, --help + Display help information. + +CONFIGURATION + For configuring and running programmatically. + + Example + + require('marked')('*foo*', { gfm: true }); + +BUGS + Please report any bugs to https://github.com/markedjs/marked. + +LICENSE + Copyright (c) 2011-2014, Christopher Jeffrey (MIT License). + +SEE ALSO + markdown(1), node.js(1) + + marked(1) diff --git a/packages/markdown/marked/marked.min.js b/packages/markdown/marked/marked.min.js new file mode 100644 index 00000000..085cfb56 --- /dev/null +++ b/packages/markdown/marked/marked.min.js @@ -0,0 +1,6 @@ +/** + * marked - a markdown parser + * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed) + * https://github.com/markedjs/marked + */ +!function(e){"use strict";var k={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:f,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,nptable:f,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|\\n*|\\n*|)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:f,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,text:/^[^\n]+/};function a(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||b.defaults,this.rules=k.normal,this.options.pedantic?this.rules=k.pedantic:this.options.gfm&&(this.options.tables?this.rules=k.tables:this.rules=k.gfm)}k._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,k._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,k.def=i(k.def).replace("label",k._label).replace("title",k._title).getRegex(),k.bullet=/(?:[*+-]|\d{1,9}\.)/,k.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,k.item=i(k.item,"gm").replace(/bull/g,k.bullet).getRegex(),k.list=i(k.list).replace(/bull/g,k.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+k.def.source+")").getRegex(),k._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",k._comment=//,k.html=i(k.html,"i").replace("comment",k._comment).replace("tag",k._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k.paragraph=i(k.paragraph).replace("hr",k.hr).replace("heading",k.heading).replace("lheading",k.lheading).replace("tag",k._tag).getRegex(),k.blockquote=i(k.blockquote).replace("paragraph",k.paragraph).getRegex(),k.normal=d({},k),k.gfm=d({},k.normal,{fences:/^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),k.gfm.paragraph=i(k.paragraph).replace("(?!","(?!"+k.gfm.fences.source.replace("\\1","\\2")+"|"+k.list.source.replace("\\1","\\3")+"|").getRegex(),k.tables=d({},k.gfm,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/}),k.pedantic=d({},k.normal,{html:i("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",k._comment).replace(/tag/g,"(?!(?: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").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/}),a.rules=k,a.lex=function(e,t){return new a(t).lex(e)},a.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},a.prototype.token=function(e,t){var n,r,s,i,l,o,a,h,p,u,c,g,f,d,m,b;for(e=e.replace(/^ +$/gm,"");e;)if((s=this.rules.newline.exec(e))&&(e=e.substring(s[0].length),1 ?/gm,""),this.token(s,t),this.tokens.push({type:"blockquote_end"});else if(s=this.rules.list.exec(e)){for(e=e.substring(s[0].length),a={type:"list_start",ordered:d=1<(i=s[2]).length,start:d?+i:"",loose:!1},this.tokens.push(a),n=!(h=[]),f=(s=s[0].match(this.rules.item)).length,c=0;c?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:f,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,strong:/^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,em:/^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:f,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\?@\\[^_{|}~",n.em=i(n.em).replace(/punctuation/g,n._punctuation).getRegex(),n._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,n._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,n._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,n.autolink=i(n.autolink).replace("scheme",n._scheme).replace("email",n._email).getRegex(),n._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,n.tag=i(n.tag).replace("comment",k._comment).replace("attribute",n._attribute).getRegex(),n._label=/(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|`(?!`)|[^\[\]\\`])*?/,n._href=/\s*(<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*)/,n._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,n.link=i(n.link).replace("label",n._label).replace("href",n._href).replace("title",n._title).getRegex(),n.reflink=i(n.reflink).replace("label",n._label).getRegex(),n.normal=d({},n),n.pedantic=d({},n.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:i(/^!?\[(label)\]\((.*?)\)/).replace("label",n._label).getRegex(),reflink:i(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",n._label).getRegex()}),n.gfm=d({},n.normal,{escape:i(n.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\/i.test(i[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(i[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(i[0])&&(this.inRawBlock=!1),e=e.substring(i[0].length),o+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):u(i[0]):i[0];else if(i=this.rules.link.exec(e)){var a=m(i[2],"()");if(-1$/,"$1"),o+=this.outputLink(i,{href:p.escapes(r),title:p.escapes(s)}),this.inLink=!1}else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),!(t=this.links[t.toLowerCase()])||!t.href){o+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,o+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),o+=this.renderer.strong(this.output(i[4]||i[3]||i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),o+=this.renderer.em(this.output(i[6]||i[5]||i[4]||i[3]||i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),o+=this.renderer.codespan(u(i[2].trim(),!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),o+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),o+=this.renderer.del(this.output(i[1]));else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),r="@"===i[2]?"mailto:"+(n=u(this.mangle(i[1]))):n=u(i[1]),o+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.inRawBlock?o+=this.renderer.text(i[0]):o+=this.renderer.text(u(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else{if("@"===i[2])r="mailto:"+(n=u(i[0]));else{for(;l=i[0],i[0]=this.rules._backpedal.exec(i[0])[0],l!==i[0];);n=u(i[0]),r="www."===i[1]?"http://"+n:n}e=e.substring(i[0].length),o+=this.renderer.link(r,null,n)}return o},p.escapes=function(e){return e?e.replace(p.rules._escapes,"$1"):e},p.prototype.outputLink=function(e,t){var n=t.href,r=t.title?u(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,u(e[1]))},p.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},p.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,s=0;s'+(n?e:u(e,!0))+"\n":"
    "+(n?e:u(e,!0))+"
    "},r.prototype.blockquote=function(e){return"
    \n"+e+"
    \n"},r.prototype.html=function(e){return e},r.prototype.heading=function(e,t,n,r){return this.options.headerIds?"'+e+"\n":""+e+"\n"},r.prototype.hr=function(){return this.options.xhtml?"
    \n":"
    \n"},r.prototype.list=function(e,t,n){var r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"\n"},r.prototype.listitem=function(e){return"
  • "+e+"
  • \n"},r.prototype.checkbox=function(e){return" "},r.prototype.paragraph=function(e){return"

    "+e+"

    \n"},r.prototype.table=function(e,t){return t&&(t=""+t+""),"\n\n"+e+"\n"+t+"
    \n"},r.prototype.tablerow=function(e){return"\n"+e+"\n"},r.prototype.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+"\n"},r.prototype.strong=function(e){return""+e+""},r.prototype.em=function(e){return""+e+""},r.prototype.codespan=function(e){return""+e+""},r.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},r.prototype.del=function(e){return""+e+""},r.prototype.link=function(e,t,n){if(null===(e=l(this.options.sanitize,this.options.baseUrl,e)))return n;var r='
    "},r.prototype.image=function(e,t,n){if(null===(e=l(this.options.sanitize,this.options.baseUrl,e)))return n;var r=''+n+'":">"},r.prototype.text=function(e){return e},s.prototype.strong=s.prototype.em=s.prototype.codespan=s.prototype.del=s.prototype.text=function(e){return e},s.prototype.link=s.prototype.image=function(e,t,n){return""+n},s.prototype.br=function(){return""},h.parse=function(e,t){return new h(t).parse(e)},h.prototype.parse=function(e){this.inline=new p(e.links,this.options),this.inlineText=new p(e.links,d({},this.options,{renderer:new s})),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},h.prototype.next=function(){return this.token=this.tokens.pop()},h.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},h.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},h.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,c(this.inlineText.output(this.token.text)),this.slugger);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s="",i="";for(n="",e=0;e?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(t))for(var n=t;this.seen[n]++,t=n+"-"+this.seen[n],this.seen.hasOwnProperty(t););return this.seen[t]=0,t},u.escapeTest=/[&<>"']/,u.escapeReplace=/[&<>"']/g,u.replacements={"&":"&","<":"<",">":">",'"':""","'":"'"},u.escapeTestNoEncode=/[<>"']|&(?!#?\w+;)/,u.escapeReplaceNoEncode=/[<>"']|&(?!#?\w+;)/g;var o={},g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function f(){}function d(e){for(var t,n,r=1;rt)n.splice(t);else for(;n.lengthAn error occurred:

    "+u(e.message+"",!0)+"
    ";throw e}}f.exec=f,b.options=b.setOptions=function(e){return d(b.defaults,e),b},b.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new r,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tables:!0,xhtml:!1}},b.defaults=b.getDefaults(),b.Parser=h,b.parser=h.parse,b.Renderer=r,b.TextRenderer=s,b.Lexer=a,b.lexer=a.lex,b.InlineLexer=p,b.inlineLexer=p.output,b.Slugger=t,b.parse=b,"undefined"!=typeof module&&"object"==typeof exports?module.exports=b:"function"==typeof define&&define.amd?define(function(){return b}):e.marked=b}(this||("undefined"!=typeof window?window:global)); \ No newline at end of file diff --git a/packages/markdown/marked/package.json b/packages/markdown/marked/package.json new file mode 100644 index 00000000..43cea559 --- /dev/null +++ b/packages/markdown/marked/package.json @@ -0,0 +1,69 @@ +{ + "name": "marked", + "description": "A markdown parser built for speed", + "author": "Christopher Jeffrey", + "version": "0.6.2", + "main": "./lib/marked.js", + "bin": "./bin/marked", + "man": "./man/marked.1", + "files": [ + "bin/", + "lib/", + "man/", + "marked.min.js" + ], + "repository": "git://github.com/markedjs/marked.git", + "homepage": "https://marked.js.org", + "bugs": { + "url": "http://github.com/markedjs/marked/issues" + }, + "license": "MIT", + "keywords": [ + "markdown", + "markup", + "html" + ], + "tags": [ + "markdown", + "markup", + "html" + ], + "devDependencies": { + "@markedjs/html-differ": "^2.0.1", + "cheerio": "^1.0.0-rc.3", + "commonmark": "0.x", + "eslint": "^5.15.1", + "eslint-config-standard": "^12.0.0", + "eslint-plugin-import": "^2.16.0", + "eslint-plugin-node": "^8.0.1", + "eslint-plugin-promise": "^4.0.1", + "eslint-plugin-standard": "^4.0.0", + "eslint-plugin-vuln-regex-detector": "^1.0.4", + "front-matter": "^3.0.1", + "glob-to-regexp": "^0.4.0", + "jasmine": "^3.3.1", + "markdown": "0.x", + "markdown-it": "8.x", + "node-fetch": "^2.3.0", + "uglify-js": "^3.4.9" + }, + "scripts": { + "test": "jasmine --config=jasmine.json", + "test:unit": "npm test -- test/unit/**/*-spec.js", + "test:specs": "npm test -- test/specs/**/*-spec.js", + "test:cm": "npm test -- test/specs/commonmark/**/*-spec.js", + "test:gfm": "npm test -- test/specs/gfm/**/*-spec.js", + "test:marked": "npm test -- test/specs/marked/**/*-spec.js", + "test:old": "node test", + "test:lint": "eslint bin/marked .", + "test:redos": "eslint --plugin vuln-regex-detector --rule '\"vuln-regex-detector/no-vuln-regex\": 2' lib/marked.js", + "test:node4": "npx node@4 ./node_modules/jasmine/bin/jasmine.js --config=jasmine.json", + "bench": "node test --bench", + "lint": "eslint --fix bin/marked .", + "build": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js", + "preversion": "npm run build && (git diff --quiet || git commit -am 'minify')" + }, + "engines": { + "node": ">=0.10.0" + } +} diff --git a/packages/markdown/marked/test/README b/packages/markdown/marked/test/README new file mode 100644 index 00000000..51f6560b --- /dev/null +++ b/packages/markdown/marked/test/README @@ -0,0 +1,10 @@ +In this directory: + +# +# MarkdownTester -- Run tests for Markdown implementations +# +# Copyright (c) 2004-2005 John Gruber +# +# + +Partially modified for testing purposes. diff --git a/packages/markdown/marked/test/browser/index.html b/packages/markdown/marked/test/browser/index.html new file mode 100644 index 00000000..fbde1293 --- /dev/null +++ b/packages/markdown/marked/test/browser/index.html @@ -0,0 +1,5 @@ + +marked tests +

    testing...

    + + diff --git a/packages/markdown/marked/test/browser/index.js b/packages/markdown/marked/test/browser/index.js new file mode 100644 index 00000000..8208fa3f --- /dev/null +++ b/packages/markdown/marked/test/browser/index.js @@ -0,0 +1,39 @@ +var fs = require('fs'), + path = require('path'); + +var testMod = require('../'), + load = testMod.load; + +var express = require('express'), + app = express(); + +var files = load(); + +app.use(function(req, res, next) { + var setHeader = res.setHeader; + res.setHeader = function(name) { + switch (name) { + case 'Cache-Control': + case 'Last-Modified': + case 'ETag': + return; + } + return setHeader.apply(res, arguments); + }; + next(); +}); + +app.get('/test.js', function(req, res, next) { + var test = fs.readFileSync(path.join(__dirname, 'test.js'), 'utf8'); + var testScript = test.replace('__TESTS__', JSON.stringify(files)) + .replace('__MAIN__', testMod.runTests + '') + .replace('__LIBS__', testMod.testFile + ''); + + res.contentType('.js'); + res.send(testScript); +}); + +app.use(express.static(path.join(__dirname, '/../../lib'))); +app.use(express.static(__dirname)); + +app.listen(8080); diff --git a/packages/markdown/marked/test/browser/test.js b/packages/markdown/marked/test/browser/test.js new file mode 100644 index 00000000..59917dd4 --- /dev/null +++ b/packages/markdown/marked/test/browser/test.js @@ -0,0 +1,66 @@ + +;(function() { + var console = {}, + files = __TESTS__; // eslint-disable-line no-undef + + console.log = function(text) { + var args = Array.prototype.slice.call(arguments, 1), + i = 0; + + text = text.replace(/%\w/g, function() { + return args[i++] || ''; + }); + + if (window.console) window.console.log(text); + document.body.innerHTML += '
    ' + escape(text) + '
    '; + }; + + if (!Object.keys) { + Object.keys = function(obj) { + var out = [], + key; + + for (key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + out.push(key); + } + } + + return out; + }; + } + + if (!Array.prototype.forEach) { + // eslint-disable-next-line no-extend-native + Array.prototype.forEach = function(callback, context) { + for (var i = 0; i < this.length; i++) { + callback.call(context || null, this[i], i, this); + } + }; + } + + if (!String.prototype.trim) { + // eslint-disable-next-line no-extend-native + String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, ''); + }; + } + + // eslint-disable-next-line no-unused-vars + function load() { + return files; + } + + function escape(html, encode) { + return html + .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + __LIBS__; // eslint-disable-line no-undef, no-unused-expressions + + (__MAIN__)(); // eslint-disable-line no-undef +}).call(this); diff --git a/packages/markdown/marked/test/helpers/helpers.js b/packages/markdown/marked/test/helpers/helpers.js new file mode 100644 index 00000000..44632fcd --- /dev/null +++ b/packages/markdown/marked/test/helpers/helpers.js @@ -0,0 +1,26 @@ +const marked = require('../../'); +const htmlDiffer = require('./html-differ.js'); + +beforeEach(() => { + marked.setOptions(marked.getDefaults()); + + jasmine.addMatchers({ + toRender: () => { + return { + compare: (spec, expected) => { + const result = {}; + const actual = marked(spec.markdown, spec.options); + result.pass = htmlDiffer.isEqual(expected, actual); + + if (result.pass) { + result.message = `${spec.markdown}\n------\n\nExpected: Should Fail`; + } else { + const diff = htmlDiffer.firstDiff(actual, expected); + result.message = `Expected: ${diff.expected}\n Actual: ${diff.actual}`; + } + return result; + } + }; + } + }); +}); diff --git a/packages/markdown/marked/test/helpers/html-differ.js b/packages/markdown/marked/test/helpers/html-differ.js new file mode 100644 index 00000000..44052be4 --- /dev/null +++ b/packages/markdown/marked/test/helpers/html-differ.js @@ -0,0 +1,38 @@ +const HtmlDiffer = require('@markedjs/html-differ').HtmlDiffer; +const htmlDiffer = new HtmlDiffer({ignoreSelfClosingSlash: true}); + +module.exports = { + isEqual: htmlDiffer.isEqual.bind(htmlDiffer), + firstDiff: (actual, expected, padding) => { + padding = padding || 30; + const result = htmlDiffer + .diffHtml(actual, expected) + .reduce((obj, diff) => { + if (diff.added) { + if (obj.firstIndex === null) { + obj.firstIndex = obj.expected.length; + } + obj.expected += diff.value; + } else if (diff.removed) { + if (obj.firstIndex === null) { + obj.firstIndex = obj.actual.length; + } + obj.actual += diff.value; + } else { + obj.actual += diff.value; + obj.expected += diff.value; + } + + return obj; + }, { + firstIndex: null, + actual: '', + expected: '' + }); + + return { + actual: result.actual.substring(result.firstIndex - padding, result.firstIndex + padding), + expected: result.expected.substring(result.firstIndex - padding, result.firstIndex + padding) + }; + } +}; diff --git a/packages/markdown/marked/test/index.js b/packages/markdown/marked/test/index.js new file mode 100644 index 00000000..5027ee5b --- /dev/null +++ b/packages/markdown/marked/test/index.js @@ -0,0 +1,551 @@ +#!/usr/bin/env node +'use strict'; +// 'use strict' is here so we can use let and const in node 4 + +/** + * marked tests + * Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed) + * https://github.com/markedjs/marked + */ + +/** + * Modules + */ + +const fs = require('fs'); +const path = require('path'); +const fm = require('front-matter'); +const g2r = require('glob-to-regexp'); +let marked = require('../'); +const htmlDiffer = require('./helpers/html-differ.js'); + +/** + * Load Tests + */ + +function load(options) { + options = options || {}; + const dir = path.join(__dirname, 'compiled_tests'); + const glob = g2r(options.glob || '*', { extended: true }); + + const list = fs + .readdirSync(dir) + .filter(file => { + return path.extname(file) === '.md'; + }) + .sort(); + + const files = list.reduce((obj, item) => { + const name = path.basename(item, '.md'); + if (glob.test(name)) { + const file = path.join(dir, item); + const content = fm(fs.readFileSync(file, 'utf8')); + + obj[name] = { + options: content.attributes, + text: content.body, + html: fs.readFileSync(file.replace(/[^.]+$/, 'html'), 'utf8') + }; + } + return obj; + }, {}); + + if (options.bench || options.time) { + if (!options.glob) { + // Change certain tests to allow + // comparison to older benchmark times. + fs.readdirSync(path.join(__dirname, 'new')).forEach(name => { + if (path.extname(name) === '.html') return; + if (name === 'main.md') return; + delete files[name]; + }); + } + + if (files['backslash_escapes.md']) { + files['backslash_escapes.md'] = { + text: 'hello world \\[how](are you) today' + }; + } + + if (files['main.md']) { + files['main.md'].text = files['main.md'].text.replace('* * *\n\n', ''); + } + } + + return files; +} + +/** + * Test Runner + */ + +function runTests(engine, options) { + if (typeof engine !== 'function') { + options = engine; + engine = null; + } + + engine = engine || marked; + options = options || {}; + + let succeeded = 0; + let failed = 0; + const files = options.files || load(options); + const filenames = Object.keys(files); + + if (options.marked) { + marked.setOptions(options.marked); + } + + for (let i = 0; i < filenames.length; i++) { + const filename = filenames[i]; + const file = files[filename]; + + const success = testFile(engine, file, filename, i + 1); + + if (success) { + succeeded++; + } else { + failed++; + if (options.stop) { + break; + } + } + } + + console.log('\n%d/%d tests completed successfully.', succeeded, filenames.length); + if (failed) console.log('%d/%d tests failed.', failed, filenames.length); + + return !failed; +} + +/** + * Test a file + */ + +function testFile(engine, file, filename, index) { + const opts = Object.keys(file.options); + + if (marked._original) { + marked.defaults = marked._original; + delete marked._original; + } + + console.log('#%d. Test %s', index, filename); + + if (opts.length) { + marked._original = marked.defaults; + marked.defaults = {}; + Object.keys(marked._original).forEach(key => { + marked.defaults[key] = marked._original[key]; + }); + opts.forEach(key => { + if (marked.defaults.hasOwnProperty(key)) { + marked.defaults[key] = file.options[key]; + } + }); + } + + const before = process.hrtime(); + + let text, html, elapsed; + try { + text = engine(file.text); + html = file.html; + } catch (e) { + elapsed = process.hrtime(before); + console.log('\n failed in %dms\n', prettyElapsedTime(elapsed)); + throw e; + } + + elapsed = process.hrtime(before); + + if (htmlDiffer.isEqual(text, html)) { + if (elapsed[0] > 0) { + console.log('\n failed because it took too long.\n\n passed in %dms\n', prettyElapsedTime(elapsed)); + return false; + } + console.log(' passed in %dms', prettyElapsedTime(elapsed)); + return true; + } + + const diff = htmlDiffer.firstDiff(text, html); + + console.log('\n failed in %dms', prettyElapsedTime(elapsed)); + console.log(' Expected: %s', diff.expected); + console.log(' Actual: %s\n', diff.actual); + return false; +} + +/** + * Benchmark a function + */ + +function bench(name, files, engine) { + const start = Date.now(); + + for (let i = 0; i < 1000; i++) { + for (const filename in files) { + engine(files[filename].text); + } + } + + const end = Date.now(); + + console.log('%s completed in %dms.', name, end - start); +} + +/** + * Benchmark all engines + */ + +function runBench(options) { + options = options || {}; + const files = load(options); + + // Non-GFM, Non-pedantic + marked.setOptions({ + gfm: false, + tables: false, + breaks: false, + pedantic: false, + sanitize: false, + smartLists: false + }); + if (options.marked) { + marked.setOptions(options.marked); + } + bench('marked', files, marked); + + // GFM + marked.setOptions({ + gfm: true, + tables: false, + breaks: false, + pedantic: false, + sanitize: false, + smartLists: false + }); + if (options.marked) { + marked.setOptions(options.marked); + } + bench('marked (gfm)', files, marked); + + // Pedantic + marked.setOptions({ + gfm: false, + tables: false, + breaks: false, + pedantic: true, + sanitize: false, + smartLists: false + }); + if (options.marked) { + marked.setOptions(options.marked); + } + bench('marked (pedantic)', files, marked); + + try { + bench('commonmark', files, (() => { + const commonmark = require('commonmark'); + const parser = new commonmark.Parser(); + const writer = new commonmark.HtmlRenderer(); + return function (text) { + return writer.render(parser.parse(text)); + }; + })()); + } catch (e) { + console.log('Could not bench commonmark. (Error: %s)', e.message); + } + + try { + bench('markdown-it', files, (() => { + const MarkdownIt = require('markdown-it'); + const md = new MarkdownIt(); + return md.render.bind(md); + })()); + } catch (e) { + console.log('Could not bench markdown-it. (Error: %s)', e.message); + } + + try { + bench('markdown.js', files, (() => { + const markdown = require('markdown').markdown; + return markdown.toHTML.bind(markdown); + })()); + } catch (e) { + console.log('Could not bench markdown.js. (Error: %s)', e.message); + } + + return true; +} + +/** + * A simple one-time benchmark + */ + +function time(options) { + options = options || {}; + const files = load(options); + if (options.marked) { + marked.setOptions(options.marked); + } + bench('marked', files, marked); + + return true; +} + +/** + * Markdown Test Suite Fixer + * This function is responsible for "fixing" + * the markdown test suite. There are + * certain aspects of the suite that + * are strange or might make tests + * fail for reasons unrelated to + * conformance. + */ + +function fix() { + ['compiled_tests', 'original', 'new', 'redos'].forEach(dir => { + try { + fs.mkdirSync(path.resolve(__dirname, dir)); + } catch (e) { + // directory already exists + } + }); + + // rm -rf tests + fs.readdirSync(path.resolve(__dirname, 'compiled_tests')).forEach(file => { + fs.unlinkSync(path.resolve(__dirname, 'compiled_tests', file)); + }); + + // cp -r original tests + fs.readdirSync(path.resolve(__dirname, 'original')).forEach(file => { + let text = fs.readFileSync(path.resolve(__dirname, 'original', file), 'utf8'); + + if (path.extname(file) === '.md') { + if (fm.test(text)) { + text = fm(text); + text = `---\n${text.frontmatter}\ngfm: false\n---\n${text.body}`; + } else { + text = `---\ngfm: false\n---\n${text}`; + } + } + + fs.writeFileSync(path.resolve(__dirname, 'compiled_tests', file), text); + }); + + // node fix.js + const dir = path.join(__dirname, 'compiled_tests'); + + fs.readdirSync(dir).filter(file => { + return path.extname(file) === '.html'; + }).forEach(file => { + file = path.join(dir, file); + let html = fs.readFileSync(file, 'utf8'); + + // fix unencoded quotes + html = html + .replace(/='([^\n']*)'(?=[^<>\n]*>)/g, '=&__APOS__;$1&__APOS__;') + .replace(/="([^\n"]*)"(?=[^<>\n]*>)/g, '=&__QUOT__;$1&__QUOT__;') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/&__QUOT__;/g, '"') + .replace(/&__APOS__;/g, '\''); + + fs.writeFileSync(file, html); + }); + + // turn
    into
    + fs.readdirSync(dir).forEach(file => { + file = path.join(dir, file); + let text = fs.readFileSync(file, 'utf8'); + + text = text.replace(/(<|<)hr\s*\/(>|>)/g, '$1hr$2'); + + fs.writeFileSync(file, text); + }); + + // markdown does some strange things. + // it does not encode naked `>`, marked does. + { + const file = `${dir}/amps_and_angles_encoding.html`; + const html = fs.readFileSync(file, 'utf8') + .replace('6 > 5.', '6 > 5.'); + + fs.writeFileSync(file, html); + } + + // cp new/* tests/ + fs.readdirSync(path.resolve(__dirname, 'new')).forEach(file => { + fs.writeFileSync(path.resolve(__dirname, 'compiled_tests', file), + fs.readFileSync(path.resolve(__dirname, 'new', file))); + }); + + // cp redos/* tests/ + fs.readdirSync(path.resolve(__dirname, 'redos')).forEach(file => { + fs.writeFileSync(path.resolve(__dirname, 'compiled_tests', file), + fs.readFileSync(path.resolve(__dirname, 'redos', file))); + }); +} + +/** + * Argument Parsing + */ + +function parseArg(argv) { + argv = argv.slice(2); + + const options = {}; + const orphans = []; + + function getarg() { + let arg = argv.shift(); + + if (arg.indexOf('--') === 0) { + // e.g. --opt + arg = arg.split('='); + if (arg.length > 1) { + // e.g. --opt=val + argv.unshift(arg.slice(1).join('=')); + } + arg = arg[0]; + } else if (arg[0] === '-') { + if (arg.length > 2) { + // e.g. -abc + argv = arg.substring(1).split('').map(ch => { + return `-${ch}`; + }).concat(argv); + arg = argv.shift(); + } else { + // e.g. -a + } + } else { + // e.g. foo + } + + return arg; + } + + while (argv.length) { + let arg = getarg(); + switch (arg) { + case '-f': + case '--fix': + case 'fix': + if (options.fix !== false) { + options.fix = true; + } + break; + case '--no-fix': + case 'no-fix': + options.fix = false; + break; + case '-b': + case '--bench': + options.bench = true; + break; + case '-s': + case '--stop': + options.stop = true; + break; + case '-t': + case '--time': + options.time = true; + break; + case '-m': + case '--minified': + options.minified = true; + break; + case '--glob': + arg = argv.shift(); + options.glob = arg.replace(/^=/, ''); + break; + default: + if (arg.indexOf('--') === 0) { + const opt = camelize(arg.replace(/^--(no-)?/, '')); + if (!marked.defaults.hasOwnProperty(opt)) { + continue; + } + options.marked = options.marked || {}; + if (arg.indexOf('--no-') === 0) { + options.marked[opt] = typeof marked.defaults[opt] !== 'boolean' + ? null + : false; + } else { + options.marked[opt] = typeof marked.defaults[opt] !== 'boolean' + ? argv.shift() + : true; + } + } else { + orphans.push(arg); + } + break; + } + } + + return options; +} + +/** + * Helpers + */ + +function camelize(text) { + return text.replace(/(\w)-(\w)/g, (_, a, b) => a + b.toUpperCase()); +} + +/** + * Main + */ + +function main(argv) { + const opt = parseArg(argv); + + if (opt.fix !== false) { + fix(); + } + + if (opt.fix) { + // only run fix + return; + } + + if (opt.bench) { + return runBench(opt); + } + + if (opt.time) { + return time(opt); + } + + if (opt.minified) { + marked = require('../marked.min.js'); + } + return runTests(opt); +} + +/** + * Execute + */ + +if (!module.parent) { + process.title = 'marked'; + process.exit(main(process.argv.slice()) ? 0 : 1); +} else { + exports = main; + exports.main = main; + exports.runTests = runTests; + exports.testFile = testFile; + exports.runBench = runBench; + exports.load = load; + exports.bench = bench; + module.exports = exports; +} + +// returns time to millisecond granularity +function prettyElapsedTime(hrtimeElapsed) { + const seconds = hrtimeElapsed[0]; + const frac = Math.round(hrtimeElapsed[1] / 1e3) / 1e3; + return seconds * 1e3 + frac; +} diff --git a/packages/markdown/marked/test/json-to-files.js b/packages/markdown/marked/test/json-to-files.js new file mode 100644 index 00000000..d7e72aaf --- /dev/null +++ b/packages/markdown/marked/test/json-to-files.js @@ -0,0 +1,62 @@ +const path = require('path'); +const fs = require('fs'); + +const folder = process.argv[2]; +const jsonFile = process.argv[3]; + +if (!folder || !jsonFile) { + console.log('node ./json-to-files.js {path to folder} {path to json file}'); + process.exit(1); +} + +const specs = require(jsonFile); + +const files = specs.reduce((obj, spec) => { + if (!obj[spec.section]) { + obj[spec.section] = { + md: [], + html: [], + options: {} + }; + } + + obj[spec.section].md.push(spec.markdown); + obj[spec.section].html.push(spec.html); + Object.assign(obj[spec.section].options, spec.options); + + return obj; +}, {}); + +try { + fs.mkdirSync(folder, {recursive: true}); +} catch (ex) { + // already exists +} + +for (const section in files) { + const file = files[section]; + const name = section.toLowerCase().replace(' ', '_'); + const frontMatter = Object.keys(file.options).map(opt => { + let value = file.options[opt]; + if (typeof value !== 'string') { + value = JSON.stringify(value); + } + return `${opt}: ${value}`; + }).join('\n'); + + let markdown = file.md.join('\n\n'); + if (frontMatter) { + markdown = `---\n${frontMatter}\n---\n\n${markdown}`; + } + const html = file.html.join('\n\n'); + + const mdFile = path.resolve(folder, `${name}.md`); + const htmlFile = path.resolve(folder, `${name}.html`); + + if (fs.existsSync(mdFile) || fs.existsSync(htmlFile)) { + throw new Error(`${name} already exists.`); + } + + fs.writeFileSync(mdFile, markdown); + fs.writeFileSync(htmlFile, html); +} diff --git a/packages/markdown/marked/test/new/adjacent_lists.html b/packages/markdown/marked/test/new/adjacent_lists.html new file mode 100644 index 00000000..b4cd8f50 --- /dev/null +++ b/packages/markdown/marked/test/new/adjacent_lists.html @@ -0,0 +1,9 @@ +
      +
    • This should be
    • +
    • An unordered list
    • +
    + +
      +
    1. This should be
    2. +
    3. An unordered list
    4. +
    diff --git a/packages/markdown/marked/test/new/adjacent_lists.md b/packages/markdown/marked/test/new/adjacent_lists.md new file mode 100644 index 00000000..3fd460b3 --- /dev/null +++ b/packages/markdown/marked/test/new/adjacent_lists.md @@ -0,0 +1,5 @@ +* This should be +* An unordered list + +1. This should be +2. An unordered list diff --git a/packages/markdown/marked/test/new/autolink_lines.html b/packages/markdown/marked/test/new/autolink_lines.html new file mode 100644 index 00000000..aa2bed4d --- /dev/null +++ b/packages/markdown/marked/test/new/autolink_lines.html @@ -0,0 +1,3 @@ +

    hello world +http://example.com +

    diff --git a/packages/markdown/marked/test/new/autolink_lines.md b/packages/markdown/marked/test/new/autolink_lines.md new file mode 100644 index 00000000..c9b61a2c --- /dev/null +++ b/packages/markdown/marked/test/new/autolink_lines.md @@ -0,0 +1,2 @@ +hello world + diff --git a/packages/markdown/marked/test/new/autolinks.html b/packages/markdown/marked/test/new/autolinks.html new file mode 100644 index 00000000..8fa4837e --- /dev/null +++ b/packages/markdown/marked/test/new/autolinks.html @@ -0,0 +1,15 @@ +

    (See https://www.example.com/fhqwhgads.)

    + +

    ((http://foo.com))

    + +

    ((http://foo.com.))

    + +

    HTTP://FOO.COM

    + +

    hTtP://fOo.CoM

    + +

    hello@email.com

    + +

    me@example.com

    + +

    test@test.com

    \ No newline at end of file diff --git a/packages/markdown/marked/test/new/autolinks.md b/packages/markdown/marked/test/new/autolinks.md new file mode 100644 index 00000000..1f5f739c --- /dev/null +++ b/packages/markdown/marked/test/new/autolinks.md @@ -0,0 +1,15 @@ +(See https://www.example.com/fhqwhgads.) + +((http://foo.com)) + +((http://foo.com.)) + +HTTP://FOO.COM + +hTtP://fOo.CoM + +~~hello@email.com~~ + +**me@example.com** + +__test@test.com__ \ No newline at end of file diff --git a/packages/markdown/marked/test/new/blockquote_list_item.html b/packages/markdown/marked/test/new/blockquote_list_item.html new file mode 100644 index 00000000..83cf0bdd --- /dev/null +++ b/packages/markdown/marked/test/new/blockquote_list_item.html @@ -0,0 +1,3 @@ +

    This fails in markdown.pl and upskirt:

    + +
    • hello

      world

    diff --git a/packages/markdown/marked/test/new/blockquote_list_item.md b/packages/markdown/marked/test/new/blockquote_list_item.md new file mode 100644 index 00000000..19e93829 --- /dev/null +++ b/packages/markdown/marked/test/new/blockquote_list_item.md @@ -0,0 +1,4 @@ +This fails in markdown.pl and upskirt: + +* hello + > world diff --git a/packages/markdown/marked/test/new/case_insensitive_refs.html b/packages/markdown/marked/test/new/case_insensitive_refs.html new file mode 100644 index 00000000..c54388ea --- /dev/null +++ b/packages/markdown/marked/test/new/case_insensitive_refs.html @@ -0,0 +1 @@ +

    hi

    diff --git a/packages/markdown/marked/test/new/case_insensitive_refs.md b/packages/markdown/marked/test/new/case_insensitive_refs.md new file mode 100644 index 00000000..598915a8 --- /dev/null +++ b/packages/markdown/marked/test/new/case_insensitive_refs.md @@ -0,0 +1,3 @@ +[hi] + +[HI]: /url diff --git a/packages/markdown/marked/test/new/cm_autolinks.html b/packages/markdown/marked/test/new/cm_autolinks.html new file mode 100644 index 00000000..e7ae0ee4 --- /dev/null +++ b/packages/markdown/marked/test/new/cm_autolinks.html @@ -0,0 +1,91 @@ +

    Here are some valid autolinks:

    + +

    Example 565

    + +

    http://foo.bar.baz

    + +

    Example 566

    + +

    http://foo.bar.baz/test?q=hello&id=22&boolean

    + +

    Example 567

    + +

    irc://foo.bar:2233/baz

    + +

    Example 568

    + +

    Uppercase is also fine:

    + +

    MAILTO:FOO@BAR.BAZ

    + +

    Note that many strings that count as absolute URIs for purposes of this spec are not valid URIs, because their schemes are not registered or because of other problems with their syntax:

    + +

    Example 569

    + +

    a+b+c:d

    + +

    Example 570

    + +

    made-up-scheme://foo,bar

    + +

    Example 571

    + +

    http://../

    + +

    Example 572

    + +

    localhost:5001/foo

    + +

    Example 573

    + +

    Spaces are not allowed in autolinks:

    + +

    <http://foo.bar/baz bim>

    + +

    Example 574

    + +

    Backslash-escapes do not work inside autolinks:

    + +

    http://example.com/\[\

    + +

    Examples of email autolinks:

    + +

    Example 575

    + +

    foo@bar.example.com

    + +

    Example 576

    + +

    foo+special@Bar.baz-bar0.com

    + +

    Example 577

    + +

    Backslash-escapes do not work inside email autolinks:

    + +

    <foo+@bar.example.com>

    + +

    These are not autolinks:

    + +

    Example 578

    + +

    <>

    + +

    Example 579

    + +

    < http://foo.bar >

    + +

    Example 580

    + +

    <m:abc>

    + +

    Example 581

    + +

    <foo.bar.baz>

    + +

    Example 582

    + +

    http://example.com

    + +

    Example 583

    + +

    foo@bar.example.com

    \ No newline at end of file diff --git a/packages/markdown/marked/test/new/cm_autolinks.md b/packages/markdown/marked/test/new/cm_autolinks.md new file mode 100644 index 00000000..a19d830c --- /dev/null +++ b/packages/markdown/marked/test/new/cm_autolinks.md @@ -0,0 +1,96 @@ +--- +gfm: false +mangle: false +--- + +Here are some valid autolinks: + +### Example 565 + + + +### Example 566 + + + +### Example 567 + + + +### Example 568 + +Uppercase is also fine: + + + +Note that many strings that count as absolute URIs for purposes of this spec are not valid URIs, because their schemes are not registered or because of other problems with their syntax: + +### Example 569 + + + +### Example 570 + + + +### Example 571 + + + +### Example 572 + + + +### Example 573 + +Spaces are not allowed in autolinks: + + + +### Example 574 + +Backslash-escapes do not work inside autolinks: + + + +Examples of email autolinks: + +### Example 575 + + + +### Example 576 + + + +### Example 577 + +Backslash-escapes do not work inside email autolinks: + + + +These are not autolinks: + +### Example 578 + +<> + +### Example 579 + +< http://foo.bar > + +### Example 580 + + + +### Example 581 + + + +### Example 582 + +http://example.com + +### Example 583 + +foo@bar.example.com \ No newline at end of file diff --git a/packages/markdown/marked/test/new/cm_blockquotes.html b/packages/markdown/marked/test/new/cm_blockquotes.html new file mode 100644 index 00000000..b4d51b1f --- /dev/null +++ b/packages/markdown/marked/test/new/cm_blockquotes.html @@ -0,0 +1,233 @@ +

    Example 191

    + +
    +

    Foo

    +

    bar +baz

    +
    + +

    Example 192

    + +

    The spaces after the > characters can be omitted:

    + +
    +

    Bar

    +

    bar +baz

    +
    + +

    Example 193

    + +

    The > characters can be indented 1-3 spaces:

    + +
    +

    Baz

    +

    bar +baz

    +
    + +

    Example 194

    + +

    Four spaces gives us a code block:

    + +
    > # Qux
    +> bar
    +> baz
    + +

    Example 195

    + +

    The Laziness clause allows us to omit the > before paragraph continuation text:

    + +
    +

    Quux

    +

    bar +baz

    +
    + +

    Example 196

    + +

    A block quote can contain some lazy and some non-lazy continuation lines:

    + +
    +

    bar +baz +foo

    +
    + +

    Example 197

    + +

    Laziness only applies to lines that would have been continuations of paragraphs had they been prepended with block quote markers. For example, the > cannot be omitted in the second line of

    + +
    +

    foo

    +
    +
    + +

    without changing the meaning.

    + +

    Example 198

    + +
    Similarly, if we omit the `>` in the second line then the block quote ends after the first line:
    +
    +> - foo
    +- bar
    + +

    Example 199

    + +

    For the same reason, we can’t omit the > in front of subsequent lines of an indented or fenced code block:

    + +
    +
    foo
    +
    +
    bar
    + +

    Example 200

    + +
    > ```
    +foo
    +```
    +
    +<blockquote>
    +<pre><code></code></pre>
    +</blockquote>
    +<p>foo</p>
    +<pre><code></code></pre>
    + +

    Example 201

    +
    > foo
    +    - bar
    +
    +<blockquote>
    +<p>foo
    +- bar</p>
    +</blockquote>
    + +

    Example 202

    + +

    A block quote can be empty:

    + +
    +
    + +

    Example 203

    + +
    +
    + +

    Example 204

    + +

    A block quote can have initial or final blank lines:

    + +
    +

    foo

    +
    + + +

    Example 205

    + +

    A blank line always separates block quotes:

    + +
    +

    foo

    +
    +
    +

    bar

    +
    + +

    Example 206

    + +

    Consecutiveness means that if we put these block quotes together, we get a single block quote:

    + +
    +

    foo +bar

    +
    + +

    Example 207

    + +

    To get a block quote with two paragraphs, use:

    + +
    +

    foo

    +

    bar

    +
    + +

    Example 208

    + +

    Block quotes can interrupt paragraphs:

    + +

    foo

    +
    +

    bar

    +
    + +

    Example 209

    + +

    In general, blank lines are not needed before or after block quotes:

    + +
    +

    aaa

    +
    +
    +
    +

    bbb

    +
    + +

    Example 210

    + +

    However, because of laziness, a blank line is needed between a block quote and a following paragraph:

    + +
    +

    bar +baz

    +
    + +

    Example 211

    + +
    +

    bar

    +
    +

    baz

    + +

    Example 212

    + +
    +

    bar

    +
    +

    baz

    + +

    Example 213

    + +

    It is a consequence of the Laziness rule that any number of initial >s may be omitted on a continuation line of a nested block quote:

    + +
    +
    +
    +

    foo +bar

    +
    +
    +
    + +

    Example 214

    + +
    +
    +
    +

    foo +bar +baz

    +
    +
    +
    + +

    Example 215

    + +

    When including an indented code block in a block quote, remember that the block quote marker includes both the > and a following space. So five spaces are needed after the >:

    + +
    +
    code
    +
    +
    +

    not code

    +
    diff --git a/packages/markdown/marked/test/new/cm_blockquotes.md b/packages/markdown/marked/test/new/cm_blockquotes.md new file mode 100644 index 00000000..6a80a6f3 --- /dev/null +++ b/packages/markdown/marked/test/new/cm_blockquotes.md @@ -0,0 +1,189 @@ +### Example 191 + +> # Foo +> bar +> baz + +### Example 192 + +The spaces after the `>` characters can be omitted: + +># Bar +>bar +> baz + +### Example 193 + +The `>` characters can be indented 1-3 spaces: + + > # Baz + > bar + > baz + +### Example 194 + +Four spaces gives us a code block: + + > # Qux + > bar + > baz + +### Example 195 + +The Laziness clause allows us to omit the `>` before paragraph continuation text: + +> # Quux +> bar +baz + +### Example 196 + +A block quote can contain some lazy and some non-lazy continuation lines: + +> bar +baz +> foo + +### Example 197 + +Laziness only applies to lines that would have been continuations of paragraphs had they been prepended with block quote markers. For example, the `>` cannot be omitted in the second line of + +> foo +--- + +without changing the meaning. + +### Example 198 + + Similarly, if we omit the `>` in the second line then the block quote ends after the first line: + + > - foo + - bar + +### Example 199 + +For the same reason, we can’t omit the `>` in front of subsequent lines of an indented or fenced code block: + +> foo + + bar + +### Example 200 + + > ``` + foo + ``` + +
    +
    +
    +

    foo

    +
    + +### Example 201 + + > foo + - bar + +
    +

    foo + - bar

    +
    + +### Example 202 + +A block quote can be empty: + +> + +### Example 203 + +> +> +> + +### Example 204 + +A block quote can have initial or final blank lines: + +> +> foo +> + +### Example 205 + +A blank line always separates block quotes: + +> foo + +> bar + +### Example 206 + +Consecutiveness means that if we put these block quotes together, we get a single block quote: + +> foo +> bar + +### Example 207 + +To get a block quote with two paragraphs, use: + +> foo +> +> bar + +### Example 208 + +Block quotes can interrupt paragraphs: + +foo +> bar + +### Example 209 + +In general, blank lines are not needed before or after block quotes: + +> aaa +*** +> bbb + +### Example 210 + +However, because of laziness, a blank line is needed between a block quote and a following paragraph: + +> bar +baz + +### Example 211 + +> bar + +baz + +### Example 212 + +> bar +> +baz + +### Example 213 + +It is a consequence of the Laziness rule that any number of initial `>`s may be omitted on a continuation line of a nested block quote: + +> > > foo +bar + +### Example 214 + +>>> foo +> bar +>>baz + +### Example 215 + +When including an indented code block in a block quote, remember that the block quote marker includes both the `>` and a following space. So five spaces are needed after the `>`: + +> code + +> not code diff --git a/packages/markdown/marked/test/new/cm_html_blocks.html b/packages/markdown/marked/test/new/cm_html_blocks.html new file mode 100644 index 00000000..80fdff57 --- /dev/null +++ b/packages/markdown/marked/test/new/cm_html_blocks.html @@ -0,0 +1,300 @@ +

    HTML blocks

    + +

    Example 116

    + +
    +
    +**Hello**,
    +

    world. +

    +
    + +

    Example 117

    + + + + + +
    + hi +
    +

    okay.

    + +

    Example 118

    + + +*foo* + +

    Example 120

    + +
    +

    Markdown

    +
    + +

    Example 121

    + +
    +
    + +

    Example 122

    + +
    +
    + +

    Example 123

    + +
    +*foo* +

    bar

    + +

    Example 124

    + +
    Example 125

    + +
    Example 126 + +
    Example 127 + +
    *foo*
    + +

    Example 128

    + +
    +foo +
    + +

    Example 129

    + +
    +``` c +int x = 33; +``` + +

    Example 130

    + + +*bar* + + +

    Example 131

    + + +*bar* + + +

    Example 132

    + + +*bar* + + +

    Example 133

    + + +*bar* + +

    Example 134

    + + +*foo* + + +

    Example 135

    + + +

    foo

    +
    + +

    Example 136

    + +

    foo

    + +

    Example 137

    + +
    
    +import Text.HTML.TagSoup
    +
    +main :: IO ()
    +main = print $ parseTags tags
    +
    +

    okay

    + +

    Example 138

    + + +

    okay

    + +

    Example 139

    + + +

    okay

    + +

    Example 141

    + +
    +
    +foo +
    +

    bar

    + +

    Example 142

    + +
      +
    • +
      +
    • +
    • foo
    • +
    + +

    Example 143

    + + +

    foo

    + +

    Example 144

    + +*bar* +

    baz

    + +

    Example 145

    + +1. *bar* + +

    Example 146

    + + +

    okay

    + +

    Example 147

    + +'; + +?> +

    okay

    + +

    Example 148

    + + + +

    Example 149

    + + +

    okay

    + +

    Example 150

    + + +
    <!-- foo -->
    +
    + +

    Example 151

    + +
    +
    <div>
    +
    + +

    Example 152

    + +

    Foo

    +
    +bar +
    + +

    Example 153

    + +
    +bar +
    +*foo* + +

    Example 154

    + +

    Foo + +baz

    + +

    Example 155

    + +
    +

    Emphasized text.

    +
    + +

    Example 156

    + +
    +*Emphasized* text. +
    + +

    Example 157

    + + + + + +
    +Hi +
    + +

    Example 158

    + + + +
    <td>
    +  Hi
    +</td>
    +
    + +
    + +

    Example 140

    + +

    If there is no matching end tag, the block will end at the end of the document (or the enclosing block quote or list item):

    + + +okay + +### Example 141 + +>
    +> foo + +bar + +### Example 142 + +-
    +- foo + +### Example 143 + + +*foo* + +### Example 144 + +*bar* +*baz* + +### Example 145 + +1. *bar* + +### Example 146 + + +okay + +### Example 147 + +'; + +?> +okay + +### Example 148 + + + +### Example 149 + + +okay + +### Example 150 + + + + + +### Example 151 + +
    + +
    + +### Example 152 + +Foo +
    +bar +
    + +### Example 153 + +
    +bar +
    +*foo* + +### Example 154 + +Foo +
    +baz + +### Example 155 + +
    + +*Emphasized* text. + +
    + +### Example 156 + +
    +*Emphasized* text. +
    + +### Example 157 + + + + + + + + + +
    +Hi +
    + +### Example 158 + + + + + + + + + +
    + Hi +
    + +### Example 140 + +If there is no matching end tag, the block will end at the end of the document (or the enclosing block quote or list item): + +\nokay\n", + "html": "\nh1 {color:red;}\n\np {color:blue;}\n\n

    okay

    \n", + "example": 141, + "start_line": 2430, + "end_line": 2446, + "section": "HTML blocks" + }, + { + "markdown": "\n\nfoo\n", + "html": "\n\nfoo\n", + "example": 142, + "start_line": 2453, + "end_line": 2463, + "section": "HTML blocks" + }, + { + "markdown": ">
    \n> foo\n\nbar\n", + "html": "
    \n
    \nfoo\n
    \n

    bar

    \n", + "example": 143, + "start_line": 2466, + "end_line": 2477, + "section": "HTML blocks" + }, + { + "markdown": "-
    \n- foo\n", + "html": "
      \n
    • \n
      \n
    • \n
    • foo
    • \n
    \n", + "example": 144, + "start_line": 2480, + "end_line": 2490, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n", + "html": "\n

    foo

    \n", + "example": 145, + "start_line": 2495, + "end_line": 2501, + "section": "HTML blocks" + }, + { + "markdown": "*bar*\n*baz*\n", + "html": "*bar*\n

    baz

    \n", + "example": 146, + "start_line": 2504, + "end_line": 2510, + "section": "HTML blocks" + }, + { + "markdown": "1. *bar*\n", + "html": "1. *bar*\n", + "example": 147, + "start_line": 2516, + "end_line": 2524, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

    okay

    \n", + "example": 148, + "start_line": 2529, + "end_line": 2541, + "section": "HTML blocks" + }, + { + "markdown": "';\n\n?>\nokay\n", + "html": "';\n\n?>\n

    okay

    \n", + "example": 149, + "start_line": 2547, + "end_line": 2561, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 150, + "start_line": 2566, + "end_line": 2570, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

    okay

    \n", + "example": 151, + "start_line": 2575, + "end_line": 2603, + "section": "HTML blocks" + }, + { + "markdown": " \n\n \n", + "html": " \n
    <!-- foo -->\n
    \n", + "example": 152, + "start_line": 2608, + "end_line": 2616, + "section": "HTML blocks" + }, + { + "markdown": "
    \n\n
    \n", + "html": "
    \n
    <div>\n
    \n", + "example": 153, + "start_line": 2619, + "end_line": 2627, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n
    \nbar\n
    \n", + "html": "

    Foo

    \n
    \nbar\n
    \n", + "example": 154, + "start_line": 2633, + "end_line": 2643, + "section": "HTML blocks" + }, + { + "markdown": "
    \nbar\n
    \n*foo*\n", + "html": "
    \nbar\n
    \n*foo*\n", + "example": 155, + "start_line": 2650, + "end_line": 2660, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n
    \nbaz\n", + "html": "

    Foo\n\nbaz

    \n", + "example": 156, + "start_line": 2665, + "end_line": 2673, + "section": "HTML blocks" + }, + { + "markdown": "
    \n\n*Emphasized* text.\n\n
    \n", + "html": "
    \n

    Emphasized text.

    \n
    \n", + "example": 157, + "start_line": 2706, + "end_line": 2716, + "section": "HTML blocks" + }, + { + "markdown": "
    \n*Emphasized* text.\n
    \n", + "html": "
    \n*Emphasized* text.\n
    \n", + "example": 158, + "start_line": 2719, + "end_line": 2727, + "section": "HTML blocks" + }, + { + "markdown": "\n\n\n\n\n\n\n\n
    \nHi\n
    \n", + "html": "\n\n\n\n
    \nHi\n
    \n", + "example": 159, + "start_line": 2741, + "end_line": 2761, + "section": "HTML blocks" + }, + { + "markdown": "\n\n \n\n \n\n \n\n
    \n Hi\n
    \n", + "html": "\n \n
    <td>\n  Hi\n</td>\n
    \n \n
    \n", + "example": 160, + "start_line": 2768, + "end_line": 2789, + "section": "HTML blocks" + }, + { + "markdown": "[foo]: /url \"title\"\n\n[foo]\n", + "html": "

    foo

    \n", + "example": 161, + "start_line": 2816, + "end_line": 2822, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: \n /url \n 'the title' \n\n[foo]\n", + "html": "

    foo

    \n", + "example": 162, + "start_line": 2825, + "end_line": 2833, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n", + "html": "

    Foo*bar]

    \n", + "example": 163, + "start_line": 2836, + "end_line": 2842, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo bar]:\n\n'title'\n\n[Foo bar]\n", + "html": "

    Foo bar

    \n", + "example": 164, + "start_line": 2845, + "end_line": 2853, + "section": "Link reference definitions", + "shouldFail": true + }, + { + "markdown": "[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n", + "html": "

    foo

    \n", + "example": 165, + "start_line": 2858, + "end_line": 2872, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n", + "html": "

    [foo]: /url 'title

    \n

    with blank line'

    \n

    [foo]

    \n", + "example": 166, + "start_line": 2877, + "end_line": 2887, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n/url\n\n[foo]\n", + "html": "

    foo

    \n", + "example": 167, + "start_line": 2892, + "end_line": 2899, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n\n[foo]\n", + "html": "

    [foo]:

    \n

    [foo]

    \n", + "example": 168, + "start_line": 2904, + "end_line": 2911, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: <>\n\n[foo]\n", + "html": "

    foo

    \n", + "example": 169, + "start_line": 2916, + "end_line": 2922, + "section": "Link reference definitions", + "shouldFail": true + }, + { + "markdown": "[foo]: (baz)\n\n[foo]\n", + "html": "

    [foo]: (baz)

    \n

    [foo]

    \n", + "example": 170, + "start_line": 2927, + "end_line": 2934, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n", + "html": "

    foo

    \n", + "example": 171, + "start_line": 2940, + "end_line": 2946, + "section": "Link reference definitions", + "shouldFail": true + }, + { + "markdown": "[foo]\n\n[foo]: url\n", + "html": "

    foo

    \n", + "example": 172, + "start_line": 2951, + "end_line": 2957, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: first\n[foo]: second\n", + "html": "

    foo

    \n", + "example": 173, + "start_line": 2963, + "end_line": 2970, + "section": "Link reference definitions" + }, + { + "markdown": "[FOO]: /url\n\n[Foo]\n", + "html": "

    Foo

    \n", + "example": 174, + "start_line": 2976, + "end_line": 2982, + "section": "Link reference definitions" + }, + { + "markdown": "[ΑΓΩ]: /φου\n\n[αγω]\n", + "html": "

    αγω

    \n", + "example": 175, + "start_line": 2985, + "end_line": 2991, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n", + "html": "", + "example": 176, + "start_line": 2997, + "end_line": 3000, + "section": "Link reference definitions" + }, + { + "markdown": "[\nfoo\n]: /url\nbar\n", + "html": "

    bar

    \n", + "example": 177, + "start_line": 3005, + "end_line": 3012, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url \"title\" ok\n", + "html": "

    [foo]: /url "title" ok

    \n", + "example": 178, + "start_line": 3018, + "end_line": 3022, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n\"title\" ok\n", + "html": "

    "title" ok

    \n", + "example": 179, + "start_line": 3027, + "end_line": 3032, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: /url \"title\"\n\n[foo]\n", + "html": "
    [foo]: /url "title"\n
    \n

    [foo]

    \n", + "example": 180, + "start_line": 3038, + "end_line": 3046, + "section": "Link reference definitions" + }, + { + "markdown": "```\n[foo]: /url\n```\n\n[foo]\n", + "html": "
    [foo]: /url\n
    \n

    [foo]

    \n", + "example": 181, + "start_line": 3052, + "end_line": 3062, + "section": "Link reference definitions" + }, + { + "markdown": "Foo\n[bar]: /baz\n\n[bar]\n", + "html": "

    Foo\n[bar]: /baz

    \n

    [bar]

    \n", + "example": 182, + "start_line": 3067, + "end_line": 3076, + "section": "Link reference definitions" + }, + { + "markdown": "# [Foo]\n[foo]: /url\n> bar\n", + "html": "

    Foo

    \n
    \n

    bar

    \n
    \n", + "example": 183, + "start_line": 3082, + "end_line": 3091, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\nbar\n===\n[foo]\n", + "html": "

    bar

    \n

    foo

    \n", + "example": 184, + "start_line": 3093, + "end_line": 3101, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n===\n[foo]\n", + "html": "

    ===\nfoo

    \n", + "example": 185, + "start_line": 3103, + "end_line": 3110, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n", + "html": "

    foo,\nbar,\nbaz

    \n", + "example": 186, + "start_line": 3116, + "end_line": 3129, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n> [foo]: /url\n", + "html": "

    foo

    \n
    \n
    \n", + "example": 187, + "start_line": 3137, + "end_line": 3145, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n", + "html": "", + "example": 188, + "start_line": 3154, + "end_line": 3157, + "section": "Link reference definitions" + }, + { + "markdown": "aaa\n\nbbb\n", + "html": "

    aaa

    \n

    bbb

    \n", + "example": 189, + "start_line": 3171, + "end_line": 3178, + "section": "Paragraphs" + }, + { + "markdown": "aaa\nbbb\n\nccc\nddd\n", + "html": "

    aaa\nbbb

    \n

    ccc\nddd

    \n", + "example": 190, + "start_line": 3183, + "end_line": 3194, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n\n\nbbb\n", + "html": "

    aaa

    \n

    bbb

    \n", + "example": 191, + "start_line": 3199, + "end_line": 3207, + "section": "Paragraphs" + }, + { + "markdown": " aaa\n bbb\n", + "html": "

    aaa\nbbb

    \n", + "example": 192, + "start_line": 3212, + "end_line": 3218, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n bbb\n ccc\n", + "html": "

    aaa\nbbb\nccc

    \n", + "example": 193, + "start_line": 3224, + "end_line": 3232, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "

    aaa\nbbb

    \n", + "example": 194, + "start_line": 3238, + "end_line": 3244, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "
    aaa\n
    \n

    bbb

    \n", + "example": 195, + "start_line": 3247, + "end_line": 3254, + "section": "Paragraphs" + }, + { + "markdown": "aaa \nbbb \n", + "html": "

    aaa
    \nbbb

    \n", + "example": 196, + "start_line": 3261, + "end_line": 3267, + "section": "Paragraphs" + }, + { + "markdown": " \n\naaa\n \n\n# aaa\n\n \n", + "html": "

    aaa

    \n

    aaa

    \n", + "example": 197, + "start_line": 3278, + "end_line": 3290, + "section": "Blank lines" + }, + { + "markdown": "> # Foo\n> bar\n> baz\n", + "html": "
    \n

    Foo

    \n

    bar\nbaz

    \n
    \n", + "example": 198, + "start_line": 3344, + "end_line": 3354, + "section": "Block quotes" + }, + { + "markdown": "># Foo\n>bar\n> baz\n", + "html": "
    \n

    Foo

    \n

    bar\nbaz

    \n
    \n", + "example": 199, + "start_line": 3359, + "end_line": 3369, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
    \n

    Foo

    \n

    bar\nbaz

    \n
    \n", + "example": 200, + "start_line": 3374, + "end_line": 3384, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
    > # Foo\n> bar\n> baz\n
    \n", + "example": 201, + "start_line": 3389, + "end_line": 3398, + "section": "Block quotes" + }, + { + "markdown": "> # Foo\n> bar\nbaz\n", + "html": "
    \n

    Foo

    \n

    bar\nbaz

    \n
    \n", + "example": 202, + "start_line": 3404, + "end_line": 3414, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n> foo\n", + "html": "
    \n

    bar\nbaz\nfoo

    \n
    \n", + "example": 203, + "start_line": 3420, + "end_line": 3430, + "section": "Block quotes" + }, + { + "markdown": "> foo\n---\n", + "html": "
    \n

    foo

    \n
    \n
    \n", + "example": 204, + "start_line": 3444, + "end_line": 3452, + "section": "Block quotes" + }, + { + "markdown": "> - foo\n- bar\n", + "html": "
    \n
      \n
    • foo
    • \n
    \n
    \n
      \n
    • bar
    • \n
    \n", + "example": 205, + "start_line": 3464, + "end_line": 3476, + "section": "Block quotes", + "shouldFail": true + }, + { + "markdown": "> foo\n bar\n", + "html": "
    \n
    foo\n
    \n
    \n
    bar\n
    \n", + "example": 206, + "start_line": 3482, + "end_line": 3492, + "section": "Block quotes", + "shouldFail": true + }, + { + "markdown": "> ```\nfoo\n```\n", + "html": "
    \n
    \n
    \n

    foo

    \n
    \n", + "example": 207, + "start_line": 3495, + "end_line": 3505, + "section": "Block quotes", + "shouldFail": true + }, + { + "markdown": "> foo\n - bar\n", + "html": "
    \n

    foo\n- bar

    \n
    \n", + "example": 208, + "start_line": 3511, + "end_line": 3519, + "section": "Block quotes" + }, + { + "markdown": ">\n", + "html": "
    \n
    \n", + "example": 209, + "start_line": 3535, + "end_line": 3540, + "section": "Block quotes" + }, + { + "markdown": ">\n> \n> \n", + "html": "
    \n
    \n", + "example": 210, + "start_line": 3543, + "end_line": 3550, + "section": "Block quotes" + }, + { + "markdown": ">\n> foo\n> \n", + "html": "
    \n

    foo

    \n
    \n", + "example": 211, + "start_line": 3555, + "end_line": 3563, + "section": "Block quotes" + }, + { + "markdown": "> foo\n\n> bar\n", + "html": "
    \n

    foo

    \n
    \n
    \n

    bar

    \n
    \n", + "example": 212, + "start_line": 3568, + "end_line": 3579, + "section": "Block quotes" + }, + { + "markdown": "> foo\n> bar\n", + "html": "
    \n

    foo\nbar

    \n
    \n", + "example": 213, + "start_line": 3590, + "end_line": 3598, + "section": "Block quotes" + }, + { + "markdown": "> foo\n>\n> bar\n", + "html": "
    \n

    foo

    \n

    bar

    \n
    \n", + "example": 214, + "start_line": 3603, + "end_line": 3612, + "section": "Block quotes" + }, + { + "markdown": "foo\n> bar\n", + "html": "

    foo

    \n
    \n

    bar

    \n
    \n", + "example": 215, + "start_line": 3617, + "end_line": 3625, + "section": "Block quotes" + }, + { + "markdown": "> aaa\n***\n> bbb\n", + "html": "
    \n

    aaa

    \n
    \n
    \n
    \n

    bbb

    \n
    \n", + "example": 216, + "start_line": 3631, + "end_line": 3643, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n", + "html": "
    \n

    bar\nbaz

    \n
    \n", + "example": 217, + "start_line": 3649, + "end_line": 3657, + "section": "Block quotes" + }, + { + "markdown": "> bar\n\nbaz\n", + "html": "
    \n

    bar

    \n
    \n

    baz

    \n", + "example": 218, + "start_line": 3660, + "end_line": 3669, + "section": "Block quotes" + }, + { + "markdown": "> bar\n>\nbaz\n", + "html": "
    \n

    bar

    \n
    \n

    baz

    \n", + "example": 219, + "start_line": 3672, + "end_line": 3681, + "section": "Block quotes" + }, + { + "markdown": "> > > foo\nbar\n", + "html": "
    \n
    \n
    \n

    foo\nbar

    \n
    \n
    \n
    \n", + "example": 220, + "start_line": 3688, + "end_line": 3700, + "section": "Block quotes" + }, + { + "markdown": ">>> foo\n> bar\n>>baz\n", + "html": "
    \n
    \n
    \n

    foo\nbar\nbaz

    \n
    \n
    \n
    \n", + "example": 221, + "start_line": 3703, + "end_line": 3717, + "section": "Block quotes" + }, + { + "markdown": "> code\n\n> not code\n", + "html": "
    \n
    code\n
    \n
    \n
    \n

    not code

    \n
    \n", + "example": 222, + "start_line": 3725, + "end_line": 3737, + "section": "Block quotes" + }, + { + "markdown": "A paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n", + "html": "

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n", + "example": 223, + "start_line": 3779, + "end_line": 3794, + "section": "List items" + }, + { + "markdown": "1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
      \n
    1. \n

      A paragraph\nwith two lines.

      \n
      indented code\n
      \n
      \n

      A block quote.

      \n
      \n
    2. \n
    \n", + "example": 224, + "start_line": 3801, + "end_line": 3820, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
      \n
    • one
    • \n
    \n

    two

    \n", + "example": 225, + "start_line": 3834, + "end_line": 3843, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "- one\n\n two\n", + "html": "
      \n
    • \n

      one

      \n

      two

      \n
    • \n
    \n", + "example": 226, + "start_line": 3846, + "end_line": 3857, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
      \n
    • one
    • \n
    \n
     two\n
    \n", + "example": 227, + "start_line": 3860, + "end_line": 3870, + "section": "List items", + "shouldFail": true + }, + { + "markdown": " - one\n\n two\n", + "html": "
      \n
    • \n

      one

      \n

      two

      \n
    • \n
    \n", + "example": 228, + "start_line": 3873, + "end_line": 3884, + "section": "List items" + }, + { + "markdown": " > > 1. one\n>>\n>> two\n", + "html": "
    \n
    \n
      \n
    1. \n

      one

      \n

      two

      \n
    2. \n
    \n
    \n
    \n", + "example": 229, + "start_line": 3895, + "end_line": 3910, + "section": "List items" + }, + { + "markdown": ">>- one\n>>\n > > two\n", + "html": "
    \n
    \n
      \n
    • one
    • \n
    \n

    two

    \n
    \n
    \n", + "example": 230, + "start_line": 3922, + "end_line": 3935, + "section": "List items" + }, + { + "markdown": "-one\n\n2.two\n", + "html": "

    -one

    \n

    2.two

    \n", + "example": 231, + "start_line": 3941, + "end_line": 3948, + "section": "List items" + }, + { + "markdown": "- foo\n\n\n bar\n", + "html": "
      \n
    • \n

      foo

      \n

      bar

      \n
    • \n
    \n", + "example": 232, + "start_line": 3954, + "end_line": 3966, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n", + "html": "
      \n
    1. \n

      foo

      \n
      bar\n
      \n

      baz

      \n
      \n

      bam

      \n
      \n
    2. \n
    \n", + "example": 233, + "start_line": 3971, + "end_line": 3993, + "section": "List items" + }, + { + "markdown": "- Foo\n\n bar\n\n\n baz\n", + "html": "
      \n
    • \n

      Foo

      \n
      bar\n\n\nbaz\n
      \n
    • \n
    \n", + "example": 234, + "start_line": 3999, + "end_line": 4017, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "123456789. ok\n", + "html": "
      \n
    1. ok
    2. \n
    \n", + "example": 235, + "start_line": 4021, + "end_line": 4027, + "section": "List items" + }, + { + "markdown": "1234567890. not ok\n", + "html": "

    1234567890. not ok

    \n", + "example": 236, + "start_line": 4030, + "end_line": 4034, + "section": "List items" + }, + { + "markdown": "0. ok\n", + "html": "
      \n
    1. ok
    2. \n
    \n", + "example": 237, + "start_line": 4039, + "end_line": 4045, + "section": "List items" + }, + { + "markdown": "003. ok\n", + "html": "
      \n
    1. ok
    2. \n
    \n", + "example": 238, + "start_line": 4048, + "end_line": 4054, + "section": "List items" + }, + { + "markdown": "-1. not ok\n", + "html": "

    -1. not ok

    \n", + "example": 239, + "start_line": 4059, + "end_line": 4063, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
      \n
    • \n

      foo

      \n
      bar\n
      \n
    • \n
    \n", + "example": 240, + "start_line": 4082, + "end_line": 4094, + "section": "List items" + }, + { + "markdown": " 10. foo\n\n bar\n", + "html": "
      \n
    1. \n

      foo

      \n
      bar\n
      \n
    2. \n
    \n", + "example": 241, + "start_line": 4099, + "end_line": 4111, + "section": "List items" + }, + { + "markdown": " indented code\n\nparagraph\n\n more code\n", + "html": "
    indented code\n
    \n

    paragraph

    \n
    more code\n
    \n", + "example": 242, + "start_line": 4118, + "end_line": 4130, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
      \n
    1. \n
      indented code\n
      \n

      paragraph

      \n
      more code\n
      \n
    2. \n
    \n", + "example": 243, + "start_line": 4133, + "end_line": 4149, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
      \n
    1. \n
       indented code\n
      \n

      paragraph

      \n
      more code\n
      \n
    2. \n
    \n", + "example": 244, + "start_line": 4155, + "end_line": 4171, + "section": "List items", + "shouldFail": true + }, + { + "markdown": " foo\n\nbar\n", + "html": "

    foo

    \n

    bar

    \n", + "example": 245, + "start_line": 4182, + "end_line": 4189, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
      \n
    • foo
    • \n
    \n

    bar

    \n", + "example": 246, + "start_line": 4192, + "end_line": 4201, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
      \n
    • \n

      foo

      \n

      bar

      \n
    • \n
    \n", + "example": 247, + "start_line": 4209, + "end_line": 4220, + "section": "List items" + }, + { + "markdown": "-\n foo\n-\n ```\n bar\n ```\n-\n baz\n", + "html": "
      \n
    • foo
    • \n
    • \n
      bar\n
      \n
    • \n
    • \n
      baz\n
      \n
    • \n
    \n", + "example": 248, + "start_line": 4237, + "end_line": 4258, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "- \n foo\n", + "html": "
      \n
    • foo
    • \n
    \n", + "example": 249, + "start_line": 4263, + "end_line": 4270, + "section": "List items" + }, + { + "markdown": "-\n\n foo\n", + "html": "
      \n
    • \n
    \n

    foo

    \n", + "example": 250, + "start_line": 4277, + "end_line": 4286, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "- foo\n-\n- bar\n", + "html": "
      \n
    • foo
    • \n
    • \n
    • bar
    • \n
    \n", + "example": 251, + "start_line": 4291, + "end_line": 4301, + "section": "List items" + }, + { + "markdown": "- foo\n- \n- bar\n", + "html": "
      \n
    • foo
    • \n
    • \n
    • bar
    • \n
    \n", + "example": 252, + "start_line": 4306, + "end_line": 4316, + "section": "List items" + }, + { + "markdown": "1. foo\n2.\n3. bar\n", + "html": "
      \n
    1. foo
    2. \n
    3. \n
    4. bar
    5. \n
    \n", + "example": 253, + "start_line": 4321, + "end_line": 4331, + "section": "List items" + }, + { + "markdown": "*\n", + "html": "
      \n
    • \n
    \n", + "example": 254, + "start_line": 4336, + "end_line": 4342, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "foo\n*\n\nfoo\n1.\n", + "html": "

    foo\n*

    \n

    foo\n1.

    \n", + "example": 255, + "start_line": 4346, + "end_line": 4357, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
      \n
    1. \n

      A paragraph\nwith two lines.

      \n
      indented code\n
      \n
      \n

      A block quote.

      \n
      \n
    2. \n
    \n", + "example": 256, + "start_line": 4368, + "end_line": 4387, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
      \n
    1. \n

      A paragraph\nwith two lines.

      \n
      indented code\n
      \n
      \n

      A block quote.

      \n
      \n
    2. \n
    \n", + "example": 257, + "start_line": 4392, + "end_line": 4411, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
      \n
    1. \n

      A paragraph\nwith two lines.

      \n
      indented code\n
      \n
      \n

      A block quote.

      \n
      \n
    2. \n
    \n", + "example": 258, + "start_line": 4416, + "end_line": 4435, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
    \n", + "example": 259, + "start_line": 4440, + "end_line": 4455, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
      \n
    1. \n

      A paragraph\nwith two lines.

      \n
      indented code\n
      \n
      \n

      A block quote.

      \n
      \n
    2. \n
    \n", + "example": 260, + "start_line": 4470, + "end_line": 4489, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n", + "html": "
      \n
    1. A paragraph\nwith two lines.
    2. \n
    \n", + "example": 261, + "start_line": 4494, + "end_line": 4502, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\ncontinued here.\n", + "html": "
    \n
      \n
    1. \n
      \n

      Blockquote\ncontinued here.

      \n
      \n
    2. \n
    \n
    \n", + "example": 262, + "start_line": 4507, + "end_line": 4521, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\n> continued here.\n", + "html": "
    \n
      \n
    1. \n
      \n

      Blockquote\ncontinued here.

      \n
      \n
    2. \n
    \n
    \n", + "example": 263, + "start_line": 4524, + "end_line": 4538, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
      \n
    • foo\n
        \n
      • bar\n
          \n
        • baz\n
            \n
          • boo
          • \n
          \n
        • \n
        \n
      • \n
      \n
    • \n
    \n", + "example": 264, + "start_line": 4552, + "end_line": 4573, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
      \n
    • foo
    • \n
    • bar
    • \n
    • baz
    • \n
    • boo
    • \n
    \n", + "example": 265, + "start_line": 4578, + "end_line": 4590, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
      \n
    1. foo\n
        \n
      • bar
      • \n
      \n
    2. \n
    \n", + "example": 266, + "start_line": 4595, + "end_line": 4606, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
      \n
    1. foo
    2. \n
    \n
      \n
    • bar
    • \n
    \n", + "example": 267, + "start_line": 4611, + "end_line": 4621, + "section": "List items", + "shouldFail": true + }, + { + "markdown": "- - foo\n", + "html": "
      \n
    • \n
        \n
      • foo
      • \n
      \n
    • \n
    \n", + "example": 268, + "start_line": 4626, + "end_line": 4636, + "section": "List items" + }, + { + "markdown": "1. - 2. foo\n", + "html": "
      \n
    1. \n
        \n
      • \n
          \n
        1. foo
        2. \n
        \n
      • \n
      \n
    2. \n
    \n", + "example": 269, + "start_line": 4639, + "end_line": 4653, + "section": "List items" + }, + { + "markdown": "- # Foo\n- Bar\n ---\n baz\n", + "html": "
      \n
    • \n

      Foo

      \n
    • \n
    • \n

      Bar

      \nbaz
    • \n
    \n", + "example": 270, + "start_line": 4658, + "end_line": 4672, + "section": "List items" + }, + { + "markdown": "- foo\n- bar\n+ baz\n", + "html": "
      \n
    • foo
    • \n
    • bar
    • \n
    \n
      \n
    • baz
    • \n
    \n", + "example": 271, + "start_line": 4894, + "end_line": 4906, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "1. foo\n2. bar\n3) baz\n", + "html": "
      \n
    1. foo
    2. \n
    3. bar
    4. \n
    \n
      \n
    1. baz
    2. \n
    \n", + "example": 272, + "start_line": 4909, + "end_line": 4921, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "Foo\n- bar\n- baz\n", + "html": "

    Foo

    \n
      \n
    • bar
    • \n
    • baz
    • \n
    \n", + "example": 273, + "start_line": 4928, + "end_line": 4938, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n14. The number of doors is 6.\n", + "html": "

    The number of windows in my house is\n14. The number of doors is 6.

    \n", + "example": 274, + "start_line": 5005, + "end_line": 5011, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "The number of windows in my house is\n1. The number of doors is 6.\n", + "html": "

    The number of windows in my house is

    \n
      \n
    1. The number of doors is 6.
    2. \n
    \n", + "example": 275, + "start_line": 5015, + "end_line": 5023, + "section": "Lists" + }, + { + "markdown": "- foo\n\n- bar\n\n\n- baz\n", + "html": "
      \n
    • \n

      foo

      \n
    • \n
    • \n

      bar

      \n
    • \n
    • \n

      baz

      \n
    • \n
    \n", + "example": 276, + "start_line": 5029, + "end_line": 5048, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "- foo\n - bar\n - baz\n\n\n bim\n", + "html": "
      \n
    • foo\n
        \n
      • bar\n
          \n
        • \n

          baz

          \n

          bim

          \n
        • \n
        \n
      • \n
      \n
    • \n
    \n", + "example": 277, + "start_line": 5050, + "end_line": 5072, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "- foo\n- bar\n\n\n\n- baz\n- bim\n", + "html": "
      \n
    • foo
    • \n
    • bar
    • \n
    \n\n
      \n
    • baz
    • \n
    • bim
    • \n
    \n", + "example": 278, + "start_line": 5080, + "end_line": 5098, + "section": "Lists" + }, + { + "markdown": "- foo\n\n notcode\n\n- foo\n\n\n\n code\n", + "html": "
      \n
    • \n

      foo

      \n

      notcode

      \n
    • \n
    • \n

      foo

      \n
    • \n
    \n\n
    code\n
    \n", + "example": 279, + "start_line": 5101, + "end_line": 5124, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n - f\n- g\n", + "html": "
      \n
    • a
    • \n
    • b
    • \n
    • c
    • \n
    • d
    • \n
    • e
    • \n
    • f
    • \n
    • g
    • \n
    \n", + "example": 280, + "start_line": 5132, + "end_line": 5150, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
      \n
    1. \n

      a

      \n
    2. \n
    3. \n

      b

      \n
    4. \n
    5. \n

      c

      \n
    6. \n
    \n", + "example": 281, + "start_line": 5153, + "end_line": 5171, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n", + "html": "
      \n
    • a
    • \n
    • b
    • \n
    • c
    • \n
    • d\n- e
    • \n
    \n", + "example": 282, + "start_line": 5177, + "end_line": 5191, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
      \n
    1. \n

      a

      \n
    2. \n
    3. \n

      b

      \n
    4. \n
    \n
    3. c\n
    \n", + "example": 283, + "start_line": 5197, + "end_line": 5214, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "- a\n- b\n\n- c\n", + "html": "
      \n
    • \n

      a

      \n
    • \n
    • \n

      b

      \n
    • \n
    • \n

      c

      \n
    • \n
    \n", + "example": 284, + "start_line": 5220, + "end_line": 5237, + "section": "Lists" + }, + { + "markdown": "* a\n*\n\n* c\n", + "html": "
      \n
    • \n

      a

      \n
    • \n
    • \n
    • \n

      c

      \n
    • \n
    \n", + "example": 285, + "start_line": 5242, + "end_line": 5257, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n c\n- d\n", + "html": "
      \n
    • \n

      a

      \n
    • \n
    • \n

      b

      \n

      c

      \n
    • \n
    • \n

      d

      \n
    • \n
    \n", + "example": 286, + "start_line": 5264, + "end_line": 5283, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n [ref]: /url\n- d\n", + "html": "
      \n
    • \n

      a

      \n
    • \n
    • \n

      b

      \n
    • \n
    • \n

      d

      \n
    • \n
    \n", + "example": 287, + "start_line": 5286, + "end_line": 5304, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "- a\n- ```\n b\n\n\n ```\n- c\n", + "html": "
      \n
    • a
    • \n
    • \n
      b\n\n\n
      \n
    • \n
    • c
    • \n
    \n", + "example": 288, + "start_line": 5309, + "end_line": 5328, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "- a\n - b\n\n c\n- d\n", + "html": "
      \n
    • a\n
        \n
      • \n

        b

        \n

        c

        \n
      • \n
      \n
    • \n
    • d
    • \n
    \n", + "example": 289, + "start_line": 5335, + "end_line": 5353, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "* a\n > b\n >\n* c\n", + "html": "
      \n
    • a\n
      \n

      b

      \n
      \n
    • \n
    • c
    • \n
    \n", + "example": 290, + "start_line": 5359, + "end_line": 5373, + "section": "Lists" + }, + { + "markdown": "- a\n > b\n ```\n c\n ```\n- d\n", + "html": "
      \n
    • a\n
      \n

      b

      \n
      \n
      c\n
      \n
    • \n
    • d
    • \n
    \n", + "example": 291, + "start_line": 5379, + "end_line": 5397, + "section": "Lists", + "shouldFail": true + }, + { + "markdown": "- a\n", + "html": "
      \n
    • a
    • \n
    \n", + "example": 292, + "start_line": 5402, + "end_line": 5408, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n", + "html": "
      \n
    • a\n
        \n
      • b
      • \n
      \n
    • \n
    \n", + "example": 293, + "start_line": 5411, + "end_line": 5422, + "section": "Lists" + }, + { + "markdown": "1. ```\n foo\n ```\n\n bar\n", + "html": "
      \n
    1. \n
      foo\n
      \n

      bar

      \n
    2. \n
    \n", + "example": 294, + "start_line": 5428, + "end_line": 5442, + "section": "Lists" + }, + { + "markdown": "* foo\n * bar\n\n baz\n", + "html": "
      \n
    • \n

      foo

      \n
        \n
      • bar
      • \n
      \n

      baz

      \n
    • \n
    \n", + "example": 295, + "start_line": 5447, + "end_line": 5462, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n\n- d\n - e\n - f\n", + "html": "
      \n
    • \n

      a

      \n
        \n
      • b
      • \n
      • c
      • \n
      \n
    • \n
    • \n

      d

      \n
        \n
      • e
      • \n
      • f
      • \n
      \n
    • \n
    \n", + "example": 296, + "start_line": 5465, + "end_line": 5490, + "section": "Lists" + }, + { + "markdown": "`hi`lo`\n", + "html": "

    hilo`

    \n", + "example": 297, + "start_line": 5499, + "end_line": 5503, + "section": "Inlines" + }, + { + "markdown": "\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n", + "html": "

    !"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~

    \n", + "example": 298, + "start_line": 5513, + "end_line": 5517, + "section": "Backslash escapes" + }, + { + "markdown": "\\\t\\A\\a\\ \\3\\φ\\«\n", + "html": "

    \\\t\\A\\a\\ \\3\\φ\\«

    \n", + "example": 299, + "start_line": 5523, + "end_line": 5527, + "section": "Backslash escapes" + }, + { + "markdown": "\\*not emphasized*\n\\
    not a tag\n\\[not a link](/foo)\n\\`not code`\n1\\. not a list\n\\* not a list\n\\# not a heading\n\\[foo]: /url \"not a reference\"\n\\ö not a character entity\n", + "html": "

    *not emphasized*\n<br/> not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url "not a reference"\n&ouml; not a character entity

    \n", + "example": 300, + "start_line": 5533, + "end_line": 5553, + "section": "Backslash escapes" + }, + { + "markdown": "\\\\*emphasis*\n", + "html": "

    \\emphasis

    \n", + "example": 301, + "start_line": 5558, + "end_line": 5562, + "section": "Backslash escapes" + }, + { + "markdown": "foo\\\nbar\n", + "html": "

    foo
    \nbar

    \n", + "example": 302, + "start_line": 5567, + "end_line": 5573, + "section": "Backslash escapes" + }, + { + "markdown": "`` \\[\\` ``\n", + "html": "

    \\[\\`

    \n", + "example": 303, + "start_line": 5579, + "end_line": 5583, + "section": "Backslash escapes" + }, + { + "markdown": " \\[\\]\n", + "html": "
    \\[\\]\n
    \n", + "example": 304, + "start_line": 5586, + "end_line": 5591, + "section": "Backslash escapes" + }, + { + "markdown": "~~~\n\\[\\]\n~~~\n", + "html": "
    \\[\\]\n
    \n", + "example": 305, + "start_line": 5594, + "end_line": 5601, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "

    http://example.com?find=\\*

    \n", + "example": 306, + "start_line": 5604, + "end_line": 5608, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "\n", + "example": 307, + "start_line": 5611, + "end_line": 5615, + "section": "Backslash escapes" + }, + { + "markdown": "[foo](/bar\\* \"ti\\*tle\")\n", + "html": "

    foo

    \n", + "example": 308, + "start_line": 5621, + "end_line": 5625, + "section": "Backslash escapes" + }, + { + "markdown": "[foo]\n\n[foo]: /bar\\* \"ti\\*tle\"\n", + "html": "

    foo

    \n", + "example": 309, + "start_line": 5628, + "end_line": 5634, + "section": "Backslash escapes", + "shouldFail": true + }, + { + "markdown": "``` foo\\+bar\nfoo\n```\n", + "html": "
    foo\n
    \n", + "example": 310, + "start_line": 5637, + "end_line": 5644, + "section": "Backslash escapes", + "shouldFail": true + }, + { + "markdown": "  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n", + "html": "

      & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸

    \n", + "example": 311, + "start_line": 5674, + "end_line": 5682, + "section": "Entity and numeric character references" + }, + { + "markdown": "# Ӓ Ϡ �\n", + "html": "

    # Ӓ Ϡ �

    \n", + "example": 312, + "start_line": 5693, + "end_line": 5697, + "section": "Entity and numeric character references" + }, + { + "markdown": "" ആ ಫ\n", + "html": "

    " ആ ಫ

    \n", + "example": 313, + "start_line": 5706, + "end_line": 5710, + "section": "Entity and numeric character references" + }, + { + "markdown": "  &x; &#; &#x;\n�\n&#abcdef0;\n&ThisIsNotDefined; &hi?;\n", + "html": "

    &nbsp &x; &#; &#x;\n&#987654321;\n&#abcdef0;\n&ThisIsNotDefined; &hi?;

    \n", + "example": 314, + "start_line": 5715, + "end_line": 5725, + "section": "Entity and numeric character references", + "shouldFail": true + }, + { + "markdown": "©\n", + "html": "

    &copy

    \n", + "example": 315, + "start_line": 5732, + "end_line": 5736, + "section": "Entity and numeric character references" + }, + { + "markdown": "&MadeUpEntity;\n", + "html": "

    &MadeUpEntity;

    \n", + "example": 316, + "start_line": 5742, + "end_line": 5746, + "section": "Entity and numeric character references" + }, + { + "markdown": "\n", + "html": "\n", + "example": 317, + "start_line": 5753, + "end_line": 5757, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo](/föö \"föö\")\n", + "html": "

    foo

    \n", + "example": 318, + "start_line": 5760, + "end_line": 5764, + "section": "Entity and numeric character references", + "shouldFail": true + }, + { + "markdown": "[foo]\n\n[foo]: /föö \"föö\"\n", + "html": "

    foo

    \n", + "example": 319, + "start_line": 5767, + "end_line": 5773, + "section": "Entity and numeric character references", + "shouldFail": true + }, + { + "markdown": "``` föö\nfoo\n```\n", + "html": "
    foo\n
    \n", + "example": 320, + "start_line": 5776, + "end_line": 5783, + "section": "Entity and numeric character references", + "shouldFail": true + }, + { + "markdown": "`föö`\n", + "html": "

    f&ouml;&ouml;

    \n", + "example": 321, + "start_line": 5789, + "end_line": 5793, + "section": "Entity and numeric character references" + }, + { + "markdown": " föfö\n", + "html": "
    f&ouml;f&ouml;\n
    \n", + "example": 322, + "start_line": 5796, + "end_line": 5801, + "section": "Entity and numeric character references" + }, + { + "markdown": "*foo*\n*foo*\n", + "html": "

    *foo*\nfoo

    \n", + "example": 323, + "start_line": 5808, + "end_line": 5814, + "section": "Entity and numeric character references" + }, + { + "markdown": "* foo\n\n* foo\n", + "html": "

    * foo

    \n
      \n
    • foo
    • \n
    \n", + "example": 324, + "start_line": 5816, + "end_line": 5825, + "section": "Entity and numeric character references" + }, + { + "markdown": "foo bar\n", + "html": "

    foo\n\nbar

    \n", + "example": 325, + "start_line": 5827, + "end_line": 5833, + "section": "Entity and numeric character references" + }, + { + "markdown": " foo\n", + "html": "

    \tfoo

    \n", + "example": 326, + "start_line": 5835, + "end_line": 5839, + "section": "Entity and numeric character references" + }, + { + "markdown": "[a](url "tit")\n", + "html": "

    [a](url "tit")

    \n", + "example": 327, + "start_line": 5842, + "end_line": 5846, + "section": "Entity and numeric character references" + }, + { + "markdown": "`foo`\n", + "html": "

    foo

    \n", + "example": 328, + "start_line": 5870, + "end_line": 5874, + "section": "Code spans" + }, + { + "markdown": "`` foo ` bar ``\n", + "html": "

    foo ` bar

    \n", + "example": 329, + "start_line": 5881, + "end_line": 5885, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

    ``

    \n", + "example": 330, + "start_line": 5891, + "end_line": 5895, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

    ``

    \n", + "example": 331, + "start_line": 5899, + "end_line": 5903, + "section": "Code spans" + }, + { + "markdown": "` a`\n", + "html": "

    a

    \n", + "example": 332, + "start_line": 5908, + "end_line": 5912, + "section": "Code spans" + }, + { + "markdown": "` b `\n", + "html": "

     b 

    \n", + "example": 333, + "start_line": 5917, + "end_line": 5921, + "section": "Code spans" + }, + { + "markdown": "` `\n` `\n", + "html": "

     \n

    \n", + "example": 334, + "start_line": 5925, + "end_line": 5931, + "section": "Code spans" + }, + { + "markdown": "``\nfoo\nbar \nbaz\n``\n", + "html": "

    foo bar baz

    \n", + "example": 335, + "start_line": 5936, + "end_line": 5944, + "section": "Code spans" + }, + { + "markdown": "``\nfoo \n``\n", + "html": "

    foo

    \n", + "example": 336, + "start_line": 5946, + "end_line": 5952, + "section": "Code spans" + }, + { + "markdown": "`foo bar \nbaz`\n", + "html": "

    foo bar baz

    \n", + "example": 337, + "start_line": 5957, + "end_line": 5962, + "section": "Code spans" + }, + { + "markdown": "`foo\\`bar`\n", + "html": "

    foo\\bar`

    \n", + "example": 338, + "start_line": 5974, + "end_line": 5978, + "section": "Code spans" + }, + { + "markdown": "``foo`bar``\n", + "html": "

    foo`bar

    \n", + "example": 339, + "start_line": 5985, + "end_line": 5989, + "section": "Code spans" + }, + { + "markdown": "` foo `` bar `\n", + "html": "

    foo `` bar

    \n", + "example": 340, + "start_line": 5991, + "end_line": 5995, + "section": "Code spans" + }, + { + "markdown": "*foo`*`\n", + "html": "

    *foo*

    \n", + "example": 341, + "start_line": 6003, + "end_line": 6007, + "section": "Code spans", + "shouldFail": true + }, + { + "markdown": "[not a `link](/foo`)\n", + "html": "

    [not a link](/foo)

    \n", + "example": 342, + "start_line": 6012, + "end_line": 6016, + "section": "Code spans", + "shouldFail": true + }, + { + "markdown": "``\n", + "html": "

    <a href="">`

    \n", + "example": 343, + "start_line": 6022, + "end_line": 6026, + "section": "Code spans" + }, + { + "markdown": "
    `\n", + "html": "

    `

    \n", + "example": 344, + "start_line": 6031, + "end_line": 6035, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

    <http://foo.bar.baz>`

    \n", + "example": 345, + "start_line": 6040, + "end_line": 6044, + "section": "Code spans" + }, + { + "markdown": "`\n", + "html": "

    http://foo.bar.`baz`

    \n", + "example": 346, + "start_line": 6049, + "end_line": 6053, + "section": "Code spans" + }, + { + "markdown": "```foo``\n", + "html": "

    ```foo``

    \n", + "example": 347, + "start_line": 6059, + "end_line": 6063, + "section": "Code spans" + }, + { + "markdown": "`foo\n", + "html": "

    `foo

    \n", + "example": 348, + "start_line": 6066, + "end_line": 6070, + "section": "Code spans" + }, + { + "markdown": "`foo``bar``\n", + "html": "

    `foobar

    \n", + "example": 349, + "start_line": 6075, + "end_line": 6079, + "section": "Code spans" + }, + { + "markdown": "*foo bar*\n", + "html": "

    foo bar

    \n", + "example": 350, + "start_line": 6292, + "end_line": 6296, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a * foo bar*\n", + "html": "

    a * foo bar*

    \n", + "example": 351, + "start_line": 6302, + "end_line": 6306, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a*\"foo\"*\n", + "html": "

    a*"foo"*

    \n", + "example": 352, + "start_line": 6313, + "end_line": 6317, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "* a *\n", + "html": "

    * a *

    \n", + "example": 353, + "start_line": 6322, + "end_line": 6326, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "foo*bar*\n", + "html": "

    foobar

    \n", + "example": 354, + "start_line": 6331, + "end_line": 6335, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5*6*78\n", + "html": "

    5678

    \n", + "example": 355, + "start_line": 6338, + "end_line": 6342, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar_\n", + "html": "

    foo bar

    \n", + "example": 356, + "start_line": 6347, + "end_line": 6351, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_ foo bar_\n", + "html": "

    _ foo bar_

    \n", + "example": 357, + "start_line": 6357, + "end_line": 6361, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a_\"foo\"_\n", + "html": "

    a_"foo"_

    \n", + "example": 358, + "start_line": 6367, + "end_line": 6371, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo_bar_\n", + "html": "

    foo_bar_

    \n", + "example": 359, + "start_line": 6376, + "end_line": 6380, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5_6_78\n", + "html": "

    5_6_78

    \n", + "example": 360, + "start_line": 6383, + "end_line": 6387, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням_стремятся_\n", + "html": "

    пристаням_стремятся_

    \n", + "example": 361, + "start_line": 6390, + "end_line": 6394, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "aa_\"bb\"_cc\n", + "html": "

    aa_"bb"_cc

    \n", + "example": 362, + "start_line": 6400, + "end_line": 6404, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-_(bar)_\n", + "html": "

    foo-(bar)

    \n", + "example": 363, + "start_line": 6411, + "end_line": 6415, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo*\n", + "html": "

    _foo*

    \n", + "example": 364, + "start_line": 6423, + "end_line": 6427, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar *\n", + "html": "

    *foo bar *

    \n", + "example": 365, + "start_line": 6433, + "end_line": 6437, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar\n*\n", + "html": "

    *foo bar\n*

    \n", + "example": 366, + "start_line": 6442, + "end_line": 6448, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo)\n", + "html": "

    *(*foo)

    \n", + "example": 367, + "start_line": 6455, + "end_line": 6459, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*(*foo*)*\n", + "html": "

    (foo)

    \n", + "example": 368, + "start_line": 6465, + "end_line": 6469, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo*bar\n", + "html": "

    foobar

    \n", + "example": 369, + "start_line": 6474, + "end_line": 6478, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar _\n", + "html": "

    _foo bar _

    \n", + "example": 370, + "start_line": 6487, + "end_line": 6491, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo)\n", + "html": "

    _(_foo)

    \n", + "example": 371, + "start_line": 6497, + "end_line": 6501, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "_(_foo_)_\n", + "html": "

    (foo)

    \n", + "example": 372, + "start_line": 6506, + "end_line": 6510, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "_foo_bar\n", + "html": "

    _foo_bar

    \n", + "example": 373, + "start_line": 6515, + "end_line": 6519, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_пристаням_стремятся\n", + "html": "

    _пристаням_стремятся

    \n", + "example": 374, + "start_line": 6522, + "end_line": 6526, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar_baz_\n", + "html": "

    foo_bar_baz

    \n", + "example": 375, + "start_line": 6529, + "end_line": 6533, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(bar)_.\n", + "html": "

    (bar).

    \n", + "example": 376, + "start_line": 6540, + "end_line": 6544, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar**\n", + "html": "

    foo bar

    \n", + "example": 377, + "start_line": 6549, + "end_line": 6553, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** foo bar**\n", + "html": "

    ** foo bar**

    \n", + "example": 378, + "start_line": 6559, + "end_line": 6563, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a**\"foo\"**\n", + "html": "

    a**"foo"**

    \n", + "example": 379, + "start_line": 6570, + "end_line": 6574, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "foo**bar**\n", + "html": "

    foobar

    \n", + "example": 380, + "start_line": 6579, + "end_line": 6583, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar__\n", + "html": "

    foo bar

    \n", + "example": 381, + "start_line": 6588, + "end_line": 6592, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ foo bar__\n", + "html": "

    __ foo bar__

    \n", + "example": 382, + "start_line": 6598, + "end_line": 6602, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\nfoo bar__\n", + "html": "

    __\nfoo bar__

    \n", + "example": 383, + "start_line": 6606, + "end_line": 6612, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a__\"foo\"__\n", + "html": "

    a__"foo"__

    \n", + "example": 384, + "start_line": 6618, + "end_line": 6622, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo__bar__\n", + "html": "

    foo__bar__

    \n", + "example": 385, + "start_line": 6627, + "end_line": 6631, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5__6__78\n", + "html": "

    5__6__78

    \n", + "example": 386, + "start_line": 6634, + "end_line": 6638, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням__стремятся__\n", + "html": "

    пристаням__стремятся__

    \n", + "example": 387, + "start_line": 6641, + "end_line": 6645, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__foo, __bar__, baz__\n", + "html": "

    foo, bar, baz

    \n", + "example": 388, + "start_line": 6648, + "end_line": 6652, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "foo-__(bar)__\n", + "html": "

    foo-(bar)

    \n", + "example": 389, + "start_line": 6659, + "end_line": 6663, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar **\n", + "html": "

    **foo bar **

    \n", + "example": 390, + "start_line": 6672, + "end_line": 6676, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "**(**foo)\n", + "html": "

    **(**foo)

    \n", + "example": 391, + "start_line": 6685, + "end_line": 6689, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*(**foo**)*\n", + "html": "

    (foo)

    \n", + "example": 392, + "start_line": 6695, + "end_line": 6699, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n", + "html": "

    Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

    \n", + "example": 393, + "start_line": 6702, + "end_line": 6708, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo \"*bar*\" foo**\n", + "html": "

    foo "bar" foo

    \n", + "example": 394, + "start_line": 6711, + "end_line": 6715, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**bar\n", + "html": "

    foobar

    \n", + "example": 395, + "start_line": 6720, + "end_line": 6724, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar __\n", + "html": "

    __foo bar __

    \n", + "example": 396, + "start_line": 6732, + "end_line": 6736, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(__foo)\n", + "html": "

    __(__foo)

    \n", + "example": 397, + "start_line": 6742, + "end_line": 6746, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "_(__foo__)_\n", + "html": "

    (foo)

    \n", + "example": 398, + "start_line": 6752, + "end_line": 6756, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar\n", + "html": "

    __foo__bar

    \n", + "example": 399, + "start_line": 6761, + "end_line": 6765, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__пристаням__стремятся\n", + "html": "

    __пристаням__стремятся

    \n", + "example": 400, + "start_line": 6768, + "end_line": 6772, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__foo__bar__baz__\n", + "html": "

    foo__bar__baz

    \n", + "example": 401, + "start_line": 6775, + "end_line": 6779, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__(bar)__.\n", + "html": "

    (bar).

    \n", + "example": 402, + "start_line": 6786, + "end_line": 6790, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [bar](/url)*\n", + "html": "

    foo bar

    \n", + "example": 403, + "start_line": 6798, + "end_line": 6802, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo\nbar*\n", + "html": "

    foo\nbar

    \n", + "example": 404, + "start_line": 6805, + "end_line": 6811, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo __bar__ baz_\n", + "html": "

    foo bar baz

    \n", + "example": 405, + "start_line": 6817, + "end_line": 6821, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo _bar_ baz_\n", + "html": "

    foo bar baz

    \n", + "example": 406, + "start_line": 6824, + "end_line": 6828, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__foo_ bar_\n", + "html": "

    foo bar

    \n", + "example": 407, + "start_line": 6831, + "end_line": 6835, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo *bar**\n", + "html": "

    foo bar

    \n", + "example": 408, + "start_line": 6838, + "end_line": 6842, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar** baz*\n", + "html": "

    foo bar baz

    \n", + "example": 409, + "start_line": 6845, + "end_line": 6849, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar**baz*\n", + "html": "

    foobarbaz

    \n", + "example": 410, + "start_line": 6851, + "end_line": 6855, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar*\n", + "html": "

    foo**bar

    \n", + "example": 411, + "start_line": 6875, + "end_line": 6879, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo** bar*\n", + "html": "

    foo bar

    \n", + "example": 412, + "start_line": 6888, + "end_line": 6892, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo **bar***\n", + "html": "

    foo bar

    \n", + "example": 413, + "start_line": 6895, + "end_line": 6899, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo**bar***\n", + "html": "

    foobar

    \n", + "example": 414, + "start_line": 6902, + "end_line": 6906, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "foo***bar***baz\n", + "html": "

    foobarbaz

    \n", + "example": 415, + "start_line": 6913, + "end_line": 6917, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "foo******bar*********baz\n", + "html": "

    foobar***baz

    \n", + "example": 416, + "start_line": 6919, + "end_line": 6923, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo **bar *baz* bim** bop*\n", + "html": "

    foo bar baz bim bop

    \n", + "example": 417, + "start_line": 6928, + "end_line": 6932, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo [*bar*](/url)*\n", + "html": "

    foo bar

    \n", + "example": 418, + "start_line": 6935, + "end_line": 6939, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "** is not an empty emphasis\n", + "html": "

    ** is not an empty emphasis

    \n", + "example": 419, + "start_line": 6944, + "end_line": 6948, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**** is not an empty strong emphasis\n", + "html": "

    **** is not an empty strong emphasis

    \n", + "example": 420, + "start_line": 6951, + "end_line": 6955, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [bar](/url)**\n", + "html": "

    foo bar

    \n", + "example": 421, + "start_line": 6964, + "end_line": 6968, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo\nbar**\n", + "html": "

    foo\nbar

    \n", + "example": 422, + "start_line": 6971, + "end_line": 6977, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo _bar_ baz__\n", + "html": "

    foo bar baz

    \n", + "example": 423, + "start_line": 6983, + "end_line": 6987, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo __bar__ baz__\n", + "html": "

    foo bar baz

    \n", + "example": 424, + "start_line": 6990, + "end_line": 6994, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "____foo__ bar__\n", + "html": "

    foo bar

    \n", + "example": 425, + "start_line": 6997, + "end_line": 7001, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "**foo **bar****\n", + "html": "

    foo bar

    \n", + "example": 426, + "start_line": 7004, + "end_line": 7008, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar* baz**\n", + "html": "

    foo bar baz

    \n", + "example": 427, + "start_line": 7011, + "end_line": 7015, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*bar*baz**\n", + "html": "

    foobarbaz

    \n", + "example": 428, + "start_line": 7018, + "end_line": 7022, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo* bar**\n", + "html": "

    foo bar

    \n", + "example": 429, + "start_line": 7025, + "end_line": 7029, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar***\n", + "html": "

    foo bar

    \n", + "example": 430, + "start_line": 7032, + "end_line": 7036, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar **baz**\nbim* bop**\n", + "html": "

    foo bar baz\nbim bop

    \n", + "example": 431, + "start_line": 7041, + "end_line": 7047, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "**foo [*bar*](/url)**\n", + "html": "

    foo bar

    \n", + "example": 432, + "start_line": 7050, + "end_line": 7054, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ is not an empty emphasis\n", + "html": "

    __ is not an empty emphasis

    \n", + "example": 433, + "start_line": 7059, + "end_line": 7063, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____ is not an empty strong emphasis\n", + "html": "

    ____ is not an empty strong emphasis

    \n", + "example": 434, + "start_line": 7066, + "end_line": 7070, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ***\n", + "html": "

    foo ***

    \n", + "example": 435, + "start_line": 7076, + "end_line": 7080, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *\\**\n", + "html": "

    foo *

    \n", + "example": 436, + "start_line": 7083, + "end_line": 7087, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *_*\n", + "html": "

    foo _

    \n", + "example": 437, + "start_line": 7090, + "end_line": 7094, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *****\n", + "html": "

    foo *****

    \n", + "example": 438, + "start_line": 7097, + "end_line": 7101, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **\\***\n", + "html": "

    foo *

    \n", + "example": 439, + "start_line": 7104, + "end_line": 7108, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **_**\n", + "html": "

    foo _

    \n", + "example": 440, + "start_line": 7111, + "end_line": 7115, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*\n", + "html": "

    *foo

    \n", + "example": 441, + "start_line": 7122, + "end_line": 7126, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo**\n", + "html": "

    foo*

    \n", + "example": 442, + "start_line": 7129, + "end_line": 7133, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "***foo**\n", + "html": "

    *foo

    \n", + "example": 443, + "start_line": 7136, + "end_line": 7140, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "****foo*\n", + "html": "

    ***foo

    \n", + "example": 444, + "start_line": 7143, + "end_line": 7147, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "**foo***\n", + "html": "

    foo*

    \n", + "example": 445, + "start_line": 7150, + "end_line": 7154, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo****\n", + "html": "

    foo***

    \n", + "example": 446, + "start_line": 7157, + "end_line": 7161, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "foo ___\n", + "html": "

    foo ___

    \n", + "example": 447, + "start_line": 7167, + "end_line": 7171, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _\\__\n", + "html": "

    foo _

    \n", + "example": 448, + "start_line": 7174, + "end_line": 7178, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _*_\n", + "html": "

    foo *

    \n", + "example": 449, + "start_line": 7181, + "end_line": 7185, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _____\n", + "html": "

    foo _____

    \n", + "example": 450, + "start_line": 7188, + "end_line": 7192, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __\\___\n", + "html": "

    foo _

    \n", + "example": 451, + "start_line": 7195, + "end_line": 7199, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __*__\n", + "html": "

    foo *

    \n", + "example": 452, + "start_line": 7202, + "end_line": 7206, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_\n", + "html": "

    _foo

    \n", + "example": 453, + "start_line": 7209, + "end_line": 7213, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "_foo__\n", + "html": "

    foo_

    \n", + "example": 454, + "start_line": 7220, + "end_line": 7224, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "___foo__\n", + "html": "

    _foo

    \n", + "example": 455, + "start_line": 7227, + "end_line": 7231, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "____foo_\n", + "html": "

    ___foo

    \n", + "example": 456, + "start_line": 7234, + "end_line": 7238, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__foo___\n", + "html": "

    foo_

    \n", + "example": 457, + "start_line": 7241, + "end_line": 7245, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "_foo____\n", + "html": "

    foo___

    \n", + "example": 458, + "start_line": 7248, + "end_line": 7252, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "**foo**\n", + "html": "

    foo

    \n", + "example": 459, + "start_line": 7258, + "end_line": 7262, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*_foo_*\n", + "html": "

    foo

    \n", + "example": 460, + "start_line": 7265, + "end_line": 7269, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__\n", + "html": "

    foo

    \n", + "example": 461, + "start_line": 7272, + "end_line": 7276, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_*foo*_\n", + "html": "

    foo

    \n", + "example": 462, + "start_line": 7279, + "end_line": 7283, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo****\n", + "html": "

    foo

    \n", + "example": 463, + "start_line": 7289, + "end_line": 7293, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo____\n", + "html": "

    foo

    \n", + "example": 464, + "start_line": 7296, + "end_line": 7300, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "******foo******\n", + "html": "

    foo

    \n", + "example": 465, + "start_line": 7307, + "end_line": 7311, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "***foo***\n", + "html": "

    foo

    \n", + "example": 466, + "start_line": 7316, + "end_line": 7320, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "_____foo_____\n", + "html": "

    foo

    \n", + "example": 467, + "start_line": 7323, + "end_line": 7327, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo _bar* baz_\n", + "html": "

    foo _bar baz_

    \n", + "example": 468, + "start_line": 7332, + "end_line": 7336, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo __bar *baz bim__ bam*\n", + "html": "

    foo bar *baz bim bam

    \n", + "example": 469, + "start_line": 7339, + "end_line": 7343, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar baz**\n", + "html": "

    **foo bar baz

    \n", + "example": 470, + "start_line": 7348, + "end_line": 7352, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*foo *bar baz*\n", + "html": "

    *foo bar baz

    \n", + "example": 471, + "start_line": 7355, + "end_line": 7359, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*[bar*](/url)\n", + "html": "

    *bar*

    \n", + "example": 472, + "start_line": 7364, + "end_line": 7368, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo [bar_](/url)\n", + "html": "

    _foo bar_

    \n", + "example": 473, + "start_line": 7371, + "end_line": 7375, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*\n", + "html": "

    *

    \n", + "example": 474, + "start_line": 7378, + "end_line": 7382, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**\n", + "html": "

    **

    \n", + "example": 475, + "start_line": 7385, + "end_line": 7389, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__\n", + "html": "

    __

    \n", + "example": 476, + "start_line": 7392, + "end_line": 7396, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "*a `*`*\n", + "html": "

    a *

    \n", + "example": 477, + "start_line": 7399, + "end_line": 7403, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "_a `_`_\n", + "html": "

    a _

    \n", + "example": 478, + "start_line": 7406, + "end_line": 7410, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**a\n", + "html": "

    **ahttp://foo.bar/?q=**

    \n", + "example": 479, + "start_line": 7413, + "end_line": 7417, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "__a\n", + "html": "

    __ahttp://foo.bar/?q=__

    \n", + "example": 480, + "start_line": 7420, + "end_line": 7424, + "section": "Emphasis and strong emphasis", + "shouldFail": true + }, + { + "markdown": "[link](/uri \"title\")\n", + "html": "

    link

    \n", + "example": 481, + "start_line": 7503, + "end_line": 7507, + "section": "Links" + }, + { + "markdown": "[link](/uri)\n", + "html": "

    link

    \n", + "example": 482, + "start_line": 7512, + "end_line": 7516, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

    link

    \n", + "example": 483, + "start_line": 7521, + "end_line": 7525, + "section": "Links" + }, + { + "markdown": "[link](<>)\n", + "html": "

    link

    \n", + "example": 484, + "start_line": 7528, + "end_line": 7532, + "section": "Links" + }, + { + "markdown": "[link](/my uri)\n", + "html": "

    [link](/my uri)

    \n", + "example": 485, + "start_line": 7537, + "end_line": 7541, + "section": "Links" + }, + { + "markdown": "[link](
    )\n", + "html": "

    link

    \n", + "example": 486, + "start_line": 7543, + "end_line": 7547, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[link](foo\nbar)\n", + "html": "

    [link](foo\nbar)

    \n", + "example": 487, + "start_line": 7552, + "end_line": 7558, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

    [link]()

    \n", + "example": 488, + "start_line": 7560, + "end_line": 7566, + "section": "Links" + }, + { + "markdown": "[a]()\n", + "html": "

    a

    \n", + "example": 489, + "start_line": 7571, + "end_line": 7575, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[link]()\n", + "html": "

    [link](<foo>)

    \n", + "example": 490, + "start_line": 7579, + "end_line": 7583, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[a](\n[a](c)\n", + "html": "

    [a](<b)c\n[a](<b)c>\n[a](c)

    \n", + "example": 491, + "start_line": 7588, + "end_line": 7596, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[link](\\(foo\\))\n", + "html": "

    link

    \n", + "example": 492, + "start_line": 7600, + "end_line": 7604, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar)))\n", + "html": "

    link

    \n", + "example": 493, + "start_line": 7609, + "end_line": 7613, + "section": "Links" + }, + { + "markdown": "[link](foo\\(and\\(bar\\))\n", + "html": "

    link

    \n", + "example": 494, + "start_line": 7618, + "end_line": 7622, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

    link

    \n", + "example": 495, + "start_line": 7625, + "end_line": 7629, + "section": "Links" + }, + { + "markdown": "[link](foo\\)\\:)\n", + "html": "

    link

    \n", + "example": 496, + "start_line": 7635, + "end_line": 7639, + "section": "Links" + }, + { + "markdown": "[link](#fragment)\n\n[link](http://example.com#fragment)\n\n[link](http://example.com?foo=3#frag)\n", + "html": "

    link

    \n

    link

    \n

    link

    \n", + "example": 497, + "start_line": 7644, + "end_line": 7654, + "section": "Links" + }, + { + "markdown": "[link](foo\\bar)\n", + "html": "

    link

    \n", + "example": 498, + "start_line": 7660, + "end_line": 7664, + "section": "Links" + }, + { + "markdown": "[link](foo%20bä)\n", + "html": "

    link

    \n", + "example": 499, + "start_line": 7676, + "end_line": 7680, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[link](\"title\")\n", + "html": "

    link

    \n", + "example": 500, + "start_line": 7687, + "end_line": 7691, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n", + "html": "

    link\nlink\nlink

    \n", + "example": 501, + "start_line": 7696, + "end_line": 7704, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \\\""\")\n", + "html": "

    link

    \n", + "example": 502, + "start_line": 7710, + "end_line": 7714, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n", + "html": "

    link

    \n", + "example": 503, + "start_line": 7720, + "end_line": 7724, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[link](/url \"title \"and\" title\")\n", + "html": "

    [link](/url "title "and" title")

    \n", + "example": 504, + "start_line": 7729, + "end_line": 7733, + "section": "Links" + }, + { + "markdown": "[link](/url 'title \"and\" title')\n", + "html": "

    link

    \n", + "example": 505, + "start_line": 7738, + "end_line": 7742, + "section": "Links" + }, + { + "markdown": "[link]( /uri\n \"title\" )\n", + "html": "

    link

    \n", + "example": 506, + "start_line": 7762, + "end_line": 7767, + "section": "Links" + }, + { + "markdown": "[link] (/uri)\n", + "html": "

    [link] (/uri)

    \n", + "example": 507, + "start_line": 7773, + "end_line": 7777, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]](/uri)\n", + "html": "

    link [foo [bar]]

    \n", + "example": 508, + "start_line": 7783, + "end_line": 7787, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[link] bar](/uri)\n", + "html": "

    [link] bar](/uri)

    \n", + "example": 509, + "start_line": 7790, + "end_line": 7794, + "section": "Links" + }, + { + "markdown": "[link [bar](/uri)\n", + "html": "

    [link bar

    \n", + "example": 510, + "start_line": 7797, + "end_line": 7801, + "section": "Links" + }, + { + "markdown": "[link \\[bar](/uri)\n", + "html": "

    link [bar

    \n", + "example": 511, + "start_line": 7804, + "end_line": 7808, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*](/uri)\n", + "html": "

    link foo bar #

    \n", + "example": 512, + "start_line": 7813, + "end_line": 7817, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)](/uri)\n", + "html": "

    \"moon\"

    \n", + "example": 513, + "start_line": 7820, + "end_line": 7824, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)](/uri)\n", + "html": "

    [foo bar](/uri)

    \n", + "example": 514, + "start_line": 7829, + "end_line": 7833, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo *[bar [baz](/uri)](/uri)*](/uri)\n", + "html": "

    [foo [bar baz](/uri)](/uri)

    \n", + "example": 515, + "start_line": 7836, + "end_line": 7840, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "![[[foo](uri1)](uri2)](uri3)\n", + "html": "

    \"[foo](uri2)\"

    \n", + "example": 516, + "start_line": 7843, + "end_line": 7847, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "*[foo*](/uri)\n", + "html": "

    *foo*

    \n", + "example": 517, + "start_line": 7853, + "end_line": 7857, + "section": "Links" + }, + { + "markdown": "[foo *bar](baz*)\n", + "html": "

    foo *bar

    \n", + "example": 518, + "start_line": 7860, + "end_line": 7864, + "section": "Links" + }, + { + "markdown": "*foo [bar* baz]\n", + "html": "

    foo [bar baz]

    \n", + "example": 519, + "start_line": 7870, + "end_line": 7874, + "section": "Links" + }, + { + "markdown": "[foo \n", + "html": "

    [foo

    \n", + "example": 520, + "start_line": 7880, + "end_line": 7884, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo`](/uri)`\n", + "html": "

    [foo](/uri)

    \n", + "example": 521, + "start_line": 7887, + "end_line": 7891, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo\n", + "html": "

    [foohttp://example.com/?search=](uri)

    \n", + "example": 522, + "start_line": 7894, + "end_line": 7898, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo][bar]\n\n[bar]: /url \"title\"\n", + "html": "

    foo

    \n", + "example": 523, + "start_line": 7932, + "end_line": 7938, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]][ref]\n\n[ref]: /uri\n", + "html": "

    link [foo [bar]]

    \n", + "example": 524, + "start_line": 7947, + "end_line": 7953, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n", + "html": "

    link [bar

    \n", + "example": 525, + "start_line": 7956, + "end_line": 7962, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n", + "html": "

    link foo bar #

    \n", + "example": 526, + "start_line": 7967, + "end_line": 7973, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n", + "html": "

    \"moon\"

    \n", + "example": 527, + "start_line": 7976, + "end_line": 7982, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)][ref]\n\n[ref]: /uri\n", + "html": "

    [foo bar]ref

    \n", + "example": 528, + "start_line": 7987, + "end_line": 7993, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n", + "html": "

    [foo bar baz]ref

    \n", + "example": 529, + "start_line": 7996, + "end_line": 8002, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "*[foo*][ref]\n\n[ref]: /uri\n", + "html": "

    *foo*

    \n", + "example": 530, + "start_line": 8011, + "end_line": 8017, + "section": "Links" + }, + { + "markdown": "[foo *bar][ref]\n\n[ref]: /uri\n", + "html": "

    foo *bar

    \n", + "example": 531, + "start_line": 8020, + "end_line": 8026, + "section": "Links" + }, + { + "markdown": "[foo \n\n[ref]: /uri\n", + "html": "

    [foo

    \n", + "example": 532, + "start_line": 8032, + "end_line": 8038, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo`][ref]`\n\n[ref]: /uri\n", + "html": "

    [foo][ref]

    \n", + "example": 533, + "start_line": 8041, + "end_line": 8047, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo\n\n[ref]: /uri\n", + "html": "

    [foohttp://example.com/?search=][ref]

    \n", + "example": 534, + "start_line": 8050, + "end_line": 8056, + "section": "Links", + "shouldFail": true + }, + { + "markdown": "[foo][BaR]\n\n[bar]: /url \"title\"\n", + "html": "

    foo

    \n", + "example": 535, + "start_line": 8061, + "end_line": 8067, + "section": "Links" + }, + { + "markdown": "[Толпой][Толпой] is a Russian word.\n\n[ТОЛПОЙ]: /url\n", + "html": "

    Толпой is a Russian word.

    \n", + "example": 536, + "start_line": 8072, + "end_line": 8078, + "section": "Links" + }, + { + "markdown": "[Foo\n bar]: /url\n\n[Baz][Foo bar]\n", + "html": "

    Baz

    \n", + "example": 537, + "start_line": 8084, + "end_line": 8091, + "section": "Links" + }, + { + "markdown": "[foo] [bar]\n\n[bar]: /url \"title\"\n", + "html": "

    [foo] bar

    \n", + "example": 538, + "start_line": 8097, + "end_line": 8103, + "section": "Links" + }, + { + "markdown": "[foo]\n[bar]\n\n[bar]: /url \"title\"\n", + "html": "

    [foo]\nbar

    \n", + "example": 539, + "start_line": 8106, + "end_line": 8114, + "section": "Links" + }, + { + "markdown": "[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n", + "html": "

    bar

    \n", + "example": 540, + "start_line": 8147, + "end_line": 8155, + "section": "Links" + }, + { + "markdown": "[bar][foo\\!]\n\n[foo!]: /url\n", + "html": "

    [bar][foo!]

    \n", + "example": 541, + "start_line": 8162, + "end_line": 8168, + "section": "Links" + }, + { + "markdown": "[foo][ref[]\n\n[ref[]: /uri\n", + "html": "

    [foo][ref[]

    \n

    [ref[]: /uri

    \n", + "example": 542, + "start_line": 8174, + "end_line": 8181, + "section": "Links" + }, + { + "markdown": "[foo][ref[bar]]\n\n[ref[bar]]: /uri\n", + "html": "

    [foo][ref[bar]]

    \n

    [ref[bar]]: /uri

    \n", + "example": 543, + "start_line": 8184, + "end_line": 8191, + "section": "Links" + }, + { + "markdown": "[[[foo]]]\n\n[[[foo]]]: /url\n", + "html": "

    [[[foo]]]

    \n

    [[[foo]]]: /url

    \n", + "example": 544, + "start_line": 8194, + "end_line": 8201, + "section": "Links" + }, + { + "markdown": "[foo][ref\\[]\n\n[ref\\[]: /uri\n", + "html": "

    foo

    \n", + "example": 545, + "start_line": 8204, + "end_line": 8210, + "section": "Links" + }, + { + "markdown": "[bar\\\\]: /uri\n\n[bar\\\\]\n", + "html": "

    bar\\

    \n", + "example": 546, + "start_line": 8215, + "end_line": 8221, + "section": "Links" + }, + { + "markdown": "[]\n\n[]: /uri\n", + "html": "

    []

    \n

    []: /uri

    \n", + "example": 547, + "start_line": 8226, + "end_line": 8233, + "section": "Links" + }, + { + "markdown": "[\n ]\n\n[\n ]: /uri\n", + "html": "

    [\n]

    \n

    [\n]: /uri

    \n", + "example": 548, + "start_line": 8236, + "end_line": 8247, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url \"title\"\n", + "html": "

    foo

    \n", + "example": 549, + "start_line": 8259, + "end_line": 8265, + "section": "Links" + }, + { + "markdown": "[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

    foo bar

    \n", + "example": 550, + "start_line": 8268, + "end_line": 8274, + "section": "Links" + }, + { + "markdown": "[Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

    Foo

    \n", + "example": 551, + "start_line": 8279, + "end_line": 8285, + "section": "Links" + }, + { + "markdown": "[foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

    foo\n[]

    \n", + "example": 552, + "start_line": 8292, + "end_line": 8300, + "section": "Links" + }, + { + "markdown": "[foo]\n\n[foo]: /url \"title\"\n", + "html": "

    foo

    \n", + "example": 553, + "start_line": 8312, + "end_line": 8318, + "section": "Links" + }, + { + "markdown": "[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

    foo bar

    \n", + "example": 554, + "start_line": 8321, + "end_line": 8327, + "section": "Links" + }, + { + "markdown": "[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

    [foo bar]

    \n", + "example": 555, + "start_line": 8330, + "end_line": 8336, + "section": "Links" + }, + { + "markdown": "[[bar [foo]\n\n[foo]: /url\n", + "html": "

    [[bar foo

    \n", + "example": 556, + "start_line": 8339, + "end_line": 8345, + "section": "Links" + }, + { + "markdown": "[Foo]\n\n[foo]: /url \"title\"\n", + "html": "

    Foo

    \n", + "example": 557, + "start_line": 8350, + "end_line": 8356, + "section": "Links" + }, + { + "markdown": "[foo] bar\n\n[foo]: /url\n", + "html": "

    foo bar

    \n", + "example": 558, + "start_line": 8361, + "end_line": 8367, + "section": "Links" + }, + { + "markdown": "\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

    [foo]

    \n", + "example": 559, + "start_line": 8373, + "end_line": 8379, + "section": "Links" + }, + { + "markdown": "[foo*]: /url\n\n*[foo*]\n", + "html": "

    *foo*

    \n", + "example": 560, + "start_line": 8385, + "end_line": 8391, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n", + "html": "

    foo

    \n", + "example": 561, + "start_line": 8397, + "end_line": 8404, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url1\n", + "html": "

    foo

    \n", + "example": 562, + "start_line": 8406, + "end_line": 8412, + "section": "Links" + }, + { + "markdown": "[foo]()\n\n[foo]: /url1\n", + "html": "

    foo

    \n", + "example": 563, + "start_line": 8416, + "end_line": 8422, + "section": "Links" + }, + { + "markdown": "[foo](not a link)\n\n[foo]: /url1\n", + "html": "

    foo(not a link)

    \n", + "example": 564, + "start_line": 8424, + "end_line": 8430, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url\n", + "html": "

    [foo]bar

    \n", + "example": 565, + "start_line": 8435, + "end_line": 8441, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n", + "html": "

    foobaz

    \n", + "example": 566, + "start_line": 8447, + "end_line": 8454, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n", + "html": "

    [foo]bar

    \n", + "example": 567, + "start_line": 8460, + "end_line": 8467, + "section": "Links" + }, + { + "markdown": "![foo](/url \"title\")\n", + "html": "

    \"foo\"

    \n", + "example": 568, + "start_line": 8483, + "end_line": 8487, + "section": "Images" + }, + { + "markdown": "![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

    \"foo

    \n", + "example": 569, + "start_line": 8490, + "end_line": 8496, + "section": "Images", + "shouldFail": true + }, + { + "markdown": "![foo ![bar](/url)](/url2)\n", + "html": "

    \"foo

    \n", + "example": 570, + "start_line": 8499, + "end_line": 8503, + "section": "Images", + "shouldFail": true + }, + { + "markdown": "![foo [bar](/url)](/url2)\n", + "html": "

    \"foo

    \n", + "example": 571, + "start_line": 8506, + "end_line": 8510, + "section": "Images", + "shouldFail": true + }, + { + "markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

    \"foo

    \n", + "example": 572, + "start_line": 8520, + "end_line": 8526, + "section": "Images", + "shouldFail": true + }, + { + "markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n", + "html": "

    \"foo

    \n", + "example": 573, + "start_line": 8529, + "end_line": 8535, + "section": "Images", + "shouldFail": true + }, + { + "markdown": "![foo](train.jpg)\n", + "html": "

    \"foo\"

    \n", + "example": 574, + "start_line": 8538, + "end_line": 8542, + "section": "Images" + }, + { + "markdown": "My ![foo bar](/path/to/train.jpg \"title\" )\n", + "html": "

    My \"foo

    \n", + "example": 575, + "start_line": 8545, + "end_line": 8549, + "section": "Images" + }, + { + "markdown": "![foo]()\n", + "html": "

    \"foo\"

    \n", + "example": 576, + "start_line": 8552, + "end_line": 8556, + "section": "Images" + }, + { + "markdown": "![](/url)\n", + "html": "

    \"\"

    \n", + "example": 577, + "start_line": 8559, + "end_line": 8563, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[bar]: /url\n", + "html": "

    \"foo\"

    \n", + "example": 578, + "start_line": 8568, + "end_line": 8574, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[BAR]: /url\n", + "html": "

    \"foo\"

    \n", + "example": 579, + "start_line": 8577, + "end_line": 8583, + "section": "Images" + }, + { + "markdown": "![foo][]\n\n[foo]: /url \"title\"\n", + "html": "

    \"foo\"

    \n", + "example": 580, + "start_line": 8588, + "end_line": 8594, + "section": "Images" + }, + { + "markdown": "![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

    \"foo

    \n", + "example": 581, + "start_line": 8597, + "end_line": 8603, + "section": "Images", + "shouldFail": true + }, + { + "markdown": "![Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

    \"Foo\"

    \n", + "example": 582, + "start_line": 8608, + "end_line": 8614, + "section": "Images" + }, + { + "markdown": "![foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

    \"foo\"\n[]

    \n", + "example": 583, + "start_line": 8620, + "end_line": 8628, + "section": "Images" + }, + { + "markdown": "![foo]\n\n[foo]: /url \"title\"\n", + "html": "

    \"foo\"

    \n", + "example": 584, + "start_line": 8633, + "end_line": 8639, + "section": "Images" + }, + { + "markdown": "![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

    \"foo

    \n", + "example": 585, + "start_line": 8642, + "end_line": 8648, + "section": "Images", + "shouldFail": true + }, + { + "markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n", + "html": "

    ![[foo]]

    \n

    [[foo]]: /url "title"

    \n", + "example": 586, + "start_line": 8653, + "end_line": 8660, + "section": "Images" + }, + { + "markdown": "![Foo]\n\n[foo]: /url \"title\"\n", + "html": "

    \"Foo\"

    \n", + "example": 587, + "start_line": 8665, + "end_line": 8671, + "section": "Images" + }, + { + "markdown": "!\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

    ![foo]

    \n", + "example": 588, + "start_line": 8677, + "end_line": 8683, + "section": "Images" + }, + { + "markdown": "\\![foo]\n\n[foo]: /url \"title\"\n", + "html": "

    !foo

    \n", + "example": 589, + "start_line": 8689, + "end_line": 8695, + "section": "Images" + }, + { + "markdown": "\n", + "html": "

    http://foo.bar.baz

    \n", + "example": 590, + "start_line": 8722, + "end_line": 8726, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    http://foo.bar.baz/test?q=hello&id=22&boolean

    \n", + "example": 591, + "start_line": 8729, + "end_line": 8733, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    irc://foo.bar:2233/baz

    \n", + "example": 592, + "start_line": 8736, + "end_line": 8740, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    MAILTO:FOO@BAR.BAZ

    \n", + "example": 593, + "start_line": 8745, + "end_line": 8749, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    a+b+c:d

    \n", + "example": 594, + "start_line": 8757, + "end_line": 8761, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    made-up-scheme://foo,bar

    \n", + "example": 595, + "start_line": 8764, + "end_line": 8768, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    http://../

    \n", + "example": 596, + "start_line": 8771, + "end_line": 8775, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    localhost:5001/foo

    \n", + "example": 597, + "start_line": 8778, + "end_line": 8782, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    <http://foo.bar/baz bim>

    \n", + "example": 598, + "start_line": 8787, + "end_line": 8791, + "section": "Autolinks", + "shouldFail": true + }, + { + "markdown": "\n", + "html": "

    http://example.com/\\[\\

    \n", + "example": 599, + "start_line": 8796, + "end_line": 8800, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    foo@bar.example.com

    \n", + "example": 600, + "start_line": 8818, + "end_line": 8822, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    foo+special@Bar.baz-bar0.com

    \n", + "example": 601, + "start_line": 8825, + "end_line": 8829, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    <foo+@bar.example.com>

    \n", + "example": 602, + "start_line": 8834, + "end_line": 8838, + "section": "Autolinks" + }, + { + "markdown": "<>\n", + "html": "

    <>

    \n", + "example": 603, + "start_line": 8843, + "end_line": 8847, + "section": "Autolinks" + }, + { + "markdown": "< http://foo.bar >\n", + "html": "

    < http://foo.bar >

    \n", + "example": 604, + "start_line": 8850, + "end_line": 8854, + "section": "Autolinks", + "shouldFail": true + }, + { + "markdown": "\n", + "html": "

    <m:abc>

    \n", + "example": 605, + "start_line": 8857, + "end_line": 8861, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

    <foo.bar.baz>

    \n", + "example": 606, + "start_line": 8864, + "end_line": 8868, + "section": "Autolinks" + }, + { + "markdown": "http://example.com\n", + "html": "

    http://example.com

    \n", + "example": 607, + "start_line": 8871, + "end_line": 8875, + "section": "Autolinks", + "shouldFail": true + }, + { + "markdown": "foo@bar.example.com\n", + "html": "

    foo@bar.example.com

    \n", + "example": 608, + "start_line": 8878, + "end_line": 8882, + "section": "Autolinks", + "shouldFail": true + }, + { + "markdown": "\n", + "html": "

    \n", + "example": 609, + "start_line": 8960, + "end_line": 8964, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

    \n", + "example": 610, + "start_line": 8969, + "end_line": 8973, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

    \n", + "example": 611, + "start_line": 8978, + "end_line": 8984, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

    \n", + "example": 612, + "start_line": 8989, + "end_line": 8995, + "section": "Raw HTML" + }, + { + "markdown": "Foo \n", + "html": "

    Foo

    \n", + "example": 613, + "start_line": 9000, + "end_line": 9004, + "section": "Raw HTML" + }, + { + "markdown": "<33> <__>\n", + "html": "

    <33> <__>

    \n", + "example": 614, + "start_line": 9009, + "end_line": 9013, + "section": "Raw HTML" + }, + { + "markdown": "
    \n", + "html": "

    <a h*#ref="hi">

    \n", + "example": 615, + "start_line": 9018, + "end_line": 9022, + "section": "Raw HTML" + }, + { + "markdown": "
    \n", + "html": "

    <a href="hi'> <a href=hi'>

    \n", + "example": 616, + "start_line": 9027, + "end_line": 9031, + "section": "Raw HTML" + }, + { + "markdown": "< a><\nfoo>\n\n", + "html": "

    < a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

    \n", + "example": 617, + "start_line": 9036, + "end_line": 9046, + "section": "Raw HTML" + }, + { + "markdown": "
    \n", + "html": "

    <a href='bar'title=title>

    \n", + "example": 618, + "start_line": 9051, + "end_line": 9055, + "section": "Raw HTML" + }, + { + "markdown": "
    \n", + "html": "

    \n", + "example": 619, + "start_line": 9060, + "end_line": 9064, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

    </a href="foo">

    \n", + "example": 620, + "start_line": 9069, + "end_line": 9073, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

    foo

    \n", + "example": 621, + "start_line": 9078, + "end_line": 9084, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

    foo <!-- not a comment -- two hyphens -->

    \n", + "example": 622, + "start_line": 9087, + "end_line": 9091, + "section": "Raw HTML", + "shouldFail": true + }, + { + "markdown": "foo foo -->\n\nfoo \n", + "html": "

    foo <!--> foo -->

    \n

    foo <!-- foo--->

    \n", + "example": 623, + "start_line": 9096, + "end_line": 9103, + "section": "Raw HTML", + "shouldFail": true + }, + { + "markdown": "foo \n", + "html": "

    foo

    \n", + "example": 624, + "start_line": 9108, + "end_line": 9112, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

    foo

    \n", + "example": 625, + "start_line": 9117, + "end_line": 9121, + "section": "Raw HTML" + }, + { + "markdown": "foo &<]]>\n", + "html": "

    foo &<]]>

    \n", + "example": 626, + "start_line": 9126, + "end_line": 9130, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

    foo

    \n", + "example": 627, + "start_line": 9136, + "end_line": 9140, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

    foo

    \n", + "example": 628, + "start_line": 9145, + "end_line": 9149, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

    <a href=""">

    \n", + "example": 629, + "start_line": 9152, + "end_line": 9156, + "section": "Raw HTML" + }, + { + "markdown": "foo \nbaz\n", + "html": "

    foo
    \nbaz

    \n", + "example": 630, + "start_line": 9166, + "end_line": 9172, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\nbaz\n", + "html": "

    foo
    \nbaz

    \n", + "example": 631, + "start_line": 9178, + "end_line": 9184, + "section": "Hard line breaks" + }, + { + "markdown": "foo \nbaz\n", + "html": "

    foo
    \nbaz

    \n", + "example": 632, + "start_line": 9189, + "end_line": 9195, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n bar\n", + "html": "

    foo
    \nbar

    \n", + "example": 633, + "start_line": 9200, + "end_line": 9206, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n bar\n", + "html": "

    foo
    \nbar

    \n", + "example": 634, + "start_line": 9209, + "end_line": 9215, + "section": "Hard line breaks" + }, + { + "markdown": "*foo \nbar*\n", + "html": "

    foo
    \nbar

    \n", + "example": 635, + "start_line": 9221, + "end_line": 9227, + "section": "Hard line breaks" + }, + { + "markdown": "*foo\\\nbar*\n", + "html": "

    foo
    \nbar

    \n", + "example": 636, + "start_line": 9230, + "end_line": 9236, + "section": "Hard line breaks" + }, + { + "markdown": "`code \nspan`\n", + "html": "

    code span

    \n", + "example": 637, + "start_line": 9241, + "end_line": 9246, + "section": "Hard line breaks" + }, + { + "markdown": "`code\\\nspan`\n", + "html": "

    code\\ span

    \n", + "example": 638, + "start_line": 9249, + "end_line": 9254, + "section": "Hard line breaks" + }, + { + "markdown": "
    \n", + "html": "

    \n", + "example": 639, + "start_line": 9259, + "end_line": 9265, + "section": "Hard line breaks" + }, + { + "markdown": "\n", + "html": "

    \n", + "example": 640, + "start_line": 9268, + "end_line": 9274, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n", + "html": "

    foo\\

    \n", + "example": 641, + "start_line": 9281, + "end_line": 9285, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n", + "html": "

    foo

    \n", + "example": 642, + "start_line": 9288, + "end_line": 9292, + "section": "Hard line breaks" + }, + { + "markdown": "### foo\\\n", + "html": "

    foo\\

    \n", + "example": 643, + "start_line": 9295, + "end_line": 9299, + "section": "Hard line breaks" + }, + { + "markdown": "### foo \n", + "html": "

    foo

    \n", + "example": 644, + "start_line": 9302, + "end_line": 9306, + "section": "Hard line breaks" + }, + { + "markdown": "foo\nbaz\n", + "html": "

    foo\nbaz

    \n", + "example": 645, + "start_line": 9317, + "end_line": 9323, + "section": "Soft line breaks" + }, + { + "markdown": "foo \n baz\n", + "html": "

    foo\nbaz

    \n", + "example": 646, + "start_line": 9329, + "end_line": 9335, + "section": "Soft line breaks" + }, + { + "markdown": "hello $.;'there\n", + "html": "

    hello $.;'there

    \n", + "example": 647, + "start_line": 9349, + "end_line": 9353, + "section": "Textual content" + }, + { + "markdown": "Foo χρῆν\n", + "html": "

    Foo χρῆν

    \n", + "example": 648, + "start_line": 9356, + "end_line": 9360, + "section": "Textual content" + }, + { + "markdown": "Multiple spaces\n", + "html": "

    Multiple spaces

    \n", + "example": 649, + "start_line": 9365, + "end_line": 9369, + "section": "Textual content" + } +] diff --git a/packages/markdown/marked/test/specs/commonmark/getSpecs.js b/packages/markdown/marked/test/specs/commonmark/getSpecs.js new file mode 100644 index 00000000..f22e00c0 --- /dev/null +++ b/packages/markdown/marked/test/specs/commonmark/getSpecs.js @@ -0,0 +1,24 @@ +const fetch = require('node-fetch'); +const marked = require('../../../'); +const htmlDiffer = require('../../helpers/html-differ.js'); +const fs = require('fs'); + +fetch('https://raw.githubusercontent.com/commonmark/commonmark.js/master/package.json') + .then(res => res.json()) + .then(pkg => pkg.version.replace(/^(\d+\.\d+).*$/, '$1')) + .then(version => + fetch(`https://spec.commonmark.org/${version}/spec.json`) + .then(res => res.json()) + .then(specs => { + specs.forEach(spec => { + const html = marked(spec.markdown, {headerIds: false}); + if (!htmlDiffer.isEqual(html, spec.html)) { + spec.shouldFail = true; + } + }); + fs.writeFileSync(`commonmark.${version}.json`, JSON.stringify(specs, null, 2) + '\n'); + }) + ) + .catch((err) => { + console.error(err); + }); diff --git a/packages/markdown/marked/test/specs/gfm/getSpecs.js b/packages/markdown/marked/test/specs/gfm/getSpecs.js new file mode 100644 index 00000000..2746bdbb --- /dev/null +++ b/packages/markdown/marked/test/specs/gfm/getSpecs.js @@ -0,0 +1,44 @@ +const fetch = require('node-fetch'); +const cheerio = require('cheerio'); +const marked = require('../../../'); +const htmlDiffer = require('../../helpers/html-differ.js'); +const fs = require('fs'); + +fetch('https://github.github.com/gfm/') + .then(res => res.text()) + .then(html => cheerio.load(html)) + .then($ => { + const version = $('.version').text().match(/\d+\.\d+/)[0]; + if (!version) { + throw new Error('No version found'); + } + const specs = []; + $('.extension').each((i, ext) => { + const section = $('.definition', ext).text().trim().replace(/^\d+\.\d+(.*?) \(extension\)[\s\S]*$/, '$1'); + $('.example', ext).each((j, exa) => { + const example = +$(exa).attr('id').replace(/\D/g, ''); + const markdown = $('.language-markdown', exa).text().trim(); + const html = $('.language-html', exa).text().trim(); + specs.push({ + section, + html, + markdown, + example + }); + }); + }); + + return [version, specs]; + }) + .then(([version, specs]) => { + specs.forEach(spec => { + const html = marked(spec.markdown, {gfm: true}); + if (!htmlDiffer.isEqual(html, spec.html)) { + spec.shouldFail = true; + } + }); + fs.writeFileSync(`gfm.${version}.json`, JSON.stringify(specs, null, 2) + '\n'); + }) + .catch((err) => { + console.error(err); + }); diff --git a/packages/markdown/marked/test/specs/gfm/gfm.0.29.json b/packages/markdown/marked/test/specs/gfm/gfm.0.29.json new file mode 100644 index 00000000..7d1d43e4 --- /dev/null +++ b/packages/markdown/marked/test/specs/gfm/gfm.0.29.json @@ -0,0 +1,147 @@ +[ + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n
    foobar
    bazbim
    ", + "markdown": "| foo | bar |\n| --- | --- |\n| baz | bim |", + "example": 198 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n
    abcdefghi
    barbaz
    ", + "markdown": "| abc | defghi |\n:-: | -----------:\nbar | baz", + "example": 199 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    f|oo
    b | az
    b | im
    ", + "markdown": "| f\\|oo |\n| ------ |\n| b `\\|` az |\n| b **\\|** im |", + "example": 200 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n
    abcdef
    barbaz
    \n
    \n

    bar

    \n
    ", + "markdown": "| abc | def |\n| --- | --- |\n| bar | baz |\n> bar", + "example": 201 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    abcdef
    barbaz
    bar
    \n

    bar

    ", + "markdown": "| abc | def |\n| --- | --- |\n| bar | baz |\nbar\n\nbar", + "example": 202 + }, + { + "section": "Tables", + "html": "

    | abc | def |\n| --- |\n| bar |

    ", + "markdown": "| abc | def |\n| --- |\n| bar |", + "example": 203 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    abcdef
    bar
    barbaz
    ", + "markdown": "| abc | def |\n| --- | --- |\n| bar |\n| bar | baz | boo |", + "example": 204 + }, + { + "section": "Tables", + "html": "\n\n\n\n\n\n\n
    abcdef
    ", + "markdown": "| abc | def |\n| --- | --- |", + "example": 205 + }, + { + "section": "Task list items", + "html": "
      \n
    • foo
    • \n
    • bar
    • \n
    ", + "markdown": "- [ ] foo\n- [x] bar", + "example": 279 + }, + { + "section": "Task list items", + "html": "
      \n
    • foo\n
        \n
      • bar
      • \n
      • baz
      • \n
      \n
    • \n
    • bim
    • \n
    ", + "markdown": "- [x] foo\n - [ ] bar\n - [x] baz\n- [ ] bim", + "example": 280 + }, + { + "section": "Strikethrough", + "html": "

    Hi Hello, world!

    ", + "markdown": "~~Hi~~ Hello, world!", + "example": 491 + }, + { + "section": "Strikethrough", + "html": "

    This ~~has a

    \n

    new paragraph~~.

    ", + "markdown": "This ~~has a\n\nnew paragraph~~.", + "example": 492 + }, + { + "section": "Autolinks", + "html": "

    www.commonmark.org

    ", + "markdown": "www.commonmark.org", + "example": 621 + }, + { + "section": "Autolinks", + "html": "

    Visit www.commonmark.org/help for more information.

    ", + "markdown": "Visit www.commonmark.org/help for more information.", + "example": 622 + }, + { + "section": "Autolinks", + "html": "

    Visit www.commonmark.org.

    \n

    Visit www.commonmark.org/a.b.

    ", + "markdown": "Visit www.commonmark.org.\n\nVisit www.commonmark.org/a.b.", + "example": 623 + }, + { + "section": "Autolinks", + "html": "

    www.google.com/search?q=Markup+(business)

    \n

    (www.google.com/search?q=Markup+(business))

    ", + "markdown": "www.google.com/search?q=Markup+(business)\n\n(www.google.com/search?q=Markup+(business))", + "example": 624 + }, + { + "section": "Autolinks", + "html": "

    www.google.com/search?q=(business))+ok

    ", + "markdown": "www.google.com/search?q=(business))+ok", + "example": 625 + }, + { + "section": "Autolinks", + "html": "

    www.google.com/search?q=commonmark&hl=en

    \n

    www.google.com/search?q=commonmark&hl;

    ", + "markdown": "www.google.com/search?q=commonmark&hl=en\n\nwww.google.com/search?q=commonmark&hl;", + "example": 626 + }, + { + "section": "Autolinks", + "html": "

    www.commonmark.org/he<lp

    ", + "markdown": "www.commonmark.org/hehttp://commonmark.org

    \n

    (Visit https://encrypted.google.com/search?q=Markup+(business))

    \n

    Anonymous FTP is available at ftp://foo.bar.baz.

    ", + "markdown": "http://commonmark.org\n\n(Visit https://encrypted.google.com/search?q=Markup+(business))\n\nAnonymous FTP is available at ftp://foo.bar.baz.", + "example": 628 + }, + { + "section": "Autolinks", + "html": "

    foo@bar.baz

    ", + "markdown": "foo@bar.baz", + "example": 629 + }, + { + "section": "Autolinks", + "html": "

    hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is.

    ", + "markdown": "hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is.", + "example": 630 + }, + { + "section": "Autolinks", + "html": "

    a.b-c_d@a.b

    \n

    a.b-c_d@a.b.

    \n

    a.b-c_d@a.b-

    \n

    a.b-c_d@a.b_

    ", + "markdown": "a.b-c_d@a.b\n\na.b-c_d@a.b.\n\na.b-c_d@a.b-\n\na.b-c_d@a.b_", + "example": 631 + }, + { + "section": "Disallowed Raw HTML", + "html": "

    <title> <style>

    \n
    \n <xmp> is disallowed. <XMP> is also disallowed.\n
    ", + "markdown": " <style> <em>\n\n<blockquote>\n <xmp> is disallowed. <XMP> is also disallowed.\n</blockquote>", + "example": 653, + "shouldFail": true + } +] diff --git a/packages/markdown/marked/test/specs/original/specs-spec.js b/packages/markdown/marked/test/specs/original/specs-spec.js new file mode 100644 index 00000000..82d300a5 --- /dev/null +++ b/packages/markdown/marked/test/specs/original/specs-spec.js @@ -0,0 +1,12 @@ +var specTests = require('../../'); + +it('should run spec tests', () => { + // hide output + spyOn(console, 'log'); + if (!specTests(['', '', '--stop'])) { + // if tests fail rerun tests and show output + console.log.and.callThrough(); + specTests([]); + fail(); + } +}); diff --git a/packages/markdown/marked/test/specs/redos-spec.js b/packages/markdown/marked/test/specs/redos-spec.js new file mode 100644 index 00000000..1f94a42e --- /dev/null +++ b/packages/markdown/marked/test/specs/redos-spec.js @@ -0,0 +1,24 @@ +const path = require('path'); +const fs = require('fs'); + +const redosDir = path.resolve(__dirname, '../redos'); + +describe('ReDOS tests', () => { + const files = fs.readdirSync(redosDir); + files.forEach(file => { + if (!file.match(/\.js$/)) { + return; + } + + it(file, () => { + const spec = require(path.resolve(redosDir, file)); + const before = process.hrtime(); + expect(spec).toRender(spec.html); + const elapsed = process.hrtime(before); + if (elapsed[0] > 0) { + const s = (elapsed[0] + elapsed[1] * 1e-9).toFixed(3); + fail(`took too long: ${s}s`); + } + }); + }); +}); diff --git a/packages/markdown/marked/test/specs/run-spec.js b/packages/markdown/marked/test/specs/run-spec.js new file mode 100644 index 00000000..3af0aa45 --- /dev/null +++ b/packages/markdown/marked/test/specs/run-spec.js @@ -0,0 +1,52 @@ +function runSpecs(title, file, options) { + const json = require(file); + let longestName = 0; + let maxSpecs = 0; + const specs = json.reduce((obj, spec) => { + if (!obj[spec.section]) { + longestName = Math.max(spec.section.length, longestName); + obj[spec.section] = { + specs: [], + pass: 0, + total: 0 + }; + } + obj[spec.section].total++; + maxSpecs = Math.max(obj[spec.section].total, maxSpecs); + if (!spec.shouldFail) { + obj[spec.section].pass++; + } + obj[spec.section].specs.push(spec); + return obj; + }, {}); + + describe(title, () => { + const maxSpecsLen = ('' + maxSpecs).length; + const spaces = maxSpecsLen * 2 + longestName + 11; + console.log('-'.padEnd(spaces + 4, '-')); + console.log(`| ${title.padStart(Math.ceil((spaces + title.length) / 2)).padEnd(spaces)} |`); + console.log(`| ${' '.padEnd(spaces)} |`); + Object.keys(specs).forEach(section => { + console.log(`| ${section.padEnd(longestName)} ${('' + specs[section].pass).padStart(maxSpecsLen)} of ${('' + specs[section].total).padStart(maxSpecsLen)} ${(100 * specs[section].pass / specs[section].total).toFixed().padStart(4)}% |`); + describe(section, () => { + specs[section].specs.forEach((spec) => { + if (options) { + spec.options = Object.assign({}, options, (spec.options || {})); + } + (spec.only ? fit : it)('should ' + (spec.shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, () => { + if (spec.shouldFail) { + expect(spec).not.toRender(spec.html); + } else { + expect(spec).toRender(spec.html); + } + }); + }); + }); + }); + console.log('-'.padEnd(spaces + 4, '-')); + console.log(); + }); +}; + +runSpecs('GFM 0.29', './gfm/gfm.0.29.json', {gfm: true}); +runSpecs('CommonMark 0.29', './commonmark/commonmark.0.29.json', {headerIds: false}); diff --git a/packages/markdown/marked/test/unit/marked-spec.js b/packages/markdown/marked/test/unit/marked-spec.js new file mode 100644 index 00000000..994c5dc8 --- /dev/null +++ b/packages/markdown/marked/test/unit/marked-spec.js @@ -0,0 +1,73 @@ +var marked = require('../../lib/marked.js'); + +describe('Test heading ID functionality', () => { + it('should add id attribute by default', () => { + var renderer = new marked.Renderer(); + var slugger = new marked.Slugger(); + var header = renderer.heading('test', 1, 'test', slugger); + expect(header).toBe('<h1 id="test">test</h1>\n'); + }); + + it('should NOT add id attribute when options set false', () => { + var renderer = new marked.Renderer({ headerIds: false }); + var header = renderer.heading('test', 1, 'test'); + expect(header).toBe('<h1>test</h1>\n'); + }); +}); + +describe('Test slugger functionality', () => { + it('should use lowercase slug', () => { + var slugger = new marked.Slugger(); + expect(slugger.slug('Test')).toBe('test'); + }); + + it('should be unique to avoid collisions 1280', () => { + var slugger = new marked.Slugger(); + expect(slugger.slug('test')).toBe('test'); + expect(slugger.slug('test')).toBe('test-1'); + expect(slugger.slug('test')).toBe('test-2'); + }); + + it('should be unique when slug ends with number', () => { + var slugger = new marked.Slugger(); + expect(slugger.slug('test 1')).toBe('test-1'); + expect(slugger.slug('test')).toBe('test'); + expect(slugger.slug('test')).toBe('test-2'); + }); + + it('should be unique when slug ends with hyphen number', () => { + var slugger = new marked.Slugger(); + expect(slugger.slug('foo')).toBe('foo'); + expect(slugger.slug('foo')).toBe('foo-1'); + expect(slugger.slug('foo 1')).toBe('foo-1-1'); + expect(slugger.slug('foo-1')).toBe('foo-1-2'); + expect(slugger.slug('foo')).toBe('foo-2'); + }); + + it('should allow non-latin chars', () => { + var slugger = new marked.Slugger(); + expect(slugger.slug('привет')).toBe('привет'); + }); + + it('should remove ampersands 857', () => { + var slugger = new marked.Slugger(); + expect(slugger.slug('This & That Section')).toBe('this--that-section'); + }); + + it('should remove periods', () => { + var slugger = new marked.Slugger(); + expect(slugger.slug('file.txt')).toBe('filetxt'); + }); +}); + +describe('Test paragraph token type', () => { + it('should use the "paragraph" type on top level', () => { + const md = 'A Paragraph.\n\n> A blockquote\n\n- list item\n'; + + const tokens = marked.lexer(md); + + expect(tokens[0].type).toBe('paragraph'); + expect(tokens[3].type).toBe('paragraph'); + expect(tokens[7].type).toBe('text'); + }); +}); diff --git a/packages/markdown/package.js b/packages/markdown/package.js new file mode 100755 index 00000000..ac725b8f --- /dev/null +++ b/packages/markdown/package.js @@ -0,0 +1,24 @@ +// Source: https://github.com/chjj/marked + +Package.describe({ + name: 'wekan-markdown', + summary: "GitHub flavored markdown parser for Meteor based on marked.js", + version: "1.0.7", + git: "https://github.com/wekan/markdown.git" +}); + +// Before Meteor 0.9? +if(!Package.onUse) Package.onUse = Package.on_use; + +Package.onUse(function (api) { + if(api.versionsFrom) api.versionsFrom('METEOR@0.9.0'); + + api.use('templating'); + + api.add_files('marked/lib/marked.js', ['server', 'client']); + api.add_files('markdown.js', ['server', 'client']); + api.export('Markdown', ['server', 'client']); + + api.use("ui", "client", {weak: true}); + api.add_files("template-integration.js", "client"); +}); diff --git a/packages/markdown/smart.json b/packages/markdown/smart.json new file mode 100755 index 00000000..dd443066 --- /dev/null +++ b/packages/markdown/smart.json @@ -0,0 +1,9 @@ +{ + "name": "markdown", + "description": "GitHub flavored markdown parser for Meteor based on marked.js", + "homepage": "https://github.com/wekan/markdown", + "author": "Petar Korponaic", + "version": "1.0.7", + "git": "https://github.com/wekan/markdown.git", + "packages": {} +} diff --git a/packages/markdown/template-integration.js b/packages/markdown/template-integration.js new file mode 100755 index 00000000..301bde31 --- /dev/null +++ b/packages/markdown/template-integration.js @@ -0,0 +1,16 @@ +if (Package.ui) { + var Template = Package.templating.Template; + var UI = Package.ui.UI; + var HTML = Package.htmljs.HTML; + var Blaze = Package.blaze.Blaze; // implied by `ui` + + UI.registerHelper('markdown', new Template('markdown', function () { + var self = this; + var text = ""; + if(self.templateContentBlock) { + text = Blaze._toText(self.templateContentBlock, HTML.TEXTMODE.STRING); + } + + return HTML.Raw(Markdown(text)); + })); +} -- cgit v1.2.3-1-g7c22