├── .devcontainer └── devcontainer.json ├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ ├── Feature_request.md │ └── Proposal.md ├── PULL_REQUEST_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE │ └── badges.md ├── dependabot.yml └── workflows │ └── tests.yml ├── .gitignore ├── .releaserc.json ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── SECURITY.md ├── api └── dingus.js ├── bin ├── main.js └── marked.js ├── docs ├── .eslintrc.json ├── AUTHORS.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── INDEX.md ├── PUBLISHING.md ├── USING_ADVANCED.md ├── USING_PRO.md ├── _document.html ├── broken.md ├── build.js ├── css │ ├── hljs-github.css │ ├── shared.css │ └── style.css ├── demo │ ├── demo.css │ ├── demo.js │ ├── index.html │ ├── initial.md │ ├── preview.html │ ├── quickref.md │ └── worker.js ├── favicon.ico ├── img │ ├── copy-icon.svg │ ├── logo-black-and-white.svg │ └── logo-black.svg └── js │ └── index.js ├── esbuild.config.js ├── eslint.config.js ├── man └── marked.1.md ├── package-lock.json ├── package.json ├── src ├── Hooks.ts ├── Instance.ts ├── Lexer.ts ├── MarkedOptions.ts ├── Parser.ts ├── Renderer.ts ├── TextRenderer.ts ├── Tokenizer.ts ├── Tokens.ts ├── defaults.ts ├── helpers.ts ├── marked.ts └── rules.ts ├── test ├── .eslintrc.json ├── bench.js ├── cjs-test.cjs ├── recheck.js ├── rules.js ├── run-spec-tests.js ├── specs │ ├── commonmark │ │ └── commonmark.0.31.2.json │ ├── gfm │ │ ├── commonmark.0.31.2.json │ │ └── gfm.0.29.json │ ├── new │ │ ├── adjacent_lists.html │ │ ├── adjacent_lists.md │ │ ├── autolink_after_link.html │ │ ├── autolink_after_link.md │ │ ├── autolink_lines.html │ │ ├── autolink_lines.md │ │ ├── autolinks.html │ │ ├── autolinks.md │ │ ├── autolinks_quotes.html │ │ ├── autolinks_quotes.md │ │ ├── blockquote_following_nptable.html │ │ ├── blockquote_following_nptable.md │ │ ├── blockquote_following_table.html │ │ ├── blockquote_following_table.md │ │ ├── blockquote_list_item.html │ │ ├── blockquote_list_item.md │ │ ├── blockquote_setext.html │ │ ├── blockquote_setext.md │ │ ├── breakline.html │ │ ├── breakline.md │ │ ├── breaks.html │ │ ├── breaks.md │ │ ├── case_insensitive_refs.html │ │ ├── case_insensitive_refs.md │ │ ├── code_block_no_ending_newline.html │ │ ├── code_block_no_ending_newline.md │ │ ├── code_compensation_indent.html │ │ ├── code_compensation_indent.md │ │ ├── code_consistent_newline.html │ │ ├── code_consistent_newline.md │ │ ├── code_following_nptable.html │ │ ├── code_following_nptable.md │ │ ├── code_following_table.html │ │ ├── code_following_table.md │ │ ├── code_spans.html │ │ ├── code_spans.md │ │ ├── codespan_newline.html │ │ ├── codespan_newline.md │ │ ├── def_blocks.html │ │ ├── def_blocks.md │ │ ├── del_strikethrough.html │ │ ├── del_strikethrough.md │ │ ├── double_link.html │ │ ├── double_link.md │ │ ├── em_2char.html │ │ ├── em_2char.md │ │ ├── em_after_inline.html │ │ ├── em_after_inline.md │ │ ├── em_and_reflinks.html │ │ ├── em_and_reflinks.md │ │ ├── em_list_links.html │ │ ├── em_list_links.md │ │ ├── em_strong_adjacent.html │ │ ├── em_strong_adjacent.md │ │ ├── em_strong_adjacent_mixed.html │ │ ├── em_strong_adjacent_mixed.md │ │ ├── em_strong_complex_nesting.html │ │ ├── em_strong_complex_nesting.md │ │ ├── em_strong_multiline.html │ │ ├── em_strong_multiline.md │ │ ├── em_strong_orphaned_nesting.html │ │ ├── em_strong_orphaned_nesting.md │ │ ├── email_after_space.html │ │ ├── email_after_space.md │ │ ├── emoji_inline.html │ │ ├── emoji_inline.md │ │ ├── emphasis_extra tests.html │ │ ├── emphasis_extra tests.md │ │ ├── empty_heading_following_paragraph.html │ │ ├── empty_heading_following_paragraph.md │ │ ├── empty_heading_following_paragraph_nogfm.html │ │ ├── empty_heading_following_paragraph_nogfm.md │ │ ├── empty_heading_following_table.html │ │ ├── empty_heading_following_table.md │ │ ├── escape_tick.html │ │ ├── escape_tick.md │ │ ├── escape_within_del.html │ │ ├── escape_within_del.md │ │ ├── escape_within_emphasis.html │ │ ├── escape_within_emphasis.md │ │ ├── escaped_angles.html │ │ ├── escaped_angles.md │ │ ├── fences_breaking_paragraphs.html │ │ ├── fences_breaking_paragraphs.md │ │ ├── fences_following_list.html │ │ ├── fences_following_list.md │ │ ├── fences_following_nptable.html │ │ ├── fences_following_nptable.md │ │ ├── fences_following_table.html │ │ ├── fences_following_table.md │ │ ├── fences_with_blankline_following_list_0.html │ │ ├── fences_with_blankline_following_list_0.md │ │ ├── fences_with_blankline_following_list_1.html │ │ ├── fences_with_blankline_following_list_1.md │ │ ├── heading_following_list.html │ │ ├── heading_following_list.md │ │ ├── heading_following_nptable.html │ │ ├── heading_following_nptable.md │ │ ├── heading_following_table.html │ │ ├── heading_following_table.md │ │ ├── hr_following_nptables.html │ │ ├── hr_following_nptables.md │ │ ├── hr_following_tables.html │ │ ├── hr_following_tables.md │ │ ├── hr_list_break.html │ │ ├── hr_list_break.md │ │ ├── html_comments.html │ │ ├── html_comments.md │ │ ├── html_following_list.html │ │ ├── html_following_list.md │ │ ├── html_following_nptable.html │ │ ├── html_following_nptable.md │ │ ├── html_following_table.html │ │ ├── html_following_table.md │ │ ├── html_no_new_line.html │ │ ├── html_no_new_line.md │ │ ├── image_links.html │ │ ├── image_links.md │ │ ├── image_paren.html │ │ ├── image_paren.md │ │ ├── incorrectly_formatted_list_and_hr.html │ │ ├── incorrectly_formatted_list_and_hr.md │ │ ├── indented_details.html │ │ ├── indented_details.md │ │ ├── indented_tables.html │ │ ├── indented_tables.md │ │ ├── inlinecode_following_nptables.html │ │ ├── inlinecode_following_nptables.md │ │ ├── inlinecode_following_tables.html │ │ ├── inlinecode_following_tables.md │ │ ├── lazy_blockquotes.html │ │ ├── lazy_blockquotes.md │ │ ├── lheading_following_nptable.html │ │ ├── lheading_following_nptable.md │ │ ├── lheading_following_table.html │ │ ├── lheading_following_table.md │ │ ├── link_lt.html │ │ ├── link_lt.md │ │ ├── link_tick_redos.html │ │ ├── link_tick_redos.md │ │ ├── link_unbalanced.html │ │ ├── link_unbalanced.md │ │ ├── links.html │ │ ├── links.md │ │ ├── links_paren.html │ │ ├── links_paren.md │ │ ├── list_align_number.html │ │ ├── list_align_number.md │ │ ├── list_align_pedantic.html │ │ ├── list_align_pedantic.md │ │ ├── list_code_header.html │ │ ├── list_code_header.md │ │ ├── list_following_nptable.html │ │ ├── list_following_nptable.md │ │ ├── list_following_table.html │ │ ├── list_following_table.md │ │ ├── list_item_tabs.html │ │ ├── list_item_tabs.md │ │ ├── list_item_text.html │ │ ├── list_item_text.md │ │ ├── list_item_unindented_asterisk.html │ │ ├── list_item_unindented_asterisk.md │ │ ├── list_loose.html │ │ ├── list_loose.md │ │ ├── list_loose_tasks.html │ │ ├── list_loose_tasks.md │ │ ├── list_paren_delimiter.html │ │ ├── list_paren_delimiter.md │ │ ├── list_table.html │ │ ├── list_table.md │ │ ├── list_tasks_non_gfm.html │ │ ├── list_tasks_non_gfm.md │ │ ├── list_with_line_break.html │ │ ├── list_with_line_break.md │ │ ├── multiple_sub_lists.html │ │ ├── multiple_sub_lists.md │ │ ├── nbsp_following_tables.html │ │ ├── nbsp_following_tables.md │ │ ├── nested_code.html │ │ ├── nested_code.md │ │ ├── nested_em.html │ │ ├── nested_em.md │ │ ├── nested_square_link.html │ │ ├── nested_square_link.md │ │ ├── nogfm_hashtag.html │ │ ├── nogfm_hashtag.md │ │ ├── not_a_link.html │ │ ├── not_a_link.md │ │ ├── paragraph-after-list-item.html │ │ ├── paragraph-after-list-item.md │ │ ├── pedantic_heading.html │ │ ├── pedantic_heading.md │ │ ├── pedantic_heading_interrupts_paragraph.html │ │ ├── pedantic_heading_interrupts_paragraph.md │ │ ├── ref_paren.html │ │ ├── ref_paren.md │ │ ├── same_bullet.html │ │ ├── same_bullet.md │ │ ├── setext_blankline.html │ │ ├── setext_blankline.md │ │ ├── setext_no_blankline.html │ │ ├── setext_no_blankline.md │ │ ├── space_after_table.html │ │ ├── space_after_table.md │ │ ├── strikethrough_in_em_strong.html │ │ ├── strikethrough_in_em_strong.md │ │ ├── strong_following_nptables.html │ │ ├── strong_following_nptables.md │ │ ├── strong_following_tables.html │ │ ├── strong_following_tables.md │ │ ├── substitutions.html │ │ ├── substitutions.md │ │ ├── tab_after_blockquote.html │ │ ├── tab_after_blockquote.md │ │ ├── tab_newline.html │ │ ├── tab_newline.md │ │ ├── table_cells.html │ │ ├── table_cells.md │ │ ├── table_following_text.html │ │ ├── table_following_text.md │ │ ├── table_reference_link.html │ │ ├── table_reference_link.md │ │ ├── table_vs_setext.html │ │ ├── table_vs_setext.md │ │ ├── tabs_code.html │ │ ├── tabs_code.md │ │ ├── text_following_nptables.html │ │ ├── text_following_nptables.md │ │ ├── text_following_tables.html │ │ ├── text_following_tables.md │ │ ├── toplevel_paragraphs.html │ │ ├── toplevel_paragraphs.md │ │ ├── tricky_list.html │ │ ├── tricky_list.md │ │ ├── underscore_link.html │ │ ├── underscore_link.md │ │ ├── unicode_punctuation.html │ │ ├── unicode_punctuation.md │ │ ├── whiltespace_lines.html │ │ └── whiltespace_lines.md │ ├── original │ │ ├── amps_and_angles_encoding.html │ │ ├── amps_and_angles_encoding.md │ │ ├── auto_links.html │ │ ├── auto_links.md │ │ ├── backslash_escapes.html │ │ ├── backslash_escapes.md │ │ ├── blockquotes_with_code_blocks.html │ │ ├── blockquotes_with_code_blocks.md │ │ ├── code_blocks.html │ │ ├── code_blocks.md │ │ ├── code_spans.html │ │ ├── code_spans.md │ │ ├── hard_wrapped_paragraphs_with_list_like_lines.html │ │ ├── hard_wrapped_paragraphs_with_list_like_lines.md │ │ ├── horizontal_rules.html │ │ ├── horizontal_rules.md │ │ ├── inline_html_advanced.html │ │ ├── inline_html_advanced.md │ │ ├── inline_html_comments.html │ │ ├── inline_html_comments.md │ │ ├── inline_html_simple.html │ │ ├── inline_html_simple.md │ │ ├── links_inline_style.html │ │ ├── links_inline_style.md │ │ ├── links_reference_style.html │ │ ├── links_reference_style.md │ │ ├── links_shortcut_references.html │ │ ├── links_shortcut_references.md │ │ ├── literal_quotes_in_titles.html │ │ ├── literal_quotes_in_titles.md │ │ ├── markdown_documentation_basics.html │ │ ├── markdown_documentation_basics.md │ │ ├── markdown_documentation_syntax.html │ │ ├── markdown_documentation_syntax.md │ │ ├── nested_blockquotes.html │ │ ├── nested_blockquotes.md │ │ ├── ordered_and_unordered_lists.html │ │ ├── ordered_and_unordered_lists.md │ │ ├── tabs.html │ │ ├── tabs.md │ │ ├── tidyness.html │ │ └── tidyness.md │ └── redos │ │ ├── cubic_def.cjs │ │ ├── link_code.html │ │ ├── link_code.md │ │ ├── link_redos.html │ │ ├── link_redos.md │ │ ├── quadratic_br.cjs │ │ ├── quadratic_em_mask.cjs │ │ ├── quadratic_email.cjs │ │ ├── quadratic_heading.cjs │ │ ├── quadratic_lists.cjs │ │ ├── quadratic_underscores.cjs │ │ ├── redos_html_closing.html │ │ ├── redos_html_closing.md │ │ ├── redos_nolink.html │ │ ├── redos_nolink.md │ │ ├── reflink_redos.html │ │ └── reflink_redos.md ├── types │ └── marked.ts ├── umd-test.js ├── unit │ ├── Hooks.test.js │ ├── Lexer.test.js │ ├── Parser.test.js │ ├── bin.test.js │ ├── fixtures │ │ └── bin-config.js │ ├── instance.test.js │ ├── marked.test.js │ └── utils.js └── update-specs.js ├── tsconfig-type-test.json ├── tsconfig.json └── vercel.json /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node 3 | { 4 | "name": "marked", 5 | // We're using node 14 for development, to keep close to the engine compatibility that marked.js uses. 6 | "image": "mcr.microsoft.com/devcontainers/javascript-node:0-14", 7 | "postCreateCommand": "npm install", 8 | 9 | // Configure tool-specific properties. 10 | "customizations": { 11 | // Configure properties specific to VS Code. 12 | "vscode": { 13 | "extensions": [ 14 | "dbaeumeur.vscode-eslint" 15 | ] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{json,js}] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | 10 | [*.md, !test/*.md] 11 | charset = utf-8 12 | end_of_line = lf 13 | insert_final_newline = true 14 | trim_trailing_whitespace = true 15 | indent_style = tab 16 | indent_size = 4 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * eol=lf 2 | test/* linguist-vendored 3 | lib/* linguist-generated 4 | marked.min.js linguist-generated 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Marked version:** 2 | 3 | **Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a 4 | 5 | 6 | 7 | 18 | 19 | ## Expectation 20 | 21 | **CommonMark Demo:** [demo](https://spec.commonmark.org/dingus/) 22 | 23 | 24 | 25 | 26 | ## Result 27 | 28 | **Marked Demo:** [demo](https://marked.js.org/demo/) 29 | 30 | 31 | 32 | 33 | ## What was attempted 34 | 35 | 36 | 37 | 43 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Marked says it does this thing but does not 4 | 5 | --- 6 | **Marked version:** 7 | 8 | **Describe the bug** 9 | A clear and concise description of what the bug is. 10 | 11 | **To Reproduce** 12 | Steps to reproduce the behavior: 13 | 14 | 15 | 19 | 20 | 21 | 26 | 27 | **Expected behavior** 28 | A clear and concise description of what you expected to happen. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Marked doesn't do this thing and I think it should 4 | 5 | --- 6 | 7 | **Describe the feature** 8 | A clear and concise description of what you would like. 9 | 10 | **Why is this feature necessary?** 11 | A clear and concise description of why. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Proposal.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Proposal 3 | about: Marked doesn't do this thing and I think it should 4 | 5 | --- 6 | 7 | **What pain point are you perceiving?.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | **Marked version:** 12 | 13 | 14 | 15 | **Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a 16 | 17 | ## Description 18 | 19 | - Fixes #### (if fixing a known issue; otherwise, describe issue using the following format) 20 | 21 | 38 | 39 | ## Contributor 40 | 41 | - [ ] Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or, 42 | - [ ] no tests required for this PR. 43 | - [ ] If submitting new feature, it has been documented in the appropriate places. 44 | 45 | ## Committer 46 | 47 | In most cases, this should be a different person than the contributor. 48 | 49 | - [ ] CI is green (no forced merge required). 50 | - [ ] Squash and Merge PR following [conventional commit guidelines](https://www.conventionalcommits.org/). 51 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/badges.md: -------------------------------------------------------------------------------- 1 | **@mention the contributor:** 2 | 3 | ## Recommendation to: 4 | 5 | - [ ] Change user group 6 | - [ ] Add a badge 7 | - [ ] Remove a badge 8 | 9 | 16 | 17 | ## As the one mentioned, I would like to: 18 | 19 | - [ ] accept the recommendation; or, 20 | - [ ] graciously decline; or, 21 | - [ ] dispute the recommendation 22 | 23 | within 30 days, if you have not indicated which option you are taking one of the following will happen: 24 | 25 | 1. If adding a badge, we will assume you are graciously declining. 26 | 2. If removing a badge, we will assume you do not want to dispute the recommendation; therefore, the badge will be removed. 27 | 28 | 49 | 50 | Note: All committers must approve via review before merging, the disapproving committer can simply close the PR. 51 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | - package-ecosystem: "npm" 8 | versioning-strategy: "increase" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: "Tests" 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - master 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | UnitTests: 13 | strategy: 14 | matrix: 15 | # lowest verison here should also be in `engines` field 16 | node_version: [18, "lts/*", "latest"] 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout Code 20 | uses: actions/checkout@v4 21 | - name: Install Node 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: ${{ matrix.node_version }} 25 | check-latest: true 26 | - name: Install Dependencies 27 | run: npm ci 28 | - name: Build 🗜️ 29 | run: npm run build 30 | - name: Run Unit Tests 👩🏽‍💻 31 | run: npm run test:unit 32 | - name: Run Spec Tests 👩🏽‍💻 33 | run: npm run test:specs 34 | - name: Run CJS Tests 👩🏽‍💻 35 | run: npm run test:cjs 36 | 37 | OtherTests: 38 | runs-on: ubuntu-latest 39 | steps: 40 | - name: Checkout Code 41 | uses: actions/checkout@v4 42 | - name: Install Node 43 | uses: actions/setup-node@v4 44 | with: 45 | node-version: "lts/*" 46 | - name: Install Dependencies 47 | run: npm ci 48 | - name: Build 🗜️ 49 | run: npm run build 50 | - name: Run UMD Tests 👩🏽‍💻 51 | run: npm run test:umd 52 | - name: Run Types Tests 👩🏽‍💻 53 | run: npm run test:types 54 | - name: Lint ✨ 55 | run: npm run test:lint 56 | 57 | Release: 58 | permissions: 59 | contents: write 60 | id-token: write 61 | needs: [UnitTests, OtherTests] 62 | if: | 63 | github.ref == 'refs/heads/master' && 64 | github.event.repository.fork == false 65 | runs-on: ubuntu-latest 66 | steps: 67 | - name: Checkout Code 68 | uses: actions/checkout@v4 69 | - name: Install Node 70 | uses: actions/setup-node@v4 71 | with: 72 | node-version: "lts/*" 73 | - name: Install Dependencies 74 | run: npm ci 75 | - name: Build 🗜️ 76 | env: 77 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 78 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 79 | run: | 80 | export SEMANTIC_RELEASE_NEXT_VERSION=$(npx semantic-release --no-ci --dry-run | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+') 81 | echo "Next Version: $SEMANTIC_RELEASE_NEXT_VERSION" 82 | npm run build 83 | if ! git diff --quiet; then 84 | git config --global user.email "<>" 85 | git config --global user.name "MarkedJS bot" 86 | git commit -am "🗜️ build v$SEMANTIC_RELEASE_NEXT_VERSION [skip ci]" 87 | fi 88 | - name: Release 🎉 89 | env: 90 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 91 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 92 | run: npx semantic-release 93 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vercel 3 | .vscode 4 | node_modules/ 5 | test/compiled_tests 6 | public 7 | lib 8 | docs/LICENSE.md 9 | vuln.js 10 | man/marked.1 11 | marked.min.js 12 | test.js 13 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "@semantic-release/commit-analyzer", 4 | "@semantic-release/release-notes-generator", 5 | "@semantic-release/npm", 6 | "@semantic-release/github", 7 | "@semantic-release/git" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | see https://github.com/markedjs/marked/releases 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # License information 2 | 3 | ## Contribution License Agreement 4 | 5 | If you contribute code to this project, you are implicitly allowing your code 6 | to be distributed under the MIT license. You are also implicitly verifying that 7 | all code is your original work. `` 8 | 9 | ## Marked 10 | 11 | Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/) 12 | Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/) 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | 32 | ## Markdown 33 | 34 | Copyright © 2004, John Gruber 35 | http://daringfireball.net/ 36 | All rights reserved. 37 | 38 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 39 | 40 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 41 | * 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. 42 | * 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. 43 | 44 | 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. 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | # Marked 6 | 7 | [![npm](https://badgen.net/npm/v/marked)](https://www.npmjs.com/package/marked) 8 | [![install size](https://badgen.net/packagephobia/install/marked)](https://packagephobia.now.sh/result?p=marked) 9 | [![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked) 10 | [![github actions](https://github.com/markedjs/marked/workflows/Tests/badge.svg)](https://github.com/markedjs/marked/actions) 11 | [![snyk](https://snyk.io/test/npm/marked/badge.svg)](https://snyk.io/test/npm/marked) 12 | 13 | - ⚡ built for speed 14 | - ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time 15 | - ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications 16 | - 🌐 works in a browser, on a server, or from a command line interface (CLI) 17 | 18 | ## Demo 19 | 20 | Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️ 21 | 22 | ## Docs 23 | 24 | Our [documentation pages](https://marked.js.org) are also rendered using marked 💯 25 | 26 | Also read about: 27 | 28 | * [Options](https://marked.js.org/using_advanced) 29 | * [Extensibility](https://marked.js.org/using_pro) 30 | 31 | ## Compatibility 32 | 33 | **Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time. 34 | 35 | **Browser:** Not IE11 :) 36 | 37 | ## Installation 38 | 39 | **CLI:** 40 | 41 | ```sh 42 | npm install -g marked 43 | ``` 44 | 45 | **In-browser:** 46 | 47 | ```sh 48 | npm install marked 49 | ``` 50 | 51 | ## Usage 52 | 53 | ### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/using_advanced#options) the output HTML. Please use a sanitize library, like [DOMPurify](https://github.com/cure53/DOMPurify) (recommended), [sanitize-html](https://github.com/apostrophecms/sanitize-html) or [insane](https://github.com/bevacqua/insane) on the *output* HTML! 🚨 54 | 55 | ``` 56 | DOMPurify.sanitize(marked.parse(``)); 57 | ``` 58 | 59 | **CLI** 60 | 61 | ``` bash 62 | # Example with stdin input 63 | $ marked -o hello.html 64 | hello world 65 | ^D 66 | $ cat hello.html 67 |

hello world

68 | ``` 69 | 70 | ```bash 71 | # Print all options 72 | $ marked --help 73 | ``` 74 | 75 | **Browser** 76 | 77 | ```html 78 | 79 | 80 | 81 | 82 | Marked in the browser 83 | 84 | 85 |
86 | 87 | 91 | 92 | 93 | ``` 94 | or import esm module 95 | 96 | ```html 97 | 102 | ``` 103 | 104 | ## License 105 | 106 | Copyright (c) 2011-2022, Christopher Jeffrey. (MIT License) 107 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | The only completely secure system is the one that doesn't exist in the first place. 4 | Having said that, we take the security of Marked very seriously. 5 | 6 | ## Reporting a Vulnerability 7 | 8 | Please disclose potential security issues by email to the project [committers](https://marked.js.org/authors) as well as the [listed owners within NPM](https://docs.npmjs.com/cli/owner). 9 | We will provide an initial assessment of security reports within 48 hours and should apply patches within 2 weeks 10 | (also, feel free to contribute a fix for the issue). 11 | 12 | -------------------------------------------------------------------------------- /api/dingus.js: -------------------------------------------------------------------------------- 1 | import { marked } from '../lib/marked.esm.js'; 2 | import pkg from '../package.json' with { type: 'json' }; 3 | 4 | const version = pkg.version; 5 | const name = 'Marked'; 6 | 7 | export default function dingus(req, res) { 8 | if (req.method !== 'GET') { 9 | return res.status(405).json({ 10 | error: { 11 | code: 'method_not_allowed', 12 | message: 'Only GET requests are supported for this endpoint.', 13 | }, 14 | }); 15 | } 16 | const { text = '' } = req.query; 17 | const html = marked(text); 18 | res.json({ name, version, html }); 19 | } 20 | -------------------------------------------------------------------------------- /bin/marked.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Marked CLI 5 | * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License) 6 | */ 7 | 8 | import { main } from './main.js'; 9 | 10 | /** 11 | * Expose / Entry Point 12 | */ 13 | 14 | process.title = 'marked'; 15 | main(process); 16 | -------------------------------------------------------------------------------- /docs/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "standard", 3 | "parserOptions": { 4 | "ecmaVersion": 2015, 5 | "sourceType": "script" 6 | }, 7 | "rules": { 8 | "semi": ["error", "always"], 9 | "indent": ["error", 2, { 10 | "SwitchCase": 1, 11 | "VariableDeclarator": { "var": 2 }, 12 | "outerIIFEBody": 0 13 | }], 14 | "operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }], 15 | "space-before-function-paren": ["error", "never"], 16 | "no-cond-assign": "off", 17 | "no-useless-escape": "off", 18 | "one-var": "off", 19 | "no-control-regex": "off", 20 | "no-prototype-builtins": "off", 21 | 22 | "prefer-const": "error", 23 | "no-var": "error" 24 | }, 25 | "env": { 26 | "node": true, 27 | "browser": true, 28 | "amd": true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /docs/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to block temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team by submitting a PR with changes to the [AUTHORS](/authors) page (or emailing josh@8fold.com). All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 71 | version [1.4][version]. 72 | 73 | [homepage]: https://www.contributor-covenant.org/ 74 | [version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 75 | -------------------------------------------------------------------------------- /docs/PUBLISHING.md: -------------------------------------------------------------------------------- 1 | # Releasing Marked 2 | 3 | Marked uses [semantic-release](https://github.com/semantic-release/semantic-release) to release new versions. All PRs should use the "Squash and merge" strategy and the commit message should follow the [conventional commit guidelines](https://www.conventionalcommits.org/). 4 | 5 | ## Overall strategy 6 | 7 | **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 features, bug fixes, and so on. 8 | 9 | ## Versioning 10 | 11 | We follow [semantic versioning](https://semver.org) where the following sequence is true `[major].[minor].[patch]`: 12 | 13 | 1. **Major:** There is at least one change to the public API or a break from the [CommonMark](https://spec.commonmark.org/current/) or [GFM](https://github.github.com/gfm/) spec. Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported at any point in time. A drop in support for a Node.js version may not result in a semver major bump to Marked. 14 | 2. **Minor:** There is at least one new feature added to the public API. 15 | 3. **Patch:** Changes that move Marked closer to spec compliance or change a public API that does not break backwards compatibility. 16 | -------------------------------------------------------------------------------- /docs/css/hljs-github.css: -------------------------------------------------------------------------------- 1 | /*! 2 | Theme: GitHub 3 | Description: Light theme as seen on github.com 4 | Author: github.com 5 | Maintainer: @Hirse 6 | Updated: 2021-05-15 7 | 8 | Outdated base version: https://github.com/primer/github-syntax-light 9 | Current colors taken from GitHub's CSS 10 | */ 11 | 12 | .hljs { 13 | color: #24292e; 14 | background: #ffffff; 15 | } 16 | 17 | .hljs-doctag, 18 | .hljs-keyword, 19 | .hljs-meta .hljs-keyword, 20 | .hljs-template-tag, 21 | .hljs-template-variable, 22 | .hljs-type, 23 | .hljs-variable.language_ { 24 | /* prettylights-syntax-keyword */ 25 | color: #d73a49; 26 | } 27 | 28 | .hljs-title, 29 | .hljs-title.class_, 30 | .hljs-title.class_.inherited__, 31 | .hljs-title.function_ { 32 | /* prettylights-syntax-entity */ 33 | color: #6f42c1; 34 | } 35 | 36 | .hljs-attr, 37 | .hljs-attribute, 38 | .hljs-literal, 39 | .hljs-meta, 40 | .hljs-number, 41 | .hljs-operator, 42 | .hljs-variable, 43 | .hljs-selector-attr, 44 | .hljs-selector-class, 45 | .hljs-selector-id { 46 | /* prettylights-syntax-constant */ 47 | color: #005cc5; 48 | } 49 | 50 | .hljs-regexp, 51 | .hljs-string, 52 | .hljs-meta .hljs-string { 53 | /* prettylights-syntax-string */ 54 | color: #032f62; 55 | } 56 | 57 | .hljs-built_in, 58 | .hljs-symbol { 59 | /* prettylights-syntax-variable */ 60 | color: #e36209; 61 | } 62 | 63 | .hljs-comment, 64 | .hljs-code, 65 | .hljs-formula { 66 | /* prettylights-syntax-comment */ 67 | color: #6a737d; 68 | } 69 | 70 | .hljs-name, 71 | .hljs-quote, 72 | .hljs-selector-tag, 73 | .hljs-selector-pseudo { 74 | /* prettylights-syntax-entity-tag */ 75 | color: #22863a; 76 | } 77 | 78 | .hljs-subst { 79 | /* prettylights-syntax-storage-modifier-import */ 80 | color: #24292e; 81 | } 82 | 83 | .hljs-section { 84 | /* prettylights-syntax-markup-heading */ 85 | color: #005cc5; 86 | font-weight: bold; 87 | } 88 | 89 | .hljs-bullet { 90 | /* prettylights-syntax-markup-list */ 91 | color: #735c0f; 92 | } 93 | 94 | .hljs-emphasis { 95 | /* prettylights-syntax-markup-italic */ 96 | color: #24292e; 97 | font-style: italic; 98 | } 99 | 100 | .hljs-strong { 101 | /* prettylights-syntax-markup-bold */ 102 | color: #24292e; 103 | font-weight: bold; 104 | } 105 | 106 | .hljs-addition { 107 | /* prettylights-syntax-markup-inserted */ 108 | color: #22863a; 109 | background-color: #f0fff4; 110 | } 111 | 112 | .hljs-deletion { 113 | /* prettylights-syntax-markup-deleted */ 114 | color: #b31d28; 115 | background-color: #ffeef0; 116 | } 117 | 118 | .hljs-char.escape_, 119 | .hljs-link, 120 | .hljs-params, 121 | .hljs-property, 122 | .hljs-punctuation, 123 | .hljs-tag { 124 | /* purposely ignored */ 125 | } 126 | -------------------------------------------------------------------------------- /docs/css/shared.css: -------------------------------------------------------------------------------- 1 | .github-corner { 2 | position: absolute; 3 | top: 0; 4 | border: 0; 5 | right: 0; 6 | } 7 | 8 | .github-corner:hover .octo-arm { 9 | animation:octocat-wave 560ms ease-in-out; 10 | } 11 | 12 | @keyframes octocat-wave { 13 | 0%,100%{transform:rotate(0)} 14 | 20%,60%{transform:rotate(-25deg)} 15 | 40%,80%{transform:rotate(10deg)} 16 | } 17 | 18 | @media (max-width:500px) { 19 | .github-corner:hover .octo-arm { 20 | animation:none 21 | } 22 | 23 | .github-corner .octo-arm { 24 | animation:octocat-wave 560ms ease-in-out; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; 3 | font-size: 16px; 4 | line-height: 1.5; 5 | word-wrap: break-word; 6 | background: #F9F9F9; 7 | } 8 | 9 | #container { 10 | max-width: 900px; 11 | margin: auto; 12 | } 13 | 14 | #content { 15 | padding: 5px 10px; 16 | border: 1px solid #ddd; 17 | border-radius: 3px; 18 | background: white; 19 | } 20 | 21 | #content h1:first-child { 22 | margin-top: 0px; 23 | } 24 | 25 | nav { 26 | border: 1px solid #ddd; 27 | border-radius: 3px; 28 | background: white; 29 | margin-right: 10px; 30 | } 31 | 32 | nav > ul { 33 | position: sticky; 34 | top: 5px; 35 | margin: 10px 0px; 36 | padding: 0; 37 | list-style-type: none; 38 | font-size: 14px; 39 | } 40 | 41 | nav > ul > li { 42 | min-width: 125px; 43 | padding: 0px 15px; 44 | } 45 | 46 | nav > ul > li > ul { 47 | padding-left: 25px; 48 | } 49 | 50 | nav > ul > li > ul > li { 51 | font-size: 0.8em; 52 | } 53 | 54 | nav .selected { 55 | color: #111; 56 | font-weight: bold; 57 | } 58 | 59 | nav .selected:hover { 60 | text-decoration: none; 61 | } 62 | 63 | header { 64 | display: flex; 65 | } 66 | 67 | header h1 { margin: 0; } 68 | 69 | table { 70 | border-spacing: 0; 71 | border-collapse: collapse; 72 | border: 1px solid #ddd; 73 | } 74 | 75 | td, th { 76 | border: 1px solid #ddd; 77 | padding: 5px; 78 | } 79 | 80 | a { 81 | color: #0366d6; 82 | text-decoration: none; 83 | } 84 | 85 | a:hover { 86 | text-decoration: underline; 87 | } 88 | 89 | pre { 90 | font-family: "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace; 91 | padding: 16px; 92 | overflow: auto; 93 | font-size: 85%; 94 | line-height: 1.45; 95 | background-color: #f6f8fa; 96 | border-radius: 3px; 97 | position: relative; 98 | max-width: 680px; 99 | } 100 | 101 | pre code { 102 | max-width: 680px; 103 | overflow: auto; 104 | display: block; 105 | } 106 | 107 | :not(pre) > code { 108 | padding: 0.2em 0.4em; 109 | margin: 0; 110 | font-size: 85%; 111 | background-color: #f6f8fa; 112 | border-radius: 3px; 113 | } 114 | 115 | summary { 116 | cursor: pointer; 117 | padding: 3px 0px; 118 | } 119 | 120 | summary:hover { 121 | color: #0366d6; 122 | } 123 | 124 | .div-copy { 125 | position: absolute; 126 | top: 0; 127 | right: 0; 128 | } 129 | 130 | .div-copy .icon-copy { 131 | opacity: 0; 132 | transition: opacity .3s; 133 | height: 18px; 134 | width: 18px; 135 | cursor: pointer; 136 | padding: 5px; 137 | } 138 | 139 | .div-copy.active .icon-copy { 140 | opacity: 1; 141 | } 142 | 143 | .div-copy .tooltip-copy { 144 | position: relative; 145 | } 146 | 147 | .div-copy .tooltip-copy::before { 148 | content: "Copied"; 149 | position: absolute; 150 | 151 | /* vertically center */ 152 | top: 50%; 153 | transform: translateY(-50%); 154 | 155 | /* move to right */ 156 | right: 100%; 157 | margin-right: 5px; /* and add a small left margin */ 158 | 159 | /* basic styles */ 160 | padding: 2px 7px; 161 | border-radius: 5px; 162 | background: #444; 163 | color: #fff; 164 | text-align: center; 165 | 166 | opacity: 0; /* hide by default */ 167 | transition: opacity .3s; 168 | } 169 | 170 | .div-copy.click .tooltip-copy::before { 171 | opacity: 1; 172 | } 173 | 174 | .div-copy .tooltip-copy::after { 175 | content: ""; 176 | position: absolute; 177 | 178 | /* position tooltip correctly */ 179 | right: 100%; 180 | margin-right: -5px; 181 | 182 | /* vertically center */ 183 | top: 50%; 184 | transform: translateY(-50%); 185 | 186 | /* the arrow */ 187 | border-style: solid; 188 | border-width: 2px 2px 5px 8px; 189 | border-color: transparent transparent transparent #444; 190 | 191 | opacity: 0; 192 | transition: opacity .3s; 193 | } 194 | 195 | .div-copy.click .tooltip-copy::after { 196 | opacity: 1; 197 | } 198 | -------------------------------------------------------------------------------- /docs/demo/demo.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 5 | color: #333; 6 | background-color: #fbfbfb; 7 | height: 100%; 8 | overflow: auto; 9 | } 10 | 11 | textarea { 12 | font-family: Menlo, Monaco, Consolas, "Courier New", monospace; 13 | font-size: 12px; 14 | resize: none; 15 | } 16 | 17 | header { 18 | padding-top: 10px; 19 | display: flex; 20 | height: 58px; 21 | } 22 | 23 | header h1 { 24 | margin: 0; 25 | } 26 | 27 | .other-demos { 28 | margin-left: 3em; 29 | } 30 | 31 | .containers { 32 | display: flex; 33 | height: calc(100vh - 68px); 34 | } 35 | 36 | .container { 37 | flex-basis: 50%; 38 | padding: 5px; 39 | display: flex; 40 | flex-direction: column; 41 | height: 100%; 42 | box-sizing: border-box; 43 | } 44 | 45 | .pane, .inputPane { 46 | margin-top: 5px; 47 | padding: 0.6em; 48 | border: 1px solid #ccc; 49 | overflow: auto; 50 | flex-grow: 1; 51 | flex-shrink: 1; 52 | } 53 | 54 | #preview { 55 | display: flex; 56 | } 57 | 58 | #preview iframe { 59 | flex-grow: 1; 60 | } 61 | 62 | #main { 63 | display: none; 64 | } 65 | 66 | .error { 67 | border-color: red; 68 | background-color: #FEE 69 | } 70 | 71 | .loadingError { 72 | background-color: #fee; 73 | font-weight: bold; 74 | color: #f00; 75 | text-align: center; 76 | padding: 10px; 77 | } 78 | 79 | #responseTime { 80 | display: inline-block; 81 | } 82 | -------------------------------------------------------------------------------- /docs/demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Marked Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 |
20 | 21 | 22 | 23 |

Marked Demo

24 |
25 | CommonMark Demo 26 |
27 | Daring Fireball (pedantic) Demo 28 |
29 |
30 | 31 |
Loading...
32 |
33 |
34 |
35 |
36 | Input · 37 | · 38 | Version: 39 | · 42 | 43 | 47 |
48 | 49 | 50 |
51 | 52 |
53 |
54 | · 60 | Response Time: 61 | 62 |
63 | 64 |
65 | 68 | 69 |
70 | 71 | 72 | 73 | 74 | 75 | 76 |
77 |
78 |
79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /docs/demo/initial.md: -------------------------------------------------------------------------------- 1 | Marked - Markdown Parser 2 | ======================== 3 | 4 | [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. 5 | 6 | How To Use The Demo 7 | ------------------- 8 | 9 | 1. Type in stuff on the left. 10 | 2. See the live updates on the right. 11 | 12 | That's it. Pretty simple. There's also a drop-down option above to switch between various views: 13 | 14 | - **Preview:** A live display of the generated HTML as it would render in a browser. 15 | - **HTML Source:** The generated HTML before your browser makes it pretty. 16 | - **Lexer Data:** What [marked] uses internally, in case you like gory stuff like this. 17 | - **Quick Reference:** A brief run-down of how to format things using markdown. 18 | 19 | Why Markdown? 20 | ------------- 21 | 22 | It's easy. It's not overly bloated, unlike HTML. Also, as the creator of [markdown] says, 23 | 24 | > The overriding design goal for Markdown's 25 | > formatting syntax is to make it as readable 26 | > as possible. The idea is that a 27 | > Markdown-formatted document should be 28 | > publishable as-is, as plain text, without 29 | > looking like it's been marked up with tags 30 | > or formatting instructions. 31 | 32 | Ready to start writing? Either start changing stuff on the left or 33 | [clear everything](/demo/?text=) with a simple click. 34 | 35 | [Marked]: https://github.com/markedjs/marked/ 36 | [Markdown]: http://daringfireball.net/projects/markdown/ 37 | -------------------------------------------------------------------------------- /docs/demo/preview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | marked.js preview 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markedjs/marked/045ca84cfe522d5cc21aaf298fcaddd0c1af53c6/docs/favicon.ico -------------------------------------------------------------------------------- /docs/img/copy-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 17 | 20 | 23 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /docs/js/index.js: -------------------------------------------------------------------------------- 1 | const match = /#\/(.+)\\.md(.*)/g.exec(window.location.hash); 2 | if (match && match[1]) { 3 | // Redirect from URL format to new URL, for example: 4 | // Old: https://marked.js.org/#/USING_PRO.md#renderer 5 | // New: https://marked.js.org/using_pro#renderer 6 | const pageName = match[1].toLowerCase(); 7 | const sectionName = match[2]; 8 | window.location.href = '/' + pageName + sectionName; 9 | } 10 | 11 | const navLinks = document.querySelectorAll('nav a'); 12 | 13 | function hashChange() { 14 | const fullUrl = window.location.href; 15 | navLinks.forEach(function(link) { 16 | link.className = link.href === fullUrl ? 'selected' : ''; 17 | }); 18 | } 19 | 20 | window.addEventListener('hashchange', function(e) { 21 | e.preventDefault(); 22 | hashChange(); 23 | }); 24 | 25 | hashChange(); 26 | 27 | document.addEventListener('DOMContentLoaded', function() { 28 | const div = document.createElement('div'); 29 | div.innerHTML = '
'; 30 | div.className = 'div-copy'; 31 | 32 | const allPres = document.querySelectorAll('pre'); 33 | allPres.forEach(function(pre) { 34 | let timeout = null; 35 | const copy = div.cloneNode(true); 36 | pre.appendChild(copy); 37 | pre.onmouseover = function() { 38 | copy.classList.add('active'); 39 | }; 40 | pre.onmouseleave = function() { 41 | clearTimeout(timeout); 42 | copy.classList.remove('active'); 43 | copy.classList.remove('click'); 44 | }; 45 | copy.onclick = function() { 46 | navigator.clipboard.writeText(pre.textContent); 47 | copy.classList.add('click'); 48 | clearTimeout(timeout); 49 | timeout = setTimeout(function() { 50 | copy.classList.remove('click'); 51 | }, 3000); 52 | }; 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /esbuild.config.js: -------------------------------------------------------------------------------- 1 | import * as esbuild from 'esbuild'; 2 | import { umdWrapper } from 'esbuild-plugin-umd-wrapper'; 3 | import fs from 'fs'; 4 | 5 | const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(fs.readFileSync('./package.json')).version; 6 | 7 | console.log('building version:', version); 8 | 9 | const banner = `/** 10 | * marked v${version} - a markdown parser 11 | * Copyright (c) 2011-${new Date().getFullYear()}, Christopher Jeffrey. (MIT Licensed) 12 | * https://github.com/markedjs/marked 13 | */ 14 | 15 | /** 16 | * DO NOT EDIT THIS FILE 17 | * The code in this file is generated from files in ./src/ 18 | */ 19 | `; 20 | 21 | function config(options) { 22 | return { 23 | entryPoints: ['src/marked.ts'], 24 | banner: { 25 | js: banner, 26 | }, 27 | sourcemap: true, 28 | bundle: true, 29 | minify: false, 30 | ...(options.format === 'umd' 31 | ? { 32 | plugins: [umdWrapper({ 33 | libraryName: 'marked', 34 | })], 35 | } 36 | : {}), 37 | ...options, 38 | }; 39 | } 40 | 41 | await esbuild.build(config({ 42 | format: 'esm', 43 | outfile: 'lib/marked.esm.js', 44 | })); 45 | 46 | await esbuild.build(config({ 47 | format: 'cjs', 48 | outfile: 'lib/marked.cjs', 49 | })); 50 | 51 | await esbuild.build(config({ 52 | format: 'umd', 53 | outfile: 'lib/marked.umd.js', 54 | })); 55 | 56 | await esbuild.build(config({ 57 | sourcemap: false, 58 | minify: true, 59 | format: 'umd', 60 | outfile: 'marked.min.js', 61 | })); 62 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import markedEslintConfig from '@markedjs/eslint-config'; 2 | 3 | export default [ 4 | { 5 | ignores: ['**/lib', '**/*.min.js', '**/public'], 6 | }, 7 | ...markedEslintConfig, 8 | ]; 9 | -------------------------------------------------------------------------------- /man/marked.1.md: -------------------------------------------------------------------------------- 1 | # marked(1) -- a javascript markdown parser 2 | 3 | ## SYNOPSIS 4 | 5 | `marked` [`-o` ] [`-i` ] [`-s` ] [`-c` ] [`--help`] [`--version`] [`--tokens`] [`--no-clobber`] [`--pedantic`] [`--gfm`] [`--breaks`] [`--no-etc...`] [`--silent`] [filename] 6 | 7 | ## DESCRIPTION 8 | 9 | marked is a full-featured javascript markdown parser, built for speed. 10 | It also includes multiple GFM features. 11 | 12 | ## EXAMPLES 13 | 14 | ```sh 15 | cat in.md | marked > out.html 16 | ``` 17 | 18 | ```sh 19 | echo "hello *world*" | marked 20 | ``` 21 | 22 | ```sh 23 | marked -o out.html -i in.md --gfm 24 | ``` 25 | 26 | ```sh 27 | marked --output="hello world.html" -i in.md --no-breaks 28 | ``` 29 | 30 | ## OPTIONS 31 | 32 | * -o, --output [output file] 33 | Specify file output. If none is specified, write to stdout. 34 | 35 | * -i, --input [input file] 36 | Specify file input, otherwise use last argument as input file. 37 | If no input file is specified, read from stdin. 38 | 39 | * -s, --string [markdown string] 40 | Specify string input instead of a file. 41 | 42 | * -c, --config [config file] 43 | Specify config file to use instead of the default `~/.marked.json` or `~/.marked.js` or `~/.marked/index.js`. 44 | 45 | * -t, --tokens 46 | Output a token list instead of html. 47 | 48 | * -n, --no-clobber 49 | Do not overwrite `output` if it exists. 50 | 51 | * --pedantic 52 | Conform to obscure parts of markdown.pl as much as possible. 53 | Don't fix original markdown bugs. 54 | 55 | * --gfm 56 | Enable github flavored markdown. 57 | 58 | * --breaks 59 | Enable GFM line breaks. Only works with the gfm option. 60 | 61 | * --no-breaks, -no-etc... 62 | The inverse of any of the marked options above. 63 | 64 | * --silent 65 | Silence error output. 66 | 67 | * -h, --help 68 | Display help information. 69 | 70 | ## CONFIGURATION 71 | 72 | For configuring and running programmatically. 73 | 74 | Example 75 | 76 | ```js 77 | import { Marked } from 'marked'; 78 | const marked = new Marked({ gfm: true }); 79 | marked.parse('*foo*'); 80 | ``` 81 | 82 | ## BUGS 83 | 84 | Please report any bugs to . 85 | 86 | ## LICENSE 87 | 88 | Copyright (c) 2011-2014, Christopher Jeffrey (MIT License). 89 | 90 | ## SEE ALSO 91 | 92 | markdown(1), nodejs(1) 93 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "marked", 3 | "description": "A markdown parser built for speed", 4 | "author": "Christopher Jeffrey", 5 | "version": "15.0.12", 6 | "type": "module", 7 | "main": "./lib/marked.cjs", 8 | "module": "./lib/marked.esm.js", 9 | "browser": "./lib/marked.umd.js", 10 | "types": "./lib/marked.d.ts", 11 | "bin": { 12 | "marked": "bin/marked.js" 13 | }, 14 | "man": "./man/marked.1", 15 | "files": [ 16 | "bin/", 17 | "lib/", 18 | "man/", 19 | "marked.min.js" 20 | ], 21 | "exports": { 22 | ".": { 23 | "import": { 24 | "types": "./lib/marked.d.ts", 25 | "default": "./lib/marked.esm.js" 26 | }, 27 | "default": { 28 | "types": "./lib/marked.d.cts", 29 | "default": "./lib/marked.cjs" 30 | } 31 | }, 32 | "./bin/marked": "./bin/marked.js", 33 | "./marked.min.js": "./marked.min.js", 34 | "./package.json": "./package.json" 35 | }, 36 | "publishConfig": { 37 | "provenance": true 38 | }, 39 | "repository": { 40 | "type": "git", 41 | "url": "git://github.com/markedjs/marked.git" 42 | }, 43 | "homepage": "https://marked.js.org", 44 | "bugs": { 45 | "url": "http://github.com/markedjs/marked/issues" 46 | }, 47 | "license": "MIT", 48 | "keywords": [ 49 | "markdown", 50 | "markup", 51 | "html" 52 | ], 53 | "tags": [ 54 | "markdown", 55 | "markup", 56 | "html" 57 | ], 58 | "devDependencies": { 59 | "@arethetypeswrong/cli": "^0.18.1", 60 | "@markedjs/eslint-config": "^1.0.12", 61 | "@markedjs/testutils": "14.1.1-0", 62 | "@semantic-release/commit-analyzer": "^13.0.1", 63 | "@semantic-release/git": "^10.0.1", 64 | "@semantic-release/github": "^11.0.3", 65 | "@semantic-release/npm": "^12.0.1", 66 | "@semantic-release/release-notes-generator": "^14.0.3", 67 | "cheerio": "1.0.0", 68 | "commonmark": "0.31.2", 69 | "cross-env": "^7.0.3", 70 | "dts-bundle-generator": "^9.5.1", 71 | "esbuild": "^0.25.4", 72 | "esbuild-plugin-umd-wrapper": "^3.0.0", 73 | "eslint": "^9.27.0", 74 | "highlight.js": "^11.11.1", 75 | "markdown-it": "14.1.0", 76 | "marked-highlight": "^2.2.1", 77 | "marked-man": "^2.1.0", 78 | "recheck": "^4.5.0", 79 | "semantic-release": "^24.2.5", 80 | "titleize": "^4.0.0", 81 | "tslib": "^2.8.1", 82 | "typescript": "5.8.3" 83 | }, 84 | "scripts": { 85 | "bench": "npm run build && node test/bench.js", 86 | "build": "npm run build:esbuild && npm run build:types && npm run build:man", 87 | "build:docs": "npm run build && node docs/build.js", 88 | "build:esbuild": "node esbuild.config.js", 89 | "build:man": "marked-man man/marked.1.md > man/marked.1", 90 | "build:reset": "git checkout upstream/master lib/marked.cjs lib/marked.umd.js lib/marked.esm.js marked.min.js", 91 | "build:types": "tsc && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/marked.d.ts src/marked.ts && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/marked.d.cts src/marked.ts", 92 | "lint": "eslint --fix", 93 | "rules": "node test/rules.js", 94 | "test": "npm run build && npm run test:specs && npm run test:unit", 95 | "test:all": "npm test && npm run test:umd && npm run test:cjs && npm run test:types && npm run test:lint", 96 | "test:cjs": "node test/cjs-test.cjs", 97 | "test:lint": "eslint", 98 | "test:only": "npm run build && npm run test:specs:only && npm run test:unit:only", 99 | "test:redos": "node test/recheck.js > vuln.js", 100 | "test:specs:only": "node --test --test-only --test-reporter=spec test/run-spec-tests.js", 101 | "test:specs": "node --test --test-reporter=spec test/run-spec-tests.js", 102 | "test:types": "tsc --project tsconfig-type-test.json && attw -P --exclude-entrypoints ./bin/marked ./marked.min.js", 103 | "test:umd": "node test/umd-test.js", 104 | "test:unit:only": "node --test --test-only --test-reporter=spec test/unit/*.test.js", 105 | "test:unit": "node --test --test-reporter=spec test/unit/*.test.js", 106 | "test:update": "node test/update-specs.js" 107 | }, 108 | "engines": { 109 | "node": ">= 18" 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/Hooks.ts: -------------------------------------------------------------------------------- 1 | import { _defaults } from './defaults.ts'; 2 | import { _Lexer } from './Lexer.ts'; 3 | import { _Parser } from './Parser.ts'; 4 | import type { MarkedOptions } from './MarkedOptions.ts'; 5 | import type { Token, TokensList } from './Tokens.ts'; 6 | 7 | export class _Hooks { 8 | options: MarkedOptions; 9 | block?: boolean; 10 | 11 | constructor(options?: MarkedOptions) { 12 | this.options = options || _defaults; 13 | } 14 | 15 | static passThroughHooks = new Set([ 16 | 'preprocess', 17 | 'postprocess', 18 | 'processAllTokens', 19 | ]); 20 | 21 | /** 22 | * Process markdown before marked 23 | */ 24 | preprocess(markdown: string) { 25 | return markdown; 26 | } 27 | 28 | /** 29 | * Process HTML after marked is finished 30 | */ 31 | postprocess(html: string) { 32 | return html; 33 | } 34 | 35 | /** 36 | * Process all tokens before walk tokens 37 | */ 38 | processAllTokens(tokens: Token[] | TokensList) { 39 | return tokens; 40 | } 41 | 42 | /** 43 | * Provide function to tokenize markdown 44 | */ 45 | provideLexer() { 46 | return this.block ? _Lexer.lex : _Lexer.lexInline; 47 | } 48 | 49 | /** 50 | * Provide function to parse tokens 51 | */ 52 | provideParser() { 53 | return this.block ? _Parser.parse : _Parser.parseInline; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/TextRenderer.ts: -------------------------------------------------------------------------------- 1 | import type { Tokens } from './Tokens.ts'; 2 | 3 | /** 4 | * TextRenderer 5 | * returns only the textual part of the token 6 | */ 7 | export class _TextRenderer { 8 | // no need for block level renderers 9 | strong({ text }: Tokens.Strong) { 10 | return text; 11 | } 12 | 13 | em({ text }: Tokens.Em) { 14 | return text; 15 | } 16 | 17 | codespan({ text }: Tokens.Codespan) { 18 | return text; 19 | } 20 | 21 | del({ text }: Tokens.Del) { 22 | return text; 23 | } 24 | 25 | html({ text }: Tokens.HTML | Tokens.Tag) { 26 | return text; 27 | } 28 | 29 | text({ text }: Tokens.Text | Tokens.Escape | Tokens.Tag) { 30 | return text; 31 | } 32 | 33 | link({ text }: Tokens.Link) { 34 | return '' + text; 35 | } 36 | 37 | image({ text }: Tokens.Image) { 38 | return '' + text; 39 | } 40 | 41 | br() { 42 | return ''; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/defaults.ts: -------------------------------------------------------------------------------- 1 | import type { MarkedOptions } from './MarkedOptions.ts'; 2 | 3 | /** 4 | * Gets the original marked default options. 5 | */ 6 | export function _getDefaults(): MarkedOptions { 7 | return { 8 | async: false, 9 | breaks: false, 10 | extensions: null, 11 | gfm: true, 12 | hooks: null, 13 | pedantic: false, 14 | renderer: null, 15 | silent: false, 16 | tokenizer: null, 17 | walkTokens: null, 18 | }; 19 | } 20 | 21 | export let _defaults = _getDefaults(); 22 | 23 | export function changeDefaults(newDefaults: MarkedOptions) { 24 | _defaults = newDefaults; 25 | } 26 | -------------------------------------------------------------------------------- /src/helpers.ts: -------------------------------------------------------------------------------- 1 | import { other } from './rules.ts'; 2 | 3 | /** 4 | * Helpers 5 | */ 6 | const escapeReplacements: { [index: string]: string } = { 7 | '&': '&', 8 | '<': '<', 9 | '>': '>', 10 | '"': '"', 11 | "'": ''', 12 | }; 13 | const getEscapeReplacement = (ch: string) => escapeReplacements[ch]; 14 | 15 | export function escape(html: string, encode?: boolean) { 16 | if (encode) { 17 | if (other.escapeTest.test(html)) { 18 | return html.replace(other.escapeReplace, getEscapeReplacement); 19 | } 20 | } else { 21 | if (other.escapeTestNoEncode.test(html)) { 22 | return html.replace(other.escapeReplaceNoEncode, getEscapeReplacement); 23 | } 24 | } 25 | 26 | return html; 27 | } 28 | 29 | export function unescape(html: string) { 30 | // explicitly match decimal, hex, and named HTML entities 31 | return html.replace(other.unescapeTest, (_, n) => { 32 | n = n.toLowerCase(); 33 | if (n === 'colon') return ':'; 34 | if (n.charAt(0) === '#') { 35 | return n.charAt(1) === 'x' 36 | ? String.fromCharCode(parseInt(n.substring(2), 16)) 37 | : String.fromCharCode(+n.substring(1)); 38 | } 39 | return ''; 40 | }); 41 | } 42 | 43 | export function cleanUrl(href: string) { 44 | try { 45 | href = encodeURI(href).replace(other.percentDecode, '%'); 46 | } catch { 47 | return null; 48 | } 49 | return href; 50 | } 51 | 52 | export function splitCells(tableRow: string, count?: number) { 53 | // ensure that every cell-delimiting pipe has a space 54 | // before it to distinguish it from an escaped pipe 55 | const row = tableRow.replace(other.findPipe, (match, offset, str) => { 56 | let escaped = false; 57 | let curr = offset; 58 | while (--curr >= 0 && str[curr] === '\\') escaped = !escaped; 59 | if (escaped) { 60 | // odd number of slashes means | is escaped 61 | // so we leave it alone 62 | return '|'; 63 | } else { 64 | // add space before unescaped | 65 | return ' |'; 66 | } 67 | }), 68 | cells = row.split(other.splitPipe); 69 | let i = 0; 70 | 71 | // First/last cell in a row cannot be empty if it has no leading/trailing pipe 72 | if (!cells[0].trim()) { 73 | cells.shift(); 74 | } 75 | if (cells.length > 0 && !cells.at(-1)?.trim()) { 76 | cells.pop(); 77 | } 78 | 79 | if (count) { 80 | if (cells.length > count) { 81 | cells.splice(count); 82 | } else { 83 | while (cells.length < count) cells.push(''); 84 | } 85 | } 86 | 87 | for (; i < cells.length; i++) { 88 | // leading or trailing whitespace is ignored per the gfm spec 89 | cells[i] = cells[i].trim().replace(other.slashPipe, '|'); 90 | } 91 | return cells; 92 | } 93 | 94 | /** 95 | * Remove trailing 'c's. Equivalent to str.replace(/c*$/, ''). 96 | * /c*$/ is vulnerable to REDOS. 97 | * 98 | * @param str 99 | * @param c 100 | * @param invert Remove suffix of non-c chars instead. Default falsey. 101 | */ 102 | export function rtrim(str: string, c: string, invert?: boolean) { 103 | const l = str.length; 104 | if (l === 0) { 105 | return ''; 106 | } 107 | 108 | // Length of suffix matching the invert condition. 109 | let suffLen = 0; 110 | 111 | // Step left until we fail to match the invert condition. 112 | while (suffLen < l) { 113 | const currChar = str.charAt(l - suffLen - 1); 114 | if (currChar === c && !invert) { 115 | suffLen++; 116 | } else if (currChar !== c && invert) { 117 | suffLen++; 118 | } else { 119 | break; 120 | } 121 | } 122 | 123 | return str.slice(0, l - suffLen); 124 | } 125 | 126 | export function findClosingBracket(str: string, b: string) { 127 | if (str.indexOf(b[1]) === -1) { 128 | return -1; 129 | } 130 | 131 | let level = 0; 132 | for (let i = 0; i < str.length; i++) { 133 | if (str[i] === '\\') { 134 | i++; 135 | } else if (str[i] === b[0]) { 136 | level++; 137 | } else if (str[i] === b[1]) { 138 | level--; 139 | if (level < 0) { 140 | return i; 141 | } 142 | } 143 | } 144 | if (level > 0) { 145 | return -2; 146 | } 147 | 148 | return -1; 149 | } 150 | -------------------------------------------------------------------------------- /test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "standard", 3 | "globals": { 4 | "expectAsync": "readonly" 5 | }, 6 | "rules": { 7 | "semi": ["error", "always"], 8 | "indent": ["error", 2, { 9 | "SwitchCase": 1, 10 | "VariableDeclarator": { "var": 2 }, 11 | "outerIIFEBody": 0 12 | }], 13 | "operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }], 14 | "space-before-function-paren": ["error", "never"], 15 | "no-cond-assign": "off", 16 | "no-useless-escape": "off", 17 | "one-var": "off", 18 | "no-control-regex": "off", 19 | "no-prototype-builtins": "off", 20 | 21 | "prefer-const": "error", 22 | "no-var": "error" 23 | }, 24 | "env": { 25 | "node": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/cjs-test.cjs: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-require-imports 2 | const { marked } = require('../lib/marked.cjs'); 3 | 4 | if (!marked.parse('# test').includes(' { 7 | const item = obj[prop]; 8 | const itemName = `${name}.${prop}`; 9 | let source = ''; 10 | let flags = ''; 11 | if (item instanceof RegExp) { 12 | source = item.source; 13 | flags = item.flags; 14 | } else if (typeof item === 'string') { 15 | source = item; 16 | } else { 17 | return checkRegexp(item, itemName); 18 | } 19 | const gfm = itemName.includes('.gfm.'); 20 | const pedantic = itemName.includes('.pedantic.'); 21 | const recheckObj = await check(source, flags); 22 | if (recheckObj.status !== 'safe') { 23 | console.log(`// ${itemName}: /${recheckObj.source}/${recheckObj.flags}`); 24 | console.log(`// marked(${recheckObj.attack.pattern}, { pedantic: ${pedantic ? 'true' : 'false'}, gfm: ${gfm ? 'true' : 'false'} });`); 25 | } 26 | })); 27 | } 28 | 29 | console.log(` 30 | import { marked } from '../lib/marked.esm.js'; 31 | 32 | const start = Date.now(); 33 | `); 34 | 35 | await Promise.all([ 36 | checkRegexp(inline, 'inline'), 37 | checkRegexp(block, 'block'), 38 | ]); 39 | 40 | console.log(` 41 | console.log(Date.now() - start);`); 42 | -------------------------------------------------------------------------------- /test/rules.js: -------------------------------------------------------------------------------- 1 | import { Lexer } from '../lib/marked.esm.js'; 2 | const rules = Lexer.rules; 3 | 4 | const COLOR = { 5 | reset: '\x1b[0m', 6 | bright: '\x1b[1m', 7 | dim: '\x1b[2m', 8 | underscore: '\x1b[4m', 9 | blink: '\x1b[5m', 10 | reverse: '\x1b[7m', 11 | hidden: '\x1b[8m', 12 | 13 | fgBlack: '\x1b[30m', 14 | fgRed: '\x1b[31m', 15 | fgGreen: '\x1b[32m', 16 | fgYellow: '\x1b[33m', 17 | fgBlue: '\x1b[34m', 18 | fgMagenta: '\x1b[35m', 19 | fgCyan: '\x1b[36m', 20 | fgWhite: '\x1b[37m', 21 | 22 | bgBlack: '\x1b[40m', 23 | bgRed: '\x1b[41m', 24 | bgGreen: '\x1b[42m', 25 | bgYellow: '\x1b[43m', 26 | bgBlue: '\x1b[44m', 27 | bgMagenta: '\x1b[45m', 28 | bgCyan: '\x1b[46m', 29 | bgWhite: '\x1b[47m', 30 | }; 31 | 32 | function propsToString(obj) { 33 | if (obj === null) { 34 | return null; 35 | } 36 | if (obj.constructor.name === 'Object') { 37 | if (obj.exec?.name === 'noopTest') { 38 | return null; 39 | } 40 | for (const prop in obj) { 41 | obj[prop] = propsToString(obj[prop]); 42 | } 43 | return obj; 44 | } 45 | return obj.toString(); 46 | } 47 | 48 | let rulesObj = {}; 49 | if (process.argv.length > 2) { 50 | for (let i = 2; i < process.argv.length; i++) { 51 | const rulePath = process.argv[i].split('.'); 52 | let rulesList = rulesObj; 53 | let rule = rules; 54 | while (rulePath.length > 1) { 55 | const prop = rulePath.shift(); 56 | if (!rulesList[prop]) { 57 | rulesList[prop] = {}; 58 | rulesList = rulesList[prop]; 59 | } 60 | if (rule) { 61 | rule = rule[prop]; 62 | } 63 | } 64 | rulesList[rulePath[0]] = rule?.[rulePath[0]] ?? null; 65 | } 66 | } else { 67 | rulesObj = rules; 68 | } 69 | 70 | rulesObj = propsToString(rulesObj); 71 | let output = JSON.stringify(rulesObj, null, 2); 72 | output = output.replace(/^(\s*)"(.*)": null,?$/gm, `$1${COLOR.fgGreen}$2${COLOR.reset}: undefined`); 73 | output = output.replace(/^(\s*)"(.*)": {$/gm, `$1${COLOR.fgGreen}$2${COLOR.reset}: {`); 74 | output = output.replace(/^(\s*)"(.*)": "(.*)",?$/gm, (...p) => { 75 | return `${p[1]}${COLOR.fgGreen}${p[2]}${COLOR.reset}: ${COLOR.fgRed}${p[3].replace(/\\\\/g, '\\')}${COLOR.reset}`; 76 | }); 77 | console.log(output, COLOR.reset); 78 | -------------------------------------------------------------------------------- /test/run-spec-tests.js: -------------------------------------------------------------------------------- 1 | import { Marked } from '../lib/marked.esm.js'; 2 | import { getTests, runTests, outputCompletionTable } from '@markedjs/testutils'; 3 | import { resolve, dirname } from 'node:path'; 4 | import { fileURLToPath } from 'node:url'; 5 | 6 | function parse(markdown, options) { 7 | const marked = new Marked(options); 8 | return marked.parse(markdown); 9 | } 10 | 11 | const __dirname = dirname(fileURLToPath(import.meta.url)); 12 | 13 | const [commonMarkTests, gfmTests, newTests, originalTests, redosTests] = 14 | await getTests([ 15 | resolve(__dirname, './specs/commonmark'), 16 | resolve(__dirname, './specs/gfm'), 17 | resolve(__dirname, './specs/new'), 18 | resolve(__dirname, './specs/original'), 19 | resolve(__dirname, './specs/redos'), 20 | ]); 21 | 22 | outputCompletionTable('CommonMark', commonMarkTests); 23 | runTests({ 24 | tests: commonMarkTests, 25 | parse, 26 | defaultMarkedOptions: { gfm: false, pedantic: false }, 27 | }); 28 | 29 | outputCompletionTable('GFM', gfmTests); 30 | runTests({ 31 | tests: gfmTests, 32 | parse, 33 | defaultMarkedOptions: { gfm: true, pedantic: false }, 34 | }); 35 | 36 | runTests({ 37 | tests: newTests, 38 | parse, 39 | }); 40 | 41 | runTests({ 42 | tests: originalTests, 43 | parse, 44 | defaultMarkedOptions: { gfm: false, pedantic: true }, 45 | }); 46 | 47 | runTests({ 48 | tests: redosTests, 49 | parse, 50 | }); 51 | -------------------------------------------------------------------------------- /test/specs/new/adjacent_lists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • This should be
  • 3 |
  • An unordered list
  • 4 |
5 | 6 |
    7 |
  1. This should be
  2. 8 |
  3. An unordered list
  4. 9 |
10 | -------------------------------------------------------------------------------- /test/specs/new/adjacent_lists.md: -------------------------------------------------------------------------------- 1 | * This should be 2 | * An unordered list 3 | 4 | 1. This should be 5 | 2. An unordered list 6 | -------------------------------------------------------------------------------- /test/specs/new/autolink_after_link.html: -------------------------------------------------------------------------------- 1 |

Github

2 | 3 |

https://github.com

4 | -------------------------------------------------------------------------------- /test/specs/new/autolink_after_link.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: true 3 | --- 4 | [Github](https://github.com) 5 | 6 | https://github.com 7 | -------------------------------------------------------------------------------- /test/specs/new/autolink_lines.html: -------------------------------------------------------------------------------- 1 |

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

4 | -------------------------------------------------------------------------------- /test/specs/new/autolink_lines.md: -------------------------------------------------------------------------------- 1 | hello world 2 | 3 | -------------------------------------------------------------------------------- /test/specs/new/autolinks.html: -------------------------------------------------------------------------------- 1 |

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

2 | 3 |

((http://foo.com))

4 | 5 |

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

6 | 7 |

HTTP://FOO.COM

8 | 9 |

hTtP://fOo.CoM

10 | 11 |

hello@email.com

12 | 13 |

me@example.com

14 | 15 |

test@test.com

-------------------------------------------------------------------------------- /test/specs/new/autolinks.md: -------------------------------------------------------------------------------- 1 | (See https://www.example.com/fhqwhgads.) 2 | 3 | ((http://foo.com)) 4 | 5 | ((http://foo.com.)) 6 | 7 | HTTP://FOO.COM 8 | 9 | hTtP://fOo.CoM 10 | 11 | ~~hello@email.com~~ 12 | 13 | **me@example.com** 14 | 15 | __test@test.com__ -------------------------------------------------------------------------------- /test/specs/new/autolinks_quotes.html: -------------------------------------------------------------------------------- 1 |

"https://www.example.com?test=quote-in-"-url"

2 | 3 |

'https://www.example.com?test=quote-in-'-url'

4 | -------------------------------------------------------------------------------- /test/specs/new/autolinks_quotes.md: -------------------------------------------------------------------------------- 1 | "https://www.example.com?test=quote-in-"-url" 2 | 3 | 'https://www.example.com?test=quote-in-'-url' 4 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_following_nptable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |

a blockquote

20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
abcdef
barfoo
bazboo
38 |

a blockquote

39 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_following_nptable.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | > a blockquote 6 | 7 | abc | def 8 | --- | --- 9 | bar | foo 10 | baz | boo 11 | > a blockquote 12 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |

a blockquote

20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
abcdef
barfoo
bazboo
38 |

a blockquote

39 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_following_table.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | > a blockquote 6 | 7 | | abc | def | 8 | | --- | --- | 9 | | bar | foo | 10 | | baz | boo | 11 | > a blockquote 12 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_list_item.html: -------------------------------------------------------------------------------- 1 |

This fails in markdown.pl and upskirt:

2 | 3 |
  • hello

    world

4 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_list_item.md: -------------------------------------------------------------------------------- 1 | This fails in markdown.pl and upskirt: 2 | 3 | * hello 4 | > world 5 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_setext.html: -------------------------------------------------------------------------------- 1 |
2 |

not heading 1 ==

3 |
4 | 5 |
6 |

not heading 2 --

7 |
8 | 9 |
10 |

heading 1

11 |
12 | 13 |
14 |

heading 2

15 |
16 | 17 |
18 |

not heading 1 == not heading 2 with br
--

19 |
20 | -------------------------------------------------------------------------------- /test/specs/new/blockquote_setext.md: -------------------------------------------------------------------------------- 1 | > not heading 1 2 | == 3 | 4 | > not heading 2 5 | -- 6 | 7 | > heading 1 8 | > == 9 | 10 | > heading 2 11 | > -- 12 | 13 | > not heading 1 14 | == 15 | > not heading 2 with br 16 | -- 17 | -------------------------------------------------------------------------------- /test/specs/new/breakline.html: -------------------------------------------------------------------------------- 1 |

A
break line test
Special codeA
break line test

2 | -------------------------------------------------------------------------------- /test/specs/new/breakline.md: -------------------------------------------------------------------------------- 1 | A 2 | break line test 3 | Special `code`A 4 | break line test -------------------------------------------------------------------------------- /test/specs/new/breaks.html: -------------------------------------------------------------------------------- 1 |

A
B

2 | -------------------------------------------------------------------------------- /test/specs/new/breaks.md: -------------------------------------------------------------------------------- 1 | --- 2 | breaks: true 3 | gfm: true 4 | --- 5 | A 6 | B 7 | -------------------------------------------------------------------------------- /test/specs/new/case_insensitive_refs.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/specs/new/case_insensitive_refs.md: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [HI]: /url 4 | -------------------------------------------------------------------------------- /test/specs/new/code_block_no_ending_newline.html: -------------------------------------------------------------------------------- 1 |
2 |   
3 |     no newline at end of file
4 |   
5 | 
6 | -------------------------------------------------------------------------------- /test/specs/new/code_block_no_ending_newline.md: -------------------------------------------------------------------------------- 1 | ``` 2 | no newline at end of file -------------------------------------------------------------------------------- /test/specs/new/code_compensation_indent.html: -------------------------------------------------------------------------------- 1 |

This is some text.

2 |
    3 |
  1. This is a list element.

    4 |
    const x = 5;
    5 | const y = x + 5;
    6 | 
    7 |
  2. 8 |
9 | -------------------------------------------------------------------------------- /test/specs/new/code_compensation_indent.md: -------------------------------------------------------------------------------- 1 | --- 2 | renderExact: true 3 | --- 4 | This is some text. 5 | 6 | 1. This is a list element. 7 | 8 | ``` 9 | const x = 5; 10 | const y = x + 5; 11 | ``` -------------------------------------------------------------------------------- /test/specs/new/code_consistent_newline.html: -------------------------------------------------------------------------------- 1 |
const value = 42;
2 | 
3 |
const value = 42;
4 | 
5 |

Code blocks contain trailing new line.

6 | -------------------------------------------------------------------------------- /test/specs/new/code_consistent_newline.md: -------------------------------------------------------------------------------- 1 | --- 2 | renderExact: true 3 | --- 4 | ```js 5 | const value = 42; 6 | ``` 7 | 8 | const value = 42; 9 | 10 | Code blocks contain trailing new line. 11 | -------------------------------------------------------------------------------- /test/specs/new/code_following_nptable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
a simple
20 |  *indented* code block
21 | 
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
abcdef
barfoo
bazboo
41 |
a simple
42 |  *indented* code block
43 | 
44 | -------------------------------------------------------------------------------- /test/specs/new/code_following_nptable.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | a simple 6 | *indented* code block 7 | 8 | abc | def 9 | --- | --- 10 | bar | foo 11 | baz | boo 12 | a simple 13 | *indented* code block 14 | -------------------------------------------------------------------------------- /test/specs/new/code_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
a simple
20 |  *indented* code block
21 | 
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
abcdef
barfoo
bazboo
41 |
a simple
42 |  *indented* code block
43 | 
44 | -------------------------------------------------------------------------------- /test/specs/new/code_following_table.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | a simple 6 | *indented* code block 7 | 8 | | abc | def | 9 | | --- | --- | 10 | | bar | foo | 11 | | baz | boo | 12 | a simple 13 | *indented* code block 14 | -------------------------------------------------------------------------------- /test/specs/new/code_spans.html: -------------------------------------------------------------------------------- 1 |

someone@example.com

2 | 3 |

``test`

-------------------------------------------------------------------------------- /test/specs/new/code_spans.md: -------------------------------------------------------------------------------- 1 | `someone@example.com` 2 | 3 | ``*test`* -------------------------------------------------------------------------------- /test/specs/new/codespan_newline.html: -------------------------------------------------------------------------------- 1 |

code code

2 | 3 |
    4 |
  • code code
  • 5 |
6 | -------------------------------------------------------------------------------- /test/specs/new/codespan_newline.md: -------------------------------------------------------------------------------- 1 | `code 2 | code` 3 | 4 | - `code 5 | code` 6 | -------------------------------------------------------------------------------- /test/specs/new/def_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

hello 3 | [1]: hello

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

hello 10 | [2]: hello

11 |
12 | 13 | 14 |
    15 |
  • 16 |

    hello

    17 |
  • 18 |
  • 19 |
  • 20 |

    hello 21 | [4]: hello

    22 |
  • 23 |
24 | 25 | 26 |
27 |

foo 28 | bar 29 | [5]: foo 30 | bar

31 |
32 | -------------------------------------------------------------------------------- /test/specs/new/def_blocks.md: -------------------------------------------------------------------------------- 1 | > hello 2 | > [1]: hello 3 | 4 | * * * 5 | 6 | > hello 7 | [2]: hello 8 | 9 | 10 | * hello 11 | * [3]: hello 12 | 13 | 14 | * hello 15 | [4]: hello 16 | 17 | 18 | > foo 19 | > bar 20 | [5]: foo 21 | > bar 22 | -------------------------------------------------------------------------------- /test/specs/new/del_strikethrough.html: -------------------------------------------------------------------------------- 1 |

test

2 | 3 |

~~test~

4 | 5 |

~test~~

6 | 7 |

test

8 | 9 |

test 10 | test

11 | 12 |

~~test

13 | 14 |

test~~

15 | 16 |
17 | -------------------------------------------------------------------------------- /test/specs/new/del_strikethrough.md: -------------------------------------------------------------------------------- 1 | ~~test~~ 2 | 3 | ~~test~ 4 | 5 | ~test~~ 6 | 7 | ~test~ 8 | 9 | ~~test 10 | test~~ 11 | 12 | ~~test 13 | 14 | test~~ 15 | 16 | ~~~test~~~ 17 | -------------------------------------------------------------------------------- /test/specs/new/double_link.html: -------------------------------------------------------------------------------- 1 |

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

2 | 3 |

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

4 | 5 |

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

6 | 7 |

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

8 | 9 |

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

10 | 11 |

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

12 | 13 |

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

14 | 15 |

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

16 | -------------------------------------------------------------------------------- /test/specs/new/double_link.md: -------------------------------------------------------------------------------- 1 |

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

2 | 3 | Already linked: [http://example.com/](http://example.com/). 4 | 5 | Already linked: http://example.com/. 6 | 7 | Already linked: **http://example.com/**. 8 | 9 | Already linked: *http://example.com/*. 10 | 11 | Already linked: ~~http://example.com/~~. 12 | 13 | Already linked: [http://example.com/]. 14 | 15 | Already linked: [http://example.com/][]. 16 | 17 | [http://example.com/]: http://example.com/ 18 | -------------------------------------------------------------------------------- /test/specs/new/em_2char.html: -------------------------------------------------------------------------------- 1 |

123

2 | 3 |

123

4 | 5 |

12

6 | 7 |

12

8 | 9 |

1

10 | 11 |

1

12 | 13 |

__

14 | 15 |

**

16 | 17 |

_123 _

18 | 19 |

*123 *

20 | 21 |

_ 123_

22 | 23 |

It’s leviOHsa, not levioSAH.

24 | 25 |

__ test test

26 | -------------------------------------------------------------------------------- /test/specs/new/em_2char.md: -------------------------------------------------------------------------------- 1 | _123_ 2 | 3 | *123* 4 | 5 | _12_ 6 | 7 | *12* 8 | 9 | _1_ 10 | 11 | *1* 12 | 13 | __ 14 | 15 | ** 16 | 17 | _123 _ 18 | 19 | *123 * 20 | 21 | _ 123_ 22 | 23 | It’s levi*OH*sa, not levio*SAH.* 24 | 25 | __ test [test](https://test.com/_) 26 | -------------------------------------------------------------------------------- /test/specs/new/em_after_inline.html: -------------------------------------------------------------------------------- 1 |

a
@

2 | 3 |

aaa@

4 | 5 |

aaa@

6 | 7 |

aa@

8 | 9 |

aa@

10 | 11 |

ahttp://a.com@

12 | 13 |

aa@

14 | 15 |

a@

16 | -------------------------------------------------------------------------------- /test/specs/new/em_after_inline.md: -------------------------------------------------------------------------------- 1 | a\ 2 | *@* 3 | 4 | a*a*_a_*@* 5 | 6 | a**a**_a_*@* 7 | 8 | a~a~*@* 9 | 10 | a`a`*@* 11 | 12 | a*@* 13 | 14 | a[a](a)*@* 15 | 16 | a*@* 17 | -------------------------------------------------------------------------------- /test/specs/new/em_and_reflinks.html: -------------------------------------------------------------------------------- 1 |

Helloreflink*topguys!

2 |

Hello [notreflink] guys*!

3 |

Hello [notareflink] guys!

4 |

Helloreflink*bottomguys!

5 |

Helloreflinknoemguys!

6 | -------------------------------------------------------------------------------- /test/specs/new/em_and_reflinks.md: -------------------------------------------------------------------------------- 1 | [reflink*top]: theaddress 2 | 3 | *Hello [reflink*top] guys*! 4 | 5 | *Hello [not*reflink] guys*! 6 | 7 | *Hello [not*a*reflink] guys*! 8 | 9 | *Hello [reflink*bottom] guys*! 10 | 11 | *Hello [reflinknoem] guys*! 12 | 13 | [reflink*bottom]: theaddress 14 | 15 | [reflinknoem]: theaddress 16 | -------------------------------------------------------------------------------- /test/specs/new/em_list_links.html: -------------------------------------------------------------------------------- 1 | 55 | -------------------------------------------------------------------------------- /test/specs/new/em_list_links.md: -------------------------------------------------------------------------------- 1 | - italic 2 | - [*named link*][some-url] 3 | - *[named link][some-url]* 4 | - [_named link_][some-url] 5 | - _[named link][some-url]_ 6 | - bold 7 | - [**named link**][some-url] 8 | - **[named link][some-url]** 9 | - [__named link__][some-url] 10 | - __[named link][some-url]__ 11 | - bold italic 12 | - [***named link***][some-url] 13 | - ***[named link][some-url]*** 14 | - [___named link___][some-url] 15 | - ___[named link][some-url]___ 16 | - [*__named link__*][some-url] 17 | - [__*named link*__][some-url] 18 | - __*[named link][some-url]*__ 19 | - code 20 | - [`named link`][some-url] 21 | - code italic 22 | - *[`named link`][some-url]* 23 | - [*`named link`*][some-url] 24 | - _[`named link`][some-url]_ 25 | - [_`named link`_][some-url] 26 | - code bold 27 | - **[`named link`][some-url]** 28 | - [**`named link`**][some-url] 29 | - __[`named link`][some-url]__ 30 | - [__`named link`__][some-url] 31 | - code bold italic 32 | - [***`named link`***][some-url] 33 | - ***[`named link`][some-url]*** 34 | - [___`named link`___][some-url] 35 | - ___[`named link`][some-url]___ 36 | - [*__`named link`__*][some-url] 37 | - [__*`named link`*__][some-url] 38 | - __*[`named link`][some-url]*__ 39 | 40 | [some-url]: https://www.google.com -------------------------------------------------------------------------------- /test/specs/new/em_strong_adjacent.html: -------------------------------------------------------------------------------- 1 |

test

2 | 3 |

test

4 | 5 |

test

6 | 7 |

test

8 | 9 |

test

10 | 11 |

test

12 | 13 |

test

14 | 15 |

test

16 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_adjacent.md: -------------------------------------------------------------------------------- 1 | _te_*st* 2 | 3 | _te_**st** 4 | 5 | *te*_st_ 6 | 7 | *te*__st__ 8 | 9 | __te__*st* 10 | 11 | __te__**st** 12 | 13 | **te**_st_ 14 | 15 | **te**__st__ 16 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_adjacent_mixed.html: -------------------------------------------------------------------------------- 1 |

foo bar

2 | 3 |

foo bar foo

4 | 5 |

foo bar

6 | 7 |

foo bar foo

8 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_adjacent_mixed.md: -------------------------------------------------------------------------------- 1 | _**foo**_ **bar** 2 | 3 | _**foo**_ **bar** _**foo**_ 4 | 5 | *__foo__* __bar__ 6 | 7 | *__foo__* __bar__ *__foo__* 8 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_complex_nesting.html: -------------------------------------------------------------------------------- 1 |

Emphasis

2 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_complex_nesting.md: -------------------------------------------------------------------------------- 1 | **E*mp****ha****si*s** 2 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_multiline.html: -------------------------------------------------------------------------------- 1 |

italic bold italic 2 | italic bold italic 3 | italic bold italic

4 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_multiline.md: -------------------------------------------------------------------------------- 1 | _italic **bold** italic_ 2 | _italic **bold** italic_ 3 | _italic **bold** italic_ 4 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_orphaned_nesting.html: -------------------------------------------------------------------------------- 1 |

foo_bar

2 | -------------------------------------------------------------------------------- /test/specs/new/em_strong_orphaned_nesting.md: -------------------------------------------------------------------------------- 1 | _**foo_bar**_ 2 | -------------------------------------------------------------------------------- /test/specs/new/email_after_space.html: -------------------------------------------------------------------------------- 1 |

info@email.io

2 | -------------------------------------------------------------------------------- /test/specs/new/email_after_space.md: -------------------------------------------------------------------------------- 1 | info@email.io 2 | -------------------------------------------------------------------------------- /test/specs/new/emoji_inline.html: -------------------------------------------------------------------------------- 1 |

Situations where it fails:

2 |

test 💁

3 |

💁 test

4 |

🤓 test

5 |

🏖️ test

6 |

🏖️🤓💁 test

7 |

💁 test test

8 |

test 💁 test

9 |

test 💁 test test

10 |

test 💁

11 |

💁 test

12 |

💁 test test

13 |

test 💁 test

14 |

test 💁 test test

15 |

💁 test

16 |

Situations where it works:

17 |

**💁 **

18 |

⚠️ test

19 |

Here, the emoji rendering works, but the text doesn't get rendered in italic.

20 |

💁 test

21 |

t💁t test

22 |

t💁t test

23 | -------------------------------------------------------------------------------- /test/specs/new/emoji_inline.md: -------------------------------------------------------------------------------- 1 | Situations where it fails: 2 | 3 | **test 💁** 4 | 5 | **💁 test** 6 | 7 | **🤓 test** 8 | 9 | **🏖️ test** 10 | 11 | **🏖️🤓💁 test** 12 | 13 | **💁 test** test 14 | 15 | test **💁 test** 16 | 17 | test **💁 test** test 18 | 19 | ***test 💁*** 20 | 21 | ***💁 test*** 22 | 23 | ***💁 test*** test 24 | 25 | test ***💁 test*** 26 | 27 | test ***💁 test*** test 28 | 29 | ****💁 test**** 30 | 31 | Situations where it works: 32 | 33 | **💁 ** 34 | 35 | **⚠️ test** 36 | 37 | Here, the emoji rendering works, but the text doesn't get rendered in italic. 38 | 39 | *💁 test* 40 | 41 | *t💁t* test 42 | 43 | **t💁t** test 44 | -------------------------------------------------------------------------------- /test/specs/new/emphasis_extra tests.html: -------------------------------------------------------------------------------- 1 |

test. test: test! test? test- test,

2 | -------------------------------------------------------------------------------- /test/specs/new/emphasis_extra tests.md: -------------------------------------------------------------------------------- 1 | _test_. 2 | _test_: 3 | _test_! 4 | _test_? 5 | _test_- 6 | _test_, 7 | -------------------------------------------------------------------------------- /test/specs/new/empty_heading_following_paragraph.html: -------------------------------------------------------------------------------- 1 |

Newline after heading

2 |

3 | 4 |

No newline at the end

5 |

6 | -------------------------------------------------------------------------------- /test/specs/new/empty_heading_following_paragraph.md: -------------------------------------------------------------------------------- 1 | Newline after heading 2 | ## 3 | 4 | No newline at the end 5 | ## -------------------------------------------------------------------------------- /test/specs/new/empty_heading_following_paragraph_nogfm.html: -------------------------------------------------------------------------------- 1 |

Newline after heading

2 |

3 | 4 |

No newline at the end

5 |

6 | -------------------------------------------------------------------------------- /test/specs/new/empty_heading_following_paragraph_nogfm.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: false 3 | --- 4 | Newline after heading 5 | ## 6 | 7 | No newline at the end 8 | ## -------------------------------------------------------------------------------- /test/specs/new/empty_heading_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
ab
12
34
19 |

20 | 21 |

No newline at the end

22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
ab
12
34
41 |

42 | -------------------------------------------------------------------------------- /test/specs/new/empty_heading_following_table.md: -------------------------------------------------------------------------------- 1 | | a | b | 2 | | - | - | 3 | | 1 | 2 | 4 | | 3 | 4 | 5 | ## 6 | 7 | No newline at the end 8 | 9 | | a | b | 10 | | - | - | 11 | | 1 | 2 | 12 | | 3 | 4 | 13 | ## -------------------------------------------------------------------------------- /test/specs/new/escape_tick.html: -------------------------------------------------------------------------------- 1 |

italics

2 |

bold

3 |

bold italics

4 |

*quoted italics*

5 |

**quoted bold**

6 |

***quoted bold italics***

7 |

`escaped quoted italics`

8 |

`escaped quoted bold`

9 |

`escaped quoted bold italics`

10 | -------------------------------------------------------------------------------- /test/specs/new/escape_tick.md: -------------------------------------------------------------------------------- 1 | *italics* 2 | 3 | **bold** 4 | 5 | ***bold italics*** 6 | 7 | `*quoted italics*` 8 | 9 | `**quoted bold**` 10 | 11 | `***quoted bold italics***` 12 | 13 | \`*escaped quoted italics*\` 14 | 15 | \`**escaped quoted bold**\` 16 | 17 | \`***escaped quoted bold italics***\` 18 | -------------------------------------------------------------------------------- /test/specs/new/escape_within_del.html: -------------------------------------------------------------------------------- 1 |

\

2 |

~\~

3 |

~

4 |

~\~~

5 |

~~ ~

6 |

~ ~~

7 | -------------------------------------------------------------------------------- /test/specs/new/escape_within_del.md: -------------------------------------------------------------------------------- 1 | ~\\~ 2 | 3 | ~\\\~ 4 | 5 | ~\~~ 6 | 7 | ~\\~~ 8 | 9 | ~\~ ~ 10 | 11 | ~ \~~ 12 | -------------------------------------------------------------------------------- /test/specs/new/escape_within_emphasis.html: -------------------------------------------------------------------------------- 1 |

strong text[]

2 | 3 |

strong text\[]

4 | 5 |

strong text\[]

6 | 7 |

strong text\\[]

8 | 9 |

strong text[]

10 | 11 |

strong text\[]

12 | 13 |

strong text\[]

14 | 15 |

strong text\\[]

16 | 17 |

em[pha](sis)

18 | 19 |

em[pha](sis)

20 | 21 |

\

22 | 23 |

\

-------------------------------------------------------------------------------- /test/specs/new/escape_within_emphasis.md: -------------------------------------------------------------------------------- 1 | **strong text\[**\] 2 | 3 | **strong text\\[**\] 4 | 5 | **strong text\\\[**\] 6 | 7 | **strong text\\\\[**\] 8 | 9 | __strong text\[__\] 10 | 11 | __strong text\\[__\] 12 | 13 | __strong text\\\[__\] 14 | 15 | __strong text\\\\[__\] 16 | 17 | *em\[pha\]\(sis\)* 18 | 19 | _em\[pha\]\(sis\)_ 20 | 21 | *\\* 22 | 23 | _\\_ 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/specs/new/escaped_angles.html: -------------------------------------------------------------------------------- 1 |

>

2 | -------------------------------------------------------------------------------- /test/specs/new/escaped_angles.md: -------------------------------------------------------------------------------- 1 | \> 2 | -------------------------------------------------------------------------------- /test/specs/new/fences_breaking_paragraphs.html: -------------------------------------------------------------------------------- 1 |

A paragraph

2 |
Here is code in
 3 | backtick fences
4 |

B paragraph

5 |
Here is code in
 6 | tilde fences
7 |

C paragraph

8 |
Alternative
 9 | tilde fences
10 |

D paragraph ```~D` Invalid use of backtick fences

11 |

12 | This will be read as
13 | part of a codeblock
14 | that ends with the file
15 | -------------------------------------------------------------------------------- /test/specs/new/fences_breaking_paragraphs.md: -------------------------------------------------------------------------------- 1 | A paragraph 2 | ```A 3 | Here is code in 4 | backtick fences 5 | ``` 6 | 7 | B paragraph 8 | ~~~B 9 | Here is code in 10 | tilde fences 11 | ~~~ 12 | 13 | C paragraph 14 | ~~~`C~ 15 | Alternative 16 | tilde fences 17 | ~~~ 18 | 19 | D paragraph 20 | ```~D` 21 | Invalid use of 22 | backtick fences 23 | ``` 24 | 25 | This will be read as 26 | part of a codeblock 27 | that ends with the file 28 | -------------------------------------------------------------------------------- /test/specs/new/fences_following_list.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. abcd
  2. 3 |
4 |
if {
5 | 
6 | }
7 | 
8 | -------------------------------------------------------------------------------- /test/specs/new/fences_following_list.md: -------------------------------------------------------------------------------- 1 | 1. abcd 2 | ``` 3 | if { 4 | } 5 | ``` 6 | -------------------------------------------------------------------------------- /test/specs/new/fences_following_nptable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
foobar()
20 | -------------------------------------------------------------------------------- /test/specs/new/fences_following_nptable.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | ``` 6 | foobar() 7 | ``` 8 | -------------------------------------------------------------------------------- /test/specs/new/fences_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
foobar()
20 | -------------------------------------------------------------------------------- /test/specs/new/fences_following_table.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | ``` 6 | foobar() 7 | ``` 8 | -------------------------------------------------------------------------------- /test/specs/new/fences_with_blankline_following_list_0.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. code with blankline
  2. 3 |
4 |
if {
 5 | 
 6 | }
 7 | 
8 |
    9 |
  1. code and text
  2. 10 |
11 |
if {
12 | 
13 | }
14 | 
15 |

text after fenced code block.

16 |
    17 |
  1. tilde
  2. 18 |
19 |
if {
20 | 
21 | 
22 | }
23 | 
24 | -------------------------------------------------------------------------------- /test/specs/new/fences_with_blankline_following_list_0.md: -------------------------------------------------------------------------------- 1 | 1. code with blankline 2 | ``` 3 | if { 4 | 5 | } 6 | ``` 7 | 8 | 2. code and text 9 | ``` 10 | if { 11 | 12 | 13 | } 14 | ``` 15 | text after fenced code block. 16 | 17 | 3. tilde 18 | ~~~ 19 | if { 20 | 21 | } 22 | ~~~ 23 | -------------------------------------------------------------------------------- /test/specs/new/fences_with_blankline_following_list_1.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. code with blankline

    3 |
    if {
     4 | 
     5 | }
     6 | 
    7 |
  2. 8 |
  3. code and text

    9 |
    if {
    10 | 
    11 | }
    12 | 
    13 |

    text after fenced code block.

    14 |
  4. 15 |
  5. tilde

    16 |
    if {
    17 | 
    18 | 
    19 | }
    20 | 
    21 |
  6. 22 |
23 | -------------------------------------------------------------------------------- /test/specs/new/fences_with_blankline_following_list_1.md: -------------------------------------------------------------------------------- 1 | 1. code with blankline 2 | ``` 3 | if { 4 | 5 | } 6 | ``` 7 | 8 | 2. code and text 9 | ``` 10 | if { 11 | 12 | 13 | } 14 | ``` 15 | text after fenced code block. 16 | 17 | 3. tilde 18 | ~~~ 19 | if { 20 | 21 | } 22 | ~~~ 23 | 24 | -------------------------------------------------------------------------------- /test/specs/new/heading_following_list.html: -------------------------------------------------------------------------------- 1 |

level1

2 |

level2

3 |

level3

4 |
    5 |
  • foo=bar
  • 6 |
  • foo2=bar2
  • 7 |
8 |

level3

9 | -------------------------------------------------------------------------------- /test/specs/new/heading_following_list.md: -------------------------------------------------------------------------------- 1 | # level1 2 | ## level2 3 | ### level3 4 | - foo=bar 5 | - foo2=bar2 6 | ### level3 7 | -------------------------------------------------------------------------------- /test/specs/new/heading_following_nptable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |

title

20 | -------------------------------------------------------------------------------- /test/specs/new/heading_following_nptable.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | # title 6 | -------------------------------------------------------------------------------- /test/specs/new/heading_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |

title

20 | -------------------------------------------------------------------------------- /test/specs/new/heading_following_table.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | # title 6 | -------------------------------------------------------------------------------- /test/specs/new/hr_following_nptables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
abcdef
barfoo
bazboo
39 |
40 | 41 |

text then table

42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
abcdef
barfoo
bazboo
60 |
61 | -------------------------------------------------------------------------------- /test/specs/new/hr_following_nptables.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | ___ 6 | 7 | abc | def 8 | --- | --- 9 | bar | foo 10 | baz | boo 11 | --- 12 | 13 | text then table 14 | abc | def 15 | --- | --- 16 | bar | foo 17 | baz | boo 18 | --- 19 | -------------------------------------------------------------------------------- /test/specs/new/hr_following_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
abcdef
barfoo
bazboo
39 |
40 | 41 |

text then table

42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
abcdef
barfoo
bazboo
60 |
61 | -------------------------------------------------------------------------------- /test/specs/new/hr_following_tables.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | ___ 6 | 7 | | abc | def | 8 | | --- | --- | 9 | | bar | foo | 10 | | baz | boo | 11 | --- 12 | 13 | text then table 14 | | abc | def | 15 | | --- | --- | 16 | | bar | foo | 17 | | baz | boo | 18 | --- 19 | -------------------------------------------------------------------------------- /test/specs/new/hr_list_break.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • hello 3 | world
  • 4 |
  • how 5 | are
  • 6 |
7 | 8 |
9 | 10 |

you today?

11 | -------------------------------------------------------------------------------- /test/specs/new/hr_list_break.md: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | * how 4 | are 5 | * * * 6 | you today? 7 | -------------------------------------------------------------------------------- /test/specs/new/html_comments.html: -------------------------------------------------------------------------------- 1 |

Example 1

2 | 3 | 4 | 5 |

Example 2

6 | 7 | 8 | 9 |

Example 3

10 | 11 | 12 | 13 |

Example 4

14 | 15 | 16 | 17 |

Example 5

18 | 19 | 20 | 21 |

Example 6

22 | 23 | 24 | 25 |

Example 7

26 | 27 | 28 | 29 |

Example 8

30 | 31 | 32 | 33 |

Example 9

34 | 35 | 36 | 37 |

Example 10

38 | 39 | 43 | 44 |

Example 11

45 | 46 | 47 | 48 |
<!-- too much indentation -->
49 | 
50 | 51 |

Example 12

52 | 53 | a comment --> 54 | 55 | a comment --> 56 | 57 | --> 58 | 59 |

Example 13

60 | 61 | 62 | 63 | *is not a valid comment ending* 64 | -------------------------------------------------------------------------------- /test/specs/new/html_comments.md: -------------------------------------------------------------------------------- 1 | ### Example 1 2 | 3 | 4 | 5 | ### Example 2 6 | 7 | 8 | 9 | ### Example 3 10 | 11 | 12 | 13 | ### Example 4 14 | 15 | 16 | 17 | ### Example 5 18 | 19 | 20 | 21 | ### Example 6 22 | 23 | 24 | 25 | ### Example 7 26 | 27 | 28 | 29 | ### Example 8 30 | 31 | 32 | 33 | ### Example 9 34 | 35 | 36 | 37 | ### Example 10 38 | 39 | 43 | 44 | ### Example 11 45 | 46 | 47 | 48 | 49 | 50 | ### Example 12 51 | 52 | a comment --> 53 | 54 | a comment --> 55 | 56 | --> 57 | 58 | ### Example 13 59 | 60 | 61 | 62 | *is not a valid comment ending* 63 | -------------------------------------------------------------------------------- /test/specs/new/html_following_list.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • list item 1
  • 3 |
  • list item 2
  • 4 |
5 |
6 | Content 7 |
8 | 9 |
    10 |
  • list item 1
  • 11 |
  • list item 2
  • 12 |
13 | 16 | -------------------------------------------------------------------------------- /test/specs/new/html_following_list.md: -------------------------------------------------------------------------------- 1 | - list item 1 2 | - list item 2 3 |
4 | Content 5 |
6 | 7 | - list item 1 8 | - list item 2 9 | 12 | -------------------------------------------------------------------------------- /test/specs/new/html_following_nptable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
Some HTML
20 | -------------------------------------------------------------------------------- /test/specs/new/html_following_nptable.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 |
Some HTML
6 | -------------------------------------------------------------------------------- /test/specs/new/html_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
Some HTML
20 | -------------------------------------------------------------------------------- /test/specs/new/html_following_table.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 |
Some HTML
6 | -------------------------------------------------------------------------------- /test/specs/new/html_no_new_line.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/specs/new/html_no_new_line.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/specs/new/image_links.html: -------------------------------------------------------------------------------- 1 |

2 | 3 | test 4 | 5 |

6 | 7 |

8 | 9 | [test] 10 | 11 |

12 | -------------------------------------------------------------------------------- /test/specs/new/image_links.md: -------------------------------------------------------------------------------- 1 | [![test](https://example.com/image.jpg "title")](https://example.com/) 2 | 3 | [![\[test\]](https://example.com/image.jpg "[title]")](https://example.com/) 4 | -------------------------------------------------------------------------------- /test/specs/new/image_paren.html: -------------------------------------------------------------------------------- 1 |

(or )

2 | 3 |

one (or two)

4 | -------------------------------------------------------------------------------- /test/specs/new/image_paren.md: -------------------------------------------------------------------------------- 1 | ![](img1.svg) (or ![](img2.svg)) 2 | 3 | ![one](img1.svg) (or ![two](img2.svg)) 4 | -------------------------------------------------------------------------------- /test/specs/new/incorrectly_formatted_list_and_hr.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list, not a heading
  • 3 |
4 |
5 | 6 |
    7 |
  1. this is also a list
  2. 8 |
9 |
    10 |
  • it should be a list
  • 11 |
12 |
    13 |
  • not heading
  • 14 |
15 |
16 | 17 |

not heading

18 |
    19 |
  • this is also a list, not a multiline heading
  • 20 |
21 |
22 | 23 |

click here

24 |
    25 |
  • this has to be a list
  • 26 |
  • true...
  • 27 |
28 |
29 | 30 |

31 | heading -this one is a heading 32 |

33 | 34 |

35 | heading - this is a heading too 36 |

37 | -------------------------------------------------------------------------------- /test/specs/new/incorrectly_formatted_list_and_hr.md: -------------------------------------------------------------------------------- 1 | - this is a list, not a heading 2 | ----- 3 | 4 | 1) this is also a list 5 | * it should be a list 6 | - not heading 7 | ----- 8 | 9 | not heading 10 | - this is also a list, not a multiline heading 11 | ***** 12 | 13 | [click here](/index.jpg) 14 | - this has to be a list 15 | - true... 16 | _____ 17 | 18 | heading 19 | -this one is a heading 20 | ----- 21 | 22 | heading - this is a heading too 23 | ----- 24 | -------------------------------------------------------------------------------- /test/specs/new/indented_details.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Heading

4 |
5 | 6 |

Heading

7 | 8 | 9 |

Heading

10 |
11 | 12 |

Heading

13 |
14 | 15 |
## Heading
16 |
17 | 18 |
## Heading
19 | 20 | 21 |
## Heading
22 |
23 | 24 |
## Heading
25 | -------------------------------------------------------------------------------- /test/specs/new/indented_details.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ## Heading 4 |
5 | 6 | ## Heading 7 | 8 | 9 | ## Heading 10 | 11 | 12 | ## Heading 13 |
14 | 15 | ## Heading 16 |
17 | 18 | ## Heading 19 | 20 | 21 | ## Heading 22 | 23 | 24 | ## Heading 25 | -------------------------------------------------------------------------------- /test/specs/new/indented_tables.html: -------------------------------------------------------------------------------- 1 |

2 | | abc | def | 3 | | --- | --- | 4 | | bar | foo | 5 | | baz | boo | 6 |

7 | -------------------------------------------------------------------------------- /test/specs/new/indented_tables.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | -------------------------------------------------------------------------------- /test/specs/new/inlinecode_following_nptables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
abcdef
barfoo
bazboo
hello
23 | -------------------------------------------------------------------------------- /test/specs/new/inlinecode_following_nptables.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | `hello` 6 | -------------------------------------------------------------------------------- /test/specs/new/inlinecode_following_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
abcdef
barfoo
bazboo
hello
23 | -------------------------------------------------------------------------------- /test/specs/new/inlinecode_following_tables.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | `hello` 6 | -------------------------------------------------------------------------------- /test/specs/new/lazy_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

hi there 3 | bud

4 |
5 | -------------------------------------------------------------------------------- /test/specs/new/lazy_blockquotes.md: -------------------------------------------------------------------------------- 1 | > hi there 2 | bud 3 | -------------------------------------------------------------------------------- /test/specs/new/lheading_following_nptable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
abcdef
barfoo
bazboo
title
=====
27 | -------------------------------------------------------------------------------- /test/specs/new/lheading_following_nptable.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | title 6 | ===== 7 | -------------------------------------------------------------------------------- /test/specs/new/lheading_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
abcdef
barfoo
bazboo
title
=====
27 | -------------------------------------------------------------------------------- /test/specs/new/lheading_following_table.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | title 6 | ===== 7 | -------------------------------------------------------------------------------- /test/specs/new/link_lt.html: -------------------------------------------------------------------------------- 1 |

URL

2 | 3 |

URL

4 | -------------------------------------------------------------------------------- /test/specs/new/link_lt.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | [URL]() 7 | -------------------------------------------------------------------------------- /test/specs/new/link_tick_redos.html: -------------------------------------------------------------------------------- 1 |

dash_capstyle: ['butt' | 'round' | 'projecting'] 2 | dash_joinstyle: ['miter' | 'round' | 'bevel'] 3 | dashes: sequence of on/off ink in points 4 | drawstyle: ['default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post'] 5 | figure: a ~.Figure instance 6 | fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none'] 7 | gid: an id string 8 | label: object 9 | linestyle or ls: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | ''] 10 | linewidth or lw: float value in points 11 | marker: :mod:A valid marker style <matplotlib.markers> 12 | markeredgecolor or mec: any matplotlib color 13 | markeredgewidth or mew: float value in points 14 | markerfacecolor or mfc: any matplotlib color 15 | markerfacecoloralt or mfcalt: any matplotlib color 16 | markersize or ms: float 17 | markevery: [None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float] 18 | path_effects: ~.AbstractPathEffect 19 | picker: float distance in points or callable pick function fn(artist, event) 20 | pickradius: float distance in points 21 | rasterized: bool or None 22 | sketch_params: (scale: float, length: float, randomness: float) 23 | snap: bool or None 24 | solid_capstyle: ['butt' | 'round' | 'projecting'] 25 | solid_joinstyle: ['miter' | 'round' | 'bevel'] 26 | transform: a :class:matplotlib.transforms.Transform instance 27 | url: a url string 28 | visible: bool 29 | xdata: 1D array 30 | ydata: 1D array 31 | zorder: float

32 | -------------------------------------------------------------------------------- /test/specs/new/link_tick_redos.md: -------------------------------------------------------------------------------- 1 | dash_capstyle: ['butt' | 'round' | 'projecting'] 2 | dash_joinstyle: ['miter' | 'round' | 'bevel'] 3 | dashes: sequence of on/off ink in points 4 | drawstyle: ['default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post'] 5 | figure: a `~.Figure` instance 6 | fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none'] 7 | gid: an id string 8 | label: object 9 | linestyle or ls: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) | ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'None'`` | ``' '`` | ``''``] 10 | linewidth or lw: float value in points 11 | marker: :mod:`A valid marker style ` 12 | markeredgecolor or mec: any matplotlib color 13 | markeredgewidth or mew: float value in points 14 | markerfacecolor or mfc: any matplotlib color 15 | markerfacecoloralt or mfcalt: any matplotlib color 16 | markersize or ms: float 17 | markevery: [None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float] 18 | path_effects: `~.AbstractPathEffect` 19 | picker: float distance in points or callable pick function ``fn(artist, event)`` 20 | pickradius: float distance in points 21 | rasterized: bool or None 22 | sketch_params: (scale: float, length: float, randomness: float) 23 | snap: bool or None 24 | solid_capstyle: ['butt' | 'round' | 'projecting'] 25 | solid_joinstyle: ['miter' | 'round' | 'bevel'] 26 | transform: a :class:`matplotlib.transforms.Transform` instance 27 | url: a url string 28 | visible: bool 29 | xdata: 1D array 30 | ydata: 1D array 31 | zorder: float 32 | -------------------------------------------------------------------------------- /test/specs/new/link_unbalanced.html: -------------------------------------------------------------------------------- 1 |

[link](foo(bar())

2 | 3 |

link

4 | 5 |

link

6 | 7 |

[link](foo(bar\())

8 | -------------------------------------------------------------------------------- /test/specs/new/link_unbalanced.md: -------------------------------------------------------------------------------- 1 | [link](foo(bar()) 2 | 3 | [link](foo\(bar()) 4 | 5 | [link](foo(bar\()) 6 | 7 | [link](foo(bar\\()) 8 | -------------------------------------------------------------------------------- /test/specs/new/links.html: -------------------------------------------------------------------------------- 1 |

Link: constructor.

2 | 3 |

One (Two) Three

4 | -------------------------------------------------------------------------------- /test/specs/new/links.md: -------------------------------------------------------------------------------- 1 | Link: [constructor][]. 2 | 3 | [One](https://example.com/1) ([Two](https://example.com/2)) [Three](https://example.com/3) 4 | 5 | [constructor]: https://example.org/ 6 | -------------------------------------------------------------------------------- /test/specs/new/links_paren.html: -------------------------------------------------------------------------------- 1 |

(one) (two)

2 | 3 |

(one) (two)

4 | 5 |

(one) (two)

6 | -------------------------------------------------------------------------------- /test/specs/new/links_paren.md: -------------------------------------------------------------------------------- 1 | ([one](http://example.com/1)) ([two](http://example.com/2)) 2 | 3 | ([one](http://example.com/1)) ([two](http://example.com/2)) 4 | 5 | ([one](http://example.com/1 "a")) ([two](http://example.com/2 "b")) 6 | -------------------------------------------------------------------------------- /test/specs/new/list_align_number.html: -------------------------------------------------------------------------------- 1 |
1. Item 1
2 | 
3 |
    4 |
  1. Item 10
  2. 5 |
  3. Item 100
  4. 6 |
  5. Item 1000
  6. 7 |
  7. Item 10000
  8. 8 |
9 | -------------------------------------------------------------------------------- /test/specs/new/list_align_number.md: -------------------------------------------------------------------------------- 1 | 1. Item 1 2 | 10. Item 10 3 | 100. Item 100 4 | 1000. Item 1000 5 | 10000. Item 10000 6 | -------------------------------------------------------------------------------- /test/specs/new/list_align_pedantic.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • one 3 |
      4 |
    • two
    • 5 |
    • three
    • 6 |
    • four 7 |
        8 |
      • five
      • 9 |
      • six
      • 10 |
      • seven
      • 11 |
      12 |
    • 13 |
    14 |
  • 15 |
16 | -------------------------------------------------------------------------------- /test/specs/new/list_align_pedantic.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | - one 5 | - two 6 | - three 7 | - four 8 | - five 9 | - six 10 | - seven 11 | -------------------------------------------------------------------------------- /test/specs/new/list_code_header.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • list

    header

  • 3 |
4 | -------------------------------------------------------------------------------- /test/specs/new/list_code_header.md: -------------------------------------------------------------------------------- 1 | - list 2 | # header 3 | -------------------------------------------------------------------------------- /test/specs/new/list_following_nptable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
    20 |
  • foo
  • 21 |
  • bar
  • 22 |
  • baz
  • 23 |
24 | -------------------------------------------------------------------------------- /test/specs/new/list_following_nptable.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | - foo 6 | - bar 7 | - baz 8 | -------------------------------------------------------------------------------- /test/specs/new/list_following_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
abcdef
barfoo
bazboo
19 |
    20 |
  • foo
  • 21 |
  • bar
  • 22 |
  • baz
  • 23 |
24 | -------------------------------------------------------------------------------- /test/specs/new/list_following_table.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | - foo 6 | - bar 7 | - baz 8 | -------------------------------------------------------------------------------- /test/specs/new/list_item_tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • A
  • 3 |
  • B
  • 4 |
  • C
  • 5 |
  • D
  • 6 |
  • E
  • 7 |
  • F
  • 8 |
9 | 10 |
    11 |
  1. A
  2. 12 |
  3. B
  4. 13 |
  5. C
  6. 14 |
  7. D
  8. 15 |
  9. E
  10. 16 |
  11. F
  12. 17 |
18 | -------------------------------------------------------------------------------- /test/specs/new/list_item_tabs.md: -------------------------------------------------------------------------------- 1 | - A 2 | - B 3 | - C 4 | - D 5 | - E 6 | - F 7 | 8 | 1. A 9 | 2. B 10 | 3. C 11 | 4. D 12 | 5. E 13 | 6. F 14 | -------------------------------------------------------------------------------- /test/specs/new/list_item_text.html: -------------------------------------------------------------------------------- 1 |
  • item1

    • item2

    text

2 | -------------------------------------------------------------------------------- /test/specs/new/list_item_text.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | * item1 5 | 6 | * item2 7 | 8 | text 9 | -------------------------------------------------------------------------------- /test/specs/new/list_item_unindented_asterisk.html: -------------------------------------------------------------------------------- 1 |

*list

2 |
    3 |
  • list1 4 | *Not list(without space)
  • 5 |
  • list2
  • 6 |
7 |

+list

8 |
    9 |
  • list1 10 | +Not list(without space)
  • 11 |
  • list2
  • 12 |
13 |

-list

14 |
    15 |
  • list1 16 | -Not list(without space)
  • 17 |
  • list2
  • 18 |
19 |

number(1.)list

20 |
    21 |
  1. list 22 | 1.Notlist(without space)
  2. 23 |
  3. list
  4. 24 |
25 | -------------------------------------------------------------------------------- /test/specs/new/list_item_unindented_asterisk.md: -------------------------------------------------------------------------------- 1 | ## *list 2 | 3 | * list1 4 | *Not list(without space) 5 | * list2 6 | 7 | ## +list 8 | 9 | + list1 10 | +Not list(without space) 11 | + list2 12 | 13 | ## -list 14 | 15 | - list1 16 | -Not list(without space) 17 | - list2 18 | 19 | ## number(1.)list 20 | 1. list 21 | 1.Notlist(without space) 22 | 1. list 23 | -------------------------------------------------------------------------------- /test/specs/new/list_loose.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • 3 |

    item 1

    4 |
  • 5 |
  • 6 |

    item 2

    7 |

    still item 2

    8 |
  • 9 |
10 | -------------------------------------------------------------------------------- /test/specs/new/list_loose.md: -------------------------------------------------------------------------------- 1 | - item 1 2 | - 3 | item 2 4 | 5 | still item 2 6 | -------------------------------------------------------------------------------- /test/specs/new/list_loose_tasks.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • 3 |

    Tasks

    4 |
  • 5 |
  • 6 |

    Task1

    7 |
  • 8 |
  • 9 |

    10 |
    Task2
    11 |
  • 12 |
  • 13 |

    14 |
  • 15 |
16 | -------------------------------------------------------------------------------- /test/specs/new/list_loose_tasks.md: -------------------------------------------------------------------------------- 1 | - Tasks 2 | - [x] Task1 3 | 4 | - [ ]
Task2
5 | 6 | - [ ] 7 | -------------------------------------------------------------------------------- /test/specs/new/list_paren_delimiter.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. one
  2. 3 |
  3. two
  4. 4 |
  5. three
  6. 5 |
6 | 7 |
8 | 9 |
    10 |
  1. two
  2. 11 |
  3. three
  4. 12 |
  5. four
  6. 13 |
14 | -------------------------------------------------------------------------------- /test/specs/new/list_paren_delimiter.md: -------------------------------------------------------------------------------- 1 | 1) one 2 | 2) two 3 | 3) three 4 | 5 | *** 6 | 7 | 2) two 8 | 3) three 9 | 4) four 10 | -------------------------------------------------------------------------------- /test/specs/new/list_table.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • 3 |

    Table in list:

    4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
    column1column2
    value1value2
    value3value4
    22 |
  • 23 |
  • 24 |

    No leading pipe table in list:

    25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
    column1column2
    value1value2
    value3value4
    43 |
  • 44 |
45 | -------------------------------------------------------------------------------- /test/specs/new/list_table.md: -------------------------------------------------------------------------------- 1 | * Table in list: 2 | 3 | | column1 | column2 | 4 | |---------|---------| 5 | | value1 | value2 | 6 | | value3 | value4 | 7 | 8 | * No leading pipe table in list: 9 | 10 | column1 | column2 11 | --------|-------- 12 | value1 | value2 13 | value3 | value4 14 | -------------------------------------------------------------------------------- /test/specs/new/list_tasks_non_gfm.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • [ ] A
  • 3 |
  • [x] B
  • 4 |
  • [ ] C
  • 5 |
6 | -------------------------------------------------------------------------------- /test/specs/new/list_tasks_non_gfm.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: false 3 | description: Task lists are ignored when not using GFM 4 | --- 5 | - [ ] A 6 | - [x] B 7 | - [ ] C -------------------------------------------------------------------------------- /test/specs/new/list_with_line_break.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. 3 |
4 |

Monday 5 | 2. 6 | Tuesday 7 | 3. 8 | Wednesday

9 | -------------------------------------------------------------------------------- /test/specs/new/list_with_line_break.md: -------------------------------------------------------------------------------- 1 | 1. 2 | Monday 3 | 2. 4 | Tuesday 5 | 3. 6 | Wednesday 7 | -------------------------------------------------------------------------------- /test/specs/new/multiple_sub_lists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. list item one

    3 |
      4 |
    1. sublist item one
    2. 5 |
    3. sublist item two
    4. 6 |
    7 |
  2. 8 |
  3. list item two

    9 |
      10 |
    1. sublist item one
    2. 11 |
    3. sublist item two
    4. 12 |
    13 |
  4. 14 |
  5. list item three

    15 |
      16 |
    1. sublist item one
    2. 17 |
    3. sublist item two
    4. 18 |
    19 |
  6. 20 |
  7. list item four

    21 |
      22 |
    1. sublist item one
    2. 23 |
    3. sublist item two
    4. 24 |
    25 |
  8. 26 |
27 | -------------------------------------------------------------------------------- /test/specs/new/multiple_sub_lists.md: -------------------------------------------------------------------------------- 1 | 1. list item one 2 | 1. sublist item one 3 | 2. sublist item two 4 | 5 | 2. list item two 6 | 1. sublist item one 7 | 2. sublist item two 8 | 9 | 3. list item three 10 | 1. sublist item one 11 | 2. sublist item two 12 | 13 | 4. list item four 14 | 1. sublist item one 15 | 2. sublist item two 16 | -------------------------------------------------------------------------------- /test/specs/new/nbsp_following_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
abcdef
barfoo
bazboo
23 | -------------------------------------------------------------------------------- /test/specs/new/nbsp_following_tables.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 |   6 | -------------------------------------------------------------------------------- /test/specs/new/nested_code.html: -------------------------------------------------------------------------------- 1 |

hi ther `` ok ```

2 | 3 |

`

4 | 5 |

There is a literal backtick (`) here.

6 | 7 |

A backtick-delimited string in a code span: `foo`

8 | 9 |

Please don't use any <blink> tags.

-------------------------------------------------------------------------------- /test/specs/new/nested_code.md: -------------------------------------------------------------------------------- 1 | ````` hi ther `` ok ``` ````` 2 | 3 | `` ` `` 4 | 5 | ``There is a literal backtick (`) here.`` 6 | 7 | A backtick-delimited string in a code span: `` `foo` `` 8 | 9 | Please don't use any `` tags. -------------------------------------------------------------------------------- /test/specs/new/nested_em.html: -------------------------------------------------------------------------------- 1 |

test test test

2 | 3 |

test test test

4 | -------------------------------------------------------------------------------- /test/specs/new/nested_em.md: -------------------------------------------------------------------------------- 1 | *test **test** test* 2 | 3 | _test __test__ test_ 4 | -------------------------------------------------------------------------------- /test/specs/new/nested_square_link.html: -------------------------------------------------------------------------------- 1 |

the ] character

2 | 3 |

the ` character

4 | -------------------------------------------------------------------------------- /test/specs/new/nested_square_link.md: -------------------------------------------------------------------------------- 1 | [the `]` character](/url) 2 | 3 | [the \` character](/url) 4 | -------------------------------------------------------------------------------- /test/specs/new/nogfm_hashtag.html: -------------------------------------------------------------------------------- 1 |

header

2 | 3 |

header1

4 | 5 |

header2

6 | -------------------------------------------------------------------------------- /test/specs/new/nogfm_hashtag.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: false 3 | pedantic: true 4 | --- 5 | #header 6 | 7 | # header1 8 | 9 | # header2 10 | -------------------------------------------------------------------------------- /test/specs/new/not_a_link.html: -------------------------------------------------------------------------------- 1 |

[test](not a link)

2 | -------------------------------------------------------------------------------- /test/specs/new/not_a_link.md: -------------------------------------------------------------------------------- 1 | \[test](not a link) 2 | -------------------------------------------------------------------------------- /test/specs/new/paragraph-after-list-item.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • 3 |
    4 |
  • 5 |
6 |

paragraph

7 |
    8 |
  • 9 |

    heading

    10 |
  • 11 |
12 |

paragraph

13 |
    14 |
  • 15 |
    indented code
    16 |
  • 17 |
18 |

paragraph

19 |
    20 |
  • 21 |
    fenced code
    22 |
  • 23 |
24 |

paragraph

25 | -------------------------------------------------------------------------------- /test/specs/new/paragraph-after-list-item.md: -------------------------------------------------------------------------------- 1 | - *** 2 | paragraph 3 | - # heading 4 | paragraph 5 | - indented code 6 | paragraph 7 | - ``` 8 | fenced code 9 | ``` 10 | paragraph 11 | -------------------------------------------------------------------------------- /test/specs/new/pedantic_heading.html: -------------------------------------------------------------------------------- 1 |

h1

2 | 3 |

h1

4 | 5 |

h1 #

6 | 7 |

h1

8 | 9 |

# h1

10 | -------------------------------------------------------------------------------- /test/specs/new/pedantic_heading.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | #h1 5 | 6 | #h1# 7 | 8 | #h1 # # 9 | 10 | #h1#### 11 | 12 | # h1 13 | -------------------------------------------------------------------------------- /test/specs/new/pedantic_heading_interrupts_paragraph.html: -------------------------------------------------------------------------------- 1 |

paragraph before head with hash

2 |

how are you

3 | 4 |

paragraph before head with equals

5 |

how are you again

6 | -------------------------------------------------------------------------------- /test/specs/new/pedantic_heading_interrupts_paragraph.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | 5 | paragraph before head with hash 6 | #how are you 7 | 8 | paragraph before head with equals 9 | how are you again 10 | =========== 11 | -------------------------------------------------------------------------------- /test/specs/new/ref_paren.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/specs/new/ref_paren.md: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [hi]: /url (there) 4 | -------------------------------------------------------------------------------- /test/specs/new/same_bullet.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • test
  • 3 |
  • test
  • 4 |
  • test
  • 5 |
6 | -------------------------------------------------------------------------------- /test/specs/new/same_bullet.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | * test 5 | + test 6 | - test 7 | -------------------------------------------------------------------------------- /test/specs/new/setext_blankline.html: -------------------------------------------------------------------------------- 1 |

a

2 |

b

3 |

=

4 | 5 |

a

6 |

b

7 |
    8 |
  • 9 |
10 | -------------------------------------------------------------------------------- /test/specs/new/setext_blankline.md: -------------------------------------------------------------------------------- 1 | a 2 | 3 | b 4 | 5 | = 6 | 7 | a 8 | 9 | b 10 | 11 | - 12 | -------------------------------------------------------------------------------- /test/specs/new/setext_no_blankline.html: -------------------------------------------------------------------------------- 1 |
indented code block
 2 | 
3 |

=

4 |

fenced code block

5 |
=
 6 | 
7 |

heading

8 |

=

9 | 10 | = 11 | -------------------------------------------------------------------------------- /test/specs/new/setext_no_blankline.md: -------------------------------------------------------------------------------- 1 | indented code block 2 | = 3 | 4 | fenced code block 5 | ``` 6 | = 7 | ``` 8 | 9 | ### heading 10 | = 11 | 12 | 13 | = 14 | -------------------------------------------------------------------------------- /test/specs/new/space_after_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
ab
12
15 | 16 |

there should be a single space at the end of every line above

17 | -------------------------------------------------------------------------------- /test/specs/new/space_after_table.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: true 3 | --- 4 | | a | b | 5 | |---|---| 6 | | 1 | 2 | 7 | 8 | there should be a single space at the end of every line above 9 | -------------------------------------------------------------------------------- /test/specs/new/strikethrough_in_em_strong.html: -------------------------------------------------------------------------------- 1 |

ab

2 | 3 |

ab

4 | 5 |

ab

6 | 7 |

ab

8 | 9 |

_a_b

10 | 11 |

_a_b

12 | 13 |

__a__b

14 | 15 |

__a__b

16 | 17 |

ba

18 | 19 |

ba

20 | 21 |

ba

22 | 23 |

ba

24 | 25 |

b_a_

26 | 27 |

b_a_

28 | 29 |

b__a__

30 | 31 |

b__a__

32 | 33 |

bab

34 | 35 |

bab

36 | 37 |

bab

38 | 39 |

bab

40 | 41 |

b_a_b

42 | 43 |

b_a_b

44 | 45 |

b__a__b

46 | 47 |

b__a__b

48 | -------------------------------------------------------------------------------- /test/specs/new/strikethrough_in_em_strong.md: -------------------------------------------------------------------------------- 1 | *~a~*b 2 | 3 | *~~a~~*b 4 | 5 | **~a~**b 6 | 7 | **~~a~~**b 8 | 9 | _~a~_b 10 | 11 | _~~a~~_b 12 | 13 | __~a~__b 14 | 15 | __~~a~~__b 16 | 17 | b*~a~* 18 | 19 | b*~~a~~* 20 | 21 | b**~a~** 22 | 23 | b**~~a~~** 24 | 25 | b_~a~_ 26 | 27 | b_~~a~~_ 28 | 29 | b__~a~__ 30 | 31 | b__~~a~~__ 32 | 33 | b*~a~*b 34 | 35 | b*~~a~~*b 36 | 37 | b**~a~**b 38 | 39 | b**~~a~~**b 40 | 41 | b_~a~_b 42 | 43 | b_~~a~~_b 44 | 45 | b__~a~__b 46 | 47 | b__~~a~~__b 48 | -------------------------------------------------------------------------------- /test/specs/new/strong_following_nptables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
abcdef
barfoo
bazboo
strong
23 | -------------------------------------------------------------------------------- /test/specs/new/strong_following_nptables.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | **strong** 6 | -------------------------------------------------------------------------------- /test/specs/new/strong_following_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
abcdef
barfoo
bazboo
strong
23 | -------------------------------------------------------------------------------- /test/specs/new/strong_following_tables.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | **strong** 6 | -------------------------------------------------------------------------------- /test/specs/new/substitutions.html: -------------------------------------------------------------------------------- 1 |

foo␤␤bar

2 | 3 |

* a *

4 | -------------------------------------------------------------------------------- /test/specs/new/substitutions.md: -------------------------------------------------------------------------------- 1 | foo␤␤bar 2 | 3 | * a * 4 | -------------------------------------------------------------------------------- /test/specs/new/tab_after_blockquote.html: -------------------------------------------------------------------------------- 1 |

test

-------------------------------------------------------------------------------- /test/specs/new/tab_after_blockquote.md: -------------------------------------------------------------------------------- 1 | > test -------------------------------------------------------------------------------- /test/specs/new/tab_newline.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
y
x
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
y
x
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
y
x
37 |
code
38 | 
39 | 40 | 41 | 42 | 43 | 44 | 45 |
y
46 | -------------------------------------------------------------------------------- /test/specs/new/tab_newline.md: -------------------------------------------------------------------------------- 1 | | y | 2 | | - | 3 | | x | 4 | 5 | | y | 6 | | - | 7 | | x | 8 | 9 | | y | 10 | | - | 11 | | x | 12 | code 13 | | y | 14 | | - | 15 | -------------------------------------------------------------------------------- /test/specs/new/table_cells.html: -------------------------------------------------------------------------------- 1 |
1
1
2 | 3 |
1
|
4 | 5 |
1
1\1
6 | 7 |
1
\\
8 | 9 |
1
\\|
10 | 11 |
12
2
12 | 13 |
12
1|\2|\
14 | 15 |
12
2
16 | 17 |
12
1|\2|\
18 | 19 |
12
2
20 | 21 |
12
12|
22 | 23 |
12
12|
24 | 25 |
12
12|
26 | 27 |
12
12|
28 | -------------------------------------------------------------------------------- /test/specs/new/table_cells.md: -------------------------------------------------------------------------------- 1 | |1| 2 | |-| 3 | |1| 4 | 5 | |1| 6 | |-| 7 | |\|| 8 | 9 | |1| 10 | |-| 11 | |1\\1| 12 | 13 | |1| 14 | |-| 15 | |\\\\|| 16 | 17 | |1| 18 | |-| 19 | |\\\\\|| 20 | 21 | |1|2| 22 | |-|-| 23 | ||2| 24 | 25 | |1|2| 26 | |-|-| 27 | |1\|\\|2\|\\| 28 | 29 | |1|2| 30 | |-|-| 31 | | |2| 32 | 33 | 1|2 34 | -|- 35 | 1\|\\|2\|\\ 36 | 37 | 1|2 38 | -|- 39 | |2 40 | 41 | 1|2 42 | -|- 43 | 1|2\| 44 | 45 | 1|2 46 | -|- 47 | 1|2\| 48 | 49 | |1|2| 50 | |-|-| 51 | |1|2\|| 52 | 53 | |1|2| 54 | |-|-| 55 | |1|2\|| 56 | -------------------------------------------------------------------------------- /test/specs/new/table_following_text.html: -------------------------------------------------------------------------------- 1 |

hello world

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
abcdef
barfoo
bazboo
20 |

hello world with empty line

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
abcdef
barfoo
bazboo
39 | -------------------------------------------------------------------------------- /test/specs/new/table_following_text.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: true 3 | --- 4 | hello world 5 | | abc | def | 6 | | --- | --- | 7 | | bar | foo | 8 | | baz | boo | 9 | 10 | hello world with empty line 11 | 12 | | abc | def | 13 | | --- | --- | 14 | | bar | foo | 15 | | baz | boo | 16 | -------------------------------------------------------------------------------- /test/specs/new/table_reference_link.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
a
d
13 | -------------------------------------------------------------------------------- /test/specs/new/table_reference_link.md: -------------------------------------------------------------------------------- 1 | | a | 2 | | ------ | 3 | | [d][c] | 4 | 5 | [c]: https://www.google.com 6 | -------------------------------------------------------------------------------- /test/specs/new/table_vs_setext.html: -------------------------------------------------------------------------------- 1 |

| setext |

2 |

| setext |

3 | 4 |

setext

5 |

setext

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
table
table
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
table
table
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
table
table
45 | 46 | 47 | -------------------------------------------------------------------------------- /test/specs/new/table_vs_setext.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: true 3 | --- 4 | | setext | 5 | ---------- 6 | | setext | 7 | 8 | setext 9 | ------ 10 | setext 11 | 12 | | table | 13 | :-------- 14 | | table | 15 | 16 | table 17 | :---- 18 | table 19 | 20 | | table | 21 | |-------- 22 | | table | 23 | -------------------------------------------------------------------------------- /test/specs/new/tabs_code.html: -------------------------------------------------------------------------------- 1 |
	tab
2 | 
3 | -------------------------------------------------------------------------------- /test/specs/new/tabs_code.md: -------------------------------------------------------------------------------- 1 | --- 2 | renderExact: true 3 | --- 4 | ``` 5 | tab 6 | ``` 7 | -------------------------------------------------------------------------------- /test/specs/new/text_following_nptables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
abcdef
barfoo
bazboo
hello
23 | -------------------------------------------------------------------------------- /test/specs/new/text_following_nptables.md: -------------------------------------------------------------------------------- 1 | abc | def 2 | --- | --- 3 | bar | foo 4 | baz | boo 5 | hello 6 | -------------------------------------------------------------------------------- /test/specs/new/text_following_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
abcdef
barfoo
bazboo
hello
23 | -------------------------------------------------------------------------------- /test/specs/new/text_following_tables.md: -------------------------------------------------------------------------------- 1 | | abc | def | 2 | | --- | --- | 3 | | bar | foo | 4 | | baz | boo | 5 | hello 6 | -------------------------------------------------------------------------------- /test/specs/new/toplevel_paragraphs.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | text after spaces 3 | text after spaces

4 | 5 |

paragraph before code

6 |
text inside block code
7 | 8 |

paragraph before hr

9 |
10 | 11 |

paragraph before blockquote

12 |

text for blockquote

13 | 14 |

paragraph before list

15 |
  • text inside list
16 | 17 |

paragraph before div

18 |
text inside div
19 | 20 |

paragraph with span 21 | text inside span

22 | 23 |

hello world 24 |

25 | 26 |
hello
27 | 28 |

hello

29 | -------------------------------------------------------------------------------- /test/specs/new/toplevel_paragraphs.md: -------------------------------------------------------------------------------- 1 | --- 2 | gfm: true 3 | --- 4 | hello world 5 | text after spaces 6 | text after spaces 7 | 8 | paragraph before code 9 | ``` 10 | text inside block code 11 | ``` 12 | 13 | paragraph before hr 14 | * * * 15 | 16 | paragraph before blockquote 17 | > text for blockquote 18 | 19 | paragraph before list 20 | * text inside list 21 | 22 | paragraph before div 23 |
text inside div
24 | 25 | paragraph with span 26 | text inside span 27 | 28 | hello [world][how] 29 | 30 | [how]: /are/you 31 | 32 |
hello
33 | 34 | hello 35 | -------------------------------------------------------------------------------- /test/specs/new/tricky_list.html: -------------------------------------------------------------------------------- 1 |

hello world

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

hello world

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

hello world

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

hello world

20 | 21 |
    22 |
  • hello world
  • 23 |
24 | -------------------------------------------------------------------------------- /test/specs/new/tricky_list.md: -------------------------------------------------------------------------------- 1 | **hello** _world_ 2 | 3 | * hello world 4 | 5 | **hello** _world_ 6 | 7 | * hello world 8 | 9 | **hello** _world_ 10 | 11 | * Hello world 12 | 13 | **hello** _world_ 14 | 15 | * hello world 16 | -------------------------------------------------------------------------------- /test/specs/new/underscore_link.html: -------------------------------------------------------------------------------- 1 |

test

2 | -------------------------------------------------------------------------------- /test/specs/new/underscore_link.md: -------------------------------------------------------------------------------- 1 | _[test](https://example.com?link=with_(underscore))_ 2 | -------------------------------------------------------------------------------- /test/specs/new/unicode_punctuation.html: -------------------------------------------------------------------------------- 1 |

Ideographic comma:

2 | 3 |
    4 |
  • 5 |

    6 | ×: あれ、fooこれ、それ 7 |

    8 |
  • 9 |
  • 10 |

    11 | ○: あれ、 fooこれ、それ 12 |

    13 |
  • 14 |
  • 15 |

    16 | ×: あれ、fooこれ 、それ 17 |

    18 |
  • 19 |
  • ○: あれ、fooこれ、それ

  • 20 |
  • 21 |

    ○: あれ、 fooこれ、それ

    22 |
  • 23 |
  • 24 |

    ○: あれ、fooこれ 、それ

    25 |
  • 26 |
27 | 28 |

Fullwidth colon:\uFF1A

29 | -------------------------------------------------------------------------------- /test/specs/new/unicode_punctuation.md: -------------------------------------------------------------------------------- 1 | Ideographic comma: 2 | 3 | * ×: あれ、**`foo`これ**、それ 4 | * ○: あれ、 **`foo`これ**、それ 5 | * ×: あれ、**`foo`これ** 、それ 6 | 7 | * ○: あれ、**fooこれ**、それ 8 | * ○: あれ、 **fooこれ**、それ 9 | * ○: あれ、**fooこれ** 、それ 10 | 11 | __Fullwidth colon__:\uFF1A 12 | -------------------------------------------------------------------------------- /test/specs/new/whiltespace_lines.html: -------------------------------------------------------------------------------- 1 |

paragraph

2 |

test

3 |
a
 4 |   
 5 | b
 6 | 
 7 | c
 8 | 
9 |
a
10 |   
11 | b
12 | 
13 | -------------------------------------------------------------------------------- /test/specs/new/whiltespace_lines.md: -------------------------------------------------------------------------------- 1 | --- 2 | renderExact: true 3 | --- 4 | paragraph 5 | 6 | test 7 | 8 | a 9 | 10 | b 11 | 12 | c 13 | 14 | ``` 15 | a 16 | 17 | b 18 | ``` 19 | -------------------------------------------------------------------------------- /test/specs/original/amps_and_angles_encoding.html: -------------------------------------------------------------------------------- 1 |

AT&T has an ampersand in their name.

2 | 3 |

AT&T is another way to write it.

4 | 5 |

This & that.

6 | 7 |

4 < 5.

8 | 9 |

6 > 5.

10 | 11 |

Here's a link with an ampersand in the URL.

12 | 13 |

Here's a link with an amersand in the link text: AT&T.

14 | 15 |

Here's an inline link.

16 | 17 |

Here's an inline link.

18 | -------------------------------------------------------------------------------- /test/specs/original/amps_and_angles_encoding.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | 5 | AT&T has an ampersand in their name. 6 | 7 | AT&T is another way to write it. 8 | 9 | This & that. 10 | 11 | 4 < 5. 12 | 13 | 6 > 5. 14 | 15 | Here's a [link] [1] with an ampersand in the URL. 16 | 17 | Here's a link with an amersand in the link text: [AT&T] [2]. 18 | 19 | Here's an inline [link](/script?foo=1&bar=2). 20 | 21 | Here's an inline [link](). 22 | 23 | 24 | [1]: http://example.com/?foo=1&bar=2 25 | [2]: http://att.com/ "AT&T" 26 | -------------------------------------------------------------------------------- /test/specs/original/auto_links.html: -------------------------------------------------------------------------------- 1 |

Link: http://example.com/.

2 | 3 |

With an ampersand: http://example.com/?foo=1&bar=2

4 | 5 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

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

16 | 17 |
or here: <http://example.com/>
18 | 
19 | -------------------------------------------------------------------------------- /test/specs/original/auto_links.md: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: 14 | -------------------------------------------------------------------------------- /test/specs/original/backslash_escapes.html: -------------------------------------------------------------------------------- 1 |

These should all get escaped:

2 | 3 |

Backslash: \

4 | 5 |

Backtick: `

6 | 7 |

Asterisk: *

8 | 9 |

Underscore: _

10 | 11 |

Left brace: {

12 | 13 |

Right brace: }

14 | 15 |

Left bracket: [

16 | 17 |

Right bracket: ]

18 | 19 |

Left paren: (

20 | 21 |

Right paren: )

22 | 23 |

Greater-than: >

24 | 25 |

Hash: #

26 | 27 |

Period: .

28 | 29 |

Bang: !

30 | 31 |

Plus: +

32 | 33 |

Minus: -

34 | 35 |

These should not, because they occur within a code block:

36 | 37 |
Backslash: \\
 38 | 
 39 | Backtick: \`
 40 | 
 41 | Asterisk: \*
 42 | 
 43 | Underscore: \_
 44 | 
 45 | Left brace: \{
 46 | 
 47 | Right brace: \}
 48 | 
 49 | Left bracket: \[
 50 | 
 51 | Right bracket: \]
 52 | 
 53 | Left paren: \(
 54 | 
 55 | Right paren: \)
 56 | 
 57 | Greater-than: \>
 58 | 
 59 | Hash: \#
 60 | 
 61 | Period: \.
 62 | 
 63 | Bang: \!
 64 | 
 65 | Plus: \+
 66 | 
 67 | Minus: \-
 68 | 
69 | 70 |

Nor should these, which occur in code spans:

71 | 72 |

Backslash: \\

73 | 74 |

Backtick: \`

75 | 76 |

Asterisk: \*

77 | 78 |

Underscore: \_

79 | 80 |

Left brace: \{

81 | 82 |

Right brace: \}

83 | 84 |

Left bracket: \[

85 | 86 |

Right bracket: \]

87 | 88 |

Left paren: \(

89 | 90 |

Right paren: \)

91 | 92 |

Greater-than: \>

93 | 94 |

Hash: \#

95 | 96 |

Period: \.

97 | 98 |

Bang: \!

99 | 100 |

Plus: \+

101 | 102 |

Minus: \-

103 | 104 | 105 |

These should get escaped, even though they're matching pairs for 106 | other Markdown constructs:

107 | 108 |

*asterisks*

109 | 110 |

_underscores_

111 | 112 |

`backticks`

113 | 114 |

This is a code span with a literal backslash-backtick sequence: \`

115 | 116 |

This is a tag with unescaped backticks bar.

117 | 118 |

This is a tag with backslashes bar.

119 | -------------------------------------------------------------------------------- /test/specs/original/backslash_escapes.md: -------------------------------------------------------------------------------- 1 | These should all get escaped: 2 | 3 | Backslash: \\ 4 | 5 | Backtick: \` 6 | 7 | Asterisk: \* 8 | 9 | Underscore: \_ 10 | 11 | Left brace: \{ 12 | 13 | Right brace: \} 14 | 15 | Left bracket: \[ 16 | 17 | Right bracket: \] 18 | 19 | Left paren: \( 20 | 21 | Right paren: \) 22 | 23 | Greater-than: \> 24 | 25 | Hash: \# 26 | 27 | Period: \. 28 | 29 | Bang: \! 30 | 31 | Plus: \+ 32 | 33 | Minus: \- 34 | 35 | 36 | 37 | These should not, because they occur within a code block: 38 | 39 | Backslash: \\ 40 | 41 | Backtick: \` 42 | 43 | Asterisk: \* 44 | 45 | Underscore: \_ 46 | 47 | Left brace: \{ 48 | 49 | Right brace: \} 50 | 51 | Left bracket: \[ 52 | 53 | Right bracket: \] 54 | 55 | Left paren: \( 56 | 57 | Right paren: \) 58 | 59 | Greater-than: \> 60 | 61 | Hash: \# 62 | 63 | Period: \. 64 | 65 | Bang: \! 66 | 67 | Plus: \+ 68 | 69 | Minus: \- 70 | 71 | 72 | Nor should these, which occur in code spans: 73 | 74 | Backslash: `\\` 75 | 76 | Backtick: `` \` `` 77 | 78 | Asterisk: `\*` 79 | 80 | Underscore: `\_` 81 | 82 | Left brace: `\{` 83 | 84 | Right brace: `\}` 85 | 86 | Left bracket: `\[` 87 | 88 | Right bracket: `\]` 89 | 90 | Left paren: `\(` 91 | 92 | Right paren: `\)` 93 | 94 | Greater-than: `\>` 95 | 96 | Hash: `\#` 97 | 98 | Period: `\.` 99 | 100 | Bang: `\!` 101 | 102 | Plus: `\+` 103 | 104 | Minus: `\-` 105 | 106 | 107 | These should get escaped, even though they're matching pairs for 108 | other Markdown constructs: 109 | 110 | \*asterisks\* 111 | 112 | \_underscores\_ 113 | 114 | \`backticks\` 115 | 116 | This is a code span with a literal backslash-backtick sequence: `` \` `` 117 | 118 | This is a tag with unescaped backticks bar. 119 | 120 | This is a tag with backslashes bar. 121 | -------------------------------------------------------------------------------- /test/specs/original/blockquotes_with_code_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

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

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /test/specs/original/blockquotes_with_code_blocks.md: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /test/specs/original/code_blocks.html: -------------------------------------------------------------------------------- 1 |
code block on the first line
 2 | 
3 | 4 |

Regular text.

5 | 6 |
code block indented by spaces
 7 | 
8 | 9 |

Regular text.

10 | 11 |
the lines in this block  
12 | all contain trailing spaces  
13 | 
14 | 15 |

Regular Text.

16 | 17 |
code block on the last line
18 | 
19 | -------------------------------------------------------------------------------- /test/specs/original/code_blocks.md: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line 15 | -------------------------------------------------------------------------------- /test/specs/original/code_spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 | 3 |

Fix for backticks within HTML tag: like this

4 | 5 |

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

6 | 7 | -------------------------------------------------------------------------------- /test/specs/original/code_spans.md: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. 6 | 7 | -------------------------------------------------------------------------------- /test/specs/original/hard_wrapped_paragraphs_with_list_like_lines.html: -------------------------------------------------------------------------------- 1 |

In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.

6 | 7 |

Here's one with a bullet. 8 | * criminey.

9 | -------------------------------------------------------------------------------- /test/specs/original/hard_wrapped_paragraphs_with_list_like_lines.md: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /test/specs/original/horizontal_rules.html: -------------------------------------------------------------------------------- 1 |

Dashes:

2 | 3 |
4 | 5 |
6 | 7 |
8 | 9 |
10 | 11 |
---
12 | 
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
- - -
23 | 
24 | 25 |

Asterisks:

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

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | 73 |

Not horizontal rules:

74 |

--*

75 |

-*-

76 |

*--

77 |

-_-

78 |

__-

79 |

-__

80 |
_-_
81 | 
82 |

Long rules:

83 |
84 |
85 |
86 | -------------------------------------------------------------------------------- /test/specs/original/horizontal_rules.md: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | 69 | 70 | 71 | Not horizontal rules: 72 | 73 | --* 74 | 75 | -*- 76 | 77 | *-- 78 | 79 | -_- 80 | 81 | __- 82 | 83 | -__ 84 | 85 | _-_ 86 | 87 | 88 | Long rules: 89 | 90 | ----------- 91 | 92 | ___________ 93 | 94 | *********** 95 | -------------------------------------------------------------------------------- /test/specs/original/inline_html_advanced.html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/specs/original/inline_html_advanced.md: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/specs/original/inline_html_comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

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

Paragraph two.

10 | 11 | 12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /test/specs/original/inline_html_comments.md: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /test/specs/original/inline_html_simple.html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

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

This should be a code block, though:

8 | 9 |
<div>
10 |     foo
11 | </div>
12 | 
13 | 14 |

As should this:

15 | 16 |
<div>foo</div>
17 | 
18 | 19 |

Now, nested:

20 | 21 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

This should just be an HTML comment:

30 | 31 | 32 | 33 |

Multiline:

34 | 35 | 39 | 40 |

Code block:

41 | 42 |
<!-- Comment -->
43 | 
44 | 45 |

Just plain comment, with trailing spaces on the line:

46 | 47 | 48 | 49 |

Code:

50 | 51 |
<hr />
52 | 
53 | 54 |

Hr's:

55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /test/specs/original/inline_html_simple.md: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /test/specs/original/links_inline_style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 | 3 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

URL and title.

10 | 11 |

URL and title.

12 | 13 |

URL and title.

14 | 15 |

Empty.

16 | -------------------------------------------------------------------------------- /test/specs/original/links_inline_style.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | 5 | Just a [URL](/url/). 6 | 7 | [URL and title](/url/ "title"). 8 | 9 | [URL and title](/url/ "title preceded by two spaces"). 10 | 11 | [URL and title](/url/ "title preceded by a tab"). 12 | 13 | [URL and title](/url/ "title has spaces afterward" ). 14 | 15 | [URL and title]( /url/has space ). 16 | 17 | [URL and title]( /url/has space/ "url has space and title"). 18 | 19 | [Empty](). 20 | -------------------------------------------------------------------------------- /test/specs/original/links_reference_style.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | 5 |

Foo bar.

6 | 7 |

With embedded [brackets].

8 | 9 |

Indented once.

10 | 11 |

Indented twice.

12 | 13 |

Indented thrice.

14 | 15 |

Indented [four][] times.

16 | 17 |
[four]: /url
18 | 
19 | 20 |
21 | 22 |

this should work

23 | 24 |

So should this.

25 | 26 |

And this.

27 | 28 |

And this.

29 | 30 |

And this.

31 | 32 |

But not [that] [].

33 | 34 |

Nor [that][].

35 | 36 |

Nor [that].

37 | 38 |

[Something in brackets like this should work]

39 | 40 |

[Same with this.]

41 | 42 |

In this case, this points to something else.

43 | 44 |

Backslashing should suppress [this] and [this].

45 | 46 |
47 | 48 |

Here's one where the link 49 | breaks across lines.

50 | 51 |

Here's another where the link 52 | breaks across lines, but with a line-ending space.

53 | -------------------------------------------------------------------------------- /test/specs/original/links_reference_style.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | 5 | Foo [bar] [1]. 6 | 7 | Foo [bar][1]. 8 | 9 | Foo [bar] 10 | [1]. 11 | 12 | [1]: /url/ "Title" 13 | 14 | 15 | With [embedded [brackets]] [b]. 16 | 17 | 18 | Indented [once][]. 19 | 20 | Indented [twice][]. 21 | 22 | Indented [thrice][]. 23 | 24 | Indented [four][] times. 25 | 26 | [once]: /url 27 | 28 | [twice]: /url 29 | 30 | [thrice]: /url 31 | 32 | [four]: /url 33 | 34 | 35 | [b]: /url/ 36 | 37 | * * * 38 | 39 | [this] [this] should work 40 | 41 | So should [this][this]. 42 | 43 | And [this] []. 44 | 45 | And [this][]. 46 | 47 | And [this]. 48 | 49 | But not [that] []. 50 | 51 | Nor [that][]. 52 | 53 | Nor [that]. 54 | 55 | [Something in brackets like [this][] should work] 56 | 57 | [Same with [this].] 58 | 59 | In this case, [this](/somethingelse/) points to something else. 60 | 61 | Backslashing should suppress \[this] and [this\]. 62 | 63 | [this]: foo 64 | 65 | 66 | * * * 67 | 68 | Here's one where the [link 69 | breaks] across lines. 70 | 71 | Here's another where the [link 72 | breaks] across lines, but with a line-ending space. 73 | 74 | 75 | [link breaks]: /url/ 76 | -------------------------------------------------------------------------------- /test/specs/original/links_shortcut_references.html: -------------------------------------------------------------------------------- 1 |

This is the simple case.

2 | 3 |

This one has a line 4 | break.

5 | 6 |

This one has a line 7 | break with a line-ending space.

8 | 9 |

this and the other

10 | -------------------------------------------------------------------------------- /test/specs/original/links_shortcut_references.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | 5 | This is the [simple case]. 6 | 7 | [simple case]: /simple 8 | 9 | 10 | 11 | This one has a [line 12 | break]. 13 | 14 | This one has a [line 15 | break] with a line-ending space. 16 | 17 | [line break]: /foo 18 | 19 | 20 | [this] [that] and the [other] 21 | 22 | [this]: /this 23 | [that]: /that 24 | [other]: /other 25 | -------------------------------------------------------------------------------- /test/specs/original/literal_quotes_in_titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /test/specs/original/literal_quotes_in_titles.md: -------------------------------------------------------------------------------- 1 | --- 2 | pedantic: true 3 | --- 4 | 5 | Foo [bar][]. 6 | 7 | Foo [bar](/url/ "Title with "quotes" inside"). 8 | 9 | 10 | [bar]: /url/ "Title with "quotes" inside" 11 | -------------------------------------------------------------------------------- /test/specs/original/nested_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /test/specs/original/nested_blockquotes.md: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /test/specs/original/ordered_and_unordered_lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

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

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 |
  • asterisk 2

  • 16 |
  • asterisk 3

  • 17 |
18 | 19 |
20 | 21 |

Pluses tight:

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

Pluses loose:

30 | 31 |
    32 |
  • Plus 1

  • 33 |
  • Plus 2

  • 34 |
  • Plus 3

  • 35 |
36 | 37 |
38 | 39 |

Minuses tight:

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

Minuses loose:

48 | 49 |
    50 |
  • Minus 1

  • 51 |
  • Minus 2

  • 52 |
  • Minus 3

  • 53 |
54 | 55 |

Ordered

56 | 57 |

Tight:

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

and:

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

Loose using tabs:

74 | 75 |
    76 |
  1. First

  2. 77 |
  3. Second

  4. 78 |
  5. Third

  6. 79 |
80 | 81 |

and using spaces:

82 | 83 |
    84 |
  1. One

  2. 85 |
  3. Two

  4. 86 |
  5. Three

  6. 87 |
88 | 89 |

Multiple paragraphs:

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

    93 | 94 |

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

  2. 96 |
  3. Item 2.

  4. 97 |
  5. Item 3.

  6. 98 |
99 | 100 |

Nested

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

Here's another:

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

Same thing but with paragraphs:

126 | 127 |
    128 |
  1. First

  2. 129 |
  3. Second:

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

  6. 137 |
138 | 139 | 140 |

This was an error in Markdown 1.0.1:

141 | 142 |
    143 |
  • this

    144 | 145 |
    • sub
    146 | 147 |

    that

  • 148 |
149 | 150 | 151 |

Ordered lists start from initial number:

152 | 153 |
    154 |
  1. Three
  2. 155 |
  3. Four
  4. 156 |
157 | 158 | 159 |

Ordered lists start from initial zero:

160 | 161 |
    162 |
  1. Zero
  2. 163 |
  3. One
  4. 164 |
165 | -------------------------------------------------------------------------------- /test/specs/original/ordered_and_unordered_lists.md: -------------------------------------------------------------------------------- 1 | ## Unordered 2 | 3 | Asterisks tight: 4 | 5 | * asterisk 1 6 | * asterisk 2 7 | * asterisk 3 8 | 9 | 10 | Asterisks loose: 11 | 12 | * asterisk 1 13 | 14 | * asterisk 2 15 | 16 | * asterisk 3 17 | 18 | * * * 19 | 20 | Pluses tight: 21 | 22 | + Plus 1 23 | + Plus 2 24 | + Plus 3 25 | 26 | 27 | Pluses loose: 28 | 29 | + Plus 1 30 | 31 | + Plus 2 32 | 33 | + Plus 3 34 | 35 | * * * 36 | 37 | 38 | Minuses tight: 39 | 40 | - Minus 1 41 | - Minus 2 42 | - Minus 3 43 | 44 | 45 | Minuses loose: 46 | 47 | - Minus 1 48 | 49 | - Minus 2 50 | 51 | - Minus 3 52 | 53 | 54 | ## Ordered 55 | 56 | Tight: 57 | 58 | 1. First 59 | 2. Second 60 | 3. Third 61 | 62 | and: 63 | 64 | 1. One 65 | 2. Two 66 | 3. Three 67 | 68 | 69 | Loose using tabs: 70 | 71 | 1. First 72 | 73 | 2. Second 74 | 75 | 3. Third 76 | 77 | and using spaces: 78 | 79 | 1. One 80 | 81 | 2. Two 82 | 83 | 3. Three 84 | 85 | Multiple paragraphs: 86 | 87 | 1. Item 1, graf one. 88 | 89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's 90 | back. 91 | 92 | 2. Item 2. 93 | 94 | 3. Item 3. 95 | 96 | 97 | 98 | ## Nested 99 | 100 | * Tab 101 | * Tab 102 | * Tab 103 | 104 | Here's another: 105 | 106 | 1. First 107 | 2. Second: 108 | * Fee 109 | * Fie 110 | * Foe 111 | 3. Third 112 | 113 | Same thing but with paragraphs: 114 | 115 | 1. First 116 | 117 | 2. Second: 118 | * Fee 119 | * Fie 120 | * Foe 121 | 122 | 3. Third 123 | 124 | 125 | This was an error in Markdown 1.0.1: 126 | 127 | * this 128 | 129 | * sub 130 | 131 | that 132 | 133 | Ordered lists start from initial number: 134 | 135 | 3. Three 136 | 1. Four 137 | 138 | Ordered lists start from initial zero: 139 | 140 | 0. Zero 141 | 1. One 142 | -------------------------------------------------------------------------------- /test/specs/original/tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list item 3 | indented with tabs

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

  • 6 |
7 | 8 |

Code:

9 | 10 |
this code block is indented by one tab
11 | 
12 | 13 |

And:

14 | 15 |
    this code block is indented by two tabs
16 | 
17 | 18 |

And:

19 | 20 |
+   this is an example list item
21 |     indented with tabs
22 | 
23 | +   this is an example list item
24 |     indented with spaces
25 | 
26 | -------------------------------------------------------------------------------- /test/specs/original/tabs.md: -------------------------------------------------------------------------------- 1 | + this is a list item 2 | indented with tabs 3 | 4 | + this is a list item 5 | indented with spaces 6 | 7 | Code: 8 | 9 | this code block is indented by one tab 10 | 11 | And: 12 | 13 | this code block is indented by two tabs 14 | 15 | And: 16 | 17 | + this is an example list item 18 | indented with tabs 19 | 20 | + this is an example list item 21 | indented with spaces 22 | -------------------------------------------------------------------------------- /test/specs/original/tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 |
    4 |
  • asterisk 1
  • 5 |
  • asterisk 2
  • 6 |
  • asterisk 3
  • 7 |
8 |
9 | -------------------------------------------------------------------------------- /test/specs/original/tidyness.md: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /test/specs/redos/cubic_def.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | markdown: `[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x`, 3 | html: `

[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x

`, 4 | }; 5 | -------------------------------------------------------------------------------- /test/specs/redos/link_code.html: -------------------------------------------------------------------------------- 1 |

INDEX(string, pattern[, start): searches for the first occurrence of pattern in string, starting from start:INDEX("123123", "23", 3)==5INSERT(new, old[, start][, length][, pad]): inserts the new string into the old string after the specified position (default is 0), new string is truncated or padded (default is " ") to the specified length, if start is beyond the end of old old will be paddedLASTPOS(pattern, string[, start]): searches backwards for the last occurrence of pattern in string, starting from start:LASTPOS("123123", "23", 4)==2LINES(file): returns the number of lines typed ahead at the interactive stream:push("a line"); push("second line"); lines(STDIN); /* == 2 */MAX(number, number[, number,...]): obviousMIN(number, number[, number,...]): obviousOPEN(filehandle, filename[, "APPEND"|"READ"|"WRITE"]): opens file, returns boolean for success:OPEN("MyCon", "CON:160/50/320/100/MyCon/CDS")==1OVERLAY(new, old[, start][, length][, pad]): overlays new string onto old one at start for length chars padding with pad if necessary:OVERLAY("4", "123", 5, 5)=="123-4----"POS(pattern, string[, start])` : same as index

2 | -------------------------------------------------------------------------------- /test/specs/redos/link_code.md: -------------------------------------------------------------------------------- 1 | INDEX(string, pattern[, start)` : searches for the first occurrence of pattern in string, starting from start: `INDEX("123123", "23", 3)` == `5` 2 | `INSERT(new, old[, start][, length][, pad])` : inserts the new string into the old string after the specified position (default is 0), new string is truncated or padded (default is " ") to the specified length, if start is beyond the end of old old will be padded 3 | `LASTPOS(pattern, string[, start])` : searches backwards for the last occurrence of pattern in string, starting from start: `LASTPOS("123123", "23", 4)` == `2` 4 | `LINES(file)` : returns the number of lines typed ahead at the interactive stream: `push("a line"); push("second line"); lines(STDIN); /* == 2 */` 5 | `MAX(number, number[, number,...])` : obvious 6 | `MIN(number, number[, number,...])` : obvious 7 | `OPEN(filehandle, filename[, "APPEND"|"READ"|"WRITE"])` : opens file, returns boolean for success: `OPEN("MyCon", "CON:160/50/320/100/MyCon/CDS")` == `1` 8 | `OVERLAY(new, old[, start][, length][, pad])` : overlays new string onto old one at start for length chars padding with pad if necessary: `OVERLAY("4", "123", 5, 5)` == `"123-4----"` 9 | `POS(pattern, string[, start])` : same as index 10 | -------------------------------------------------------------------------------- /test/specs/redos/quadratic_br.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | markdown: `a${' '.repeat(50000)}`, 3 | html: `

a${' '.repeat(50000)}

`, 4 | }; 5 | -------------------------------------------------------------------------------- /test/specs/redos/quadratic_em_mask.cjs: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | markdown: '['.repeat(100000), 4 | html: `

${'['.repeat(100000)}

`, 5 | }, 6 | { 7 | markdown: '[.'.repeat(50000), 8 | html: `

${'[.'.repeat(50000)}

`, 9 | }, 10 | { 11 | markdown: '<'.repeat(100000), 12 | html: `

${'<'.repeat(100000)}

`, 13 | }, 14 | { 15 | markdown: '<.'.repeat(50000), 16 | html: `

${'<.'.repeat(50000)}

`, 17 | }, 18 | ]; 19 | -------------------------------------------------------------------------------- /test/specs/redos/quadratic_email.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | markdown: 'a'.repeat(50000), 3 | html: `

${'a'.repeat(50000)}

`, 4 | }; 5 | -------------------------------------------------------------------------------- /test/specs/redos/quadratic_heading.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | markdown: `# #${' '.repeat(50000)}a`, 3 | html: '

# a

', 4 | }; 5 | -------------------------------------------------------------------------------- /test/specs/redos/quadratic_lists.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | markdown: '- a\n'.repeat(10000), 3 | html: `
    ${'
  • a
  • '.repeat(10000)}
`, 4 | }; 5 | -------------------------------------------------------------------------------- /test/specs/redos/quadratic_underscores.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | markdown: `${'_'.repeat(101)} a`, 3 | html: `

${'_'.repeat(101)} a

`, 4 | }; 5 | -------------------------------------------------------------------------------- /test/specs/redos/redos_html_closing.html: -------------------------------------------------------------------------------- 1 |

<tag "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""<" />a'a

2 | -------------------------------------------------------------------------------- /test/specs/redos/redos_html_closing.md: -------------------------------------------------------------------------------- 1 | a'a 2 | -------------------------------------------------------------------------------- /test/specs/redos/redos_nolink.html: -------------------------------------------------------------------------------- 1 |

![[[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[][[]!\

2 | -------------------------------------------------------------------------------- /test/specs/redos/redos_nolink.md: -------------------------------------------------------------------------------- 1 | ![\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]\[[]!\ 2 | -------------------------------------------------------------------------------- /test/specs/redos/reflink_redos.html: -------------------------------------------------------------------------------- 1 |

[[]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([

2 | -------------------------------------------------------------------------------- /test/specs/redos/reflink_redos.md: -------------------------------------------------------------------------------- 1 | [x]: x 2 | 3 | [\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\](\[\]([ 4 | -------------------------------------------------------------------------------- /test/umd-test.js: -------------------------------------------------------------------------------- 1 | import '../lib/marked.umd.js'; 2 | 3 | // eslint-disable-next-line no-undef 4 | if (!marked.parse('# test').includes(' '/cwd'), 22 | env: [], 23 | argv: [], 24 | stdout: { 25 | write: mock.fn((str) => { mocks.stdout += str; }), 26 | }, 27 | stderr: { 28 | write: mock.fn((str) => { mocks.stderr += str; }), 29 | }, 30 | stdin: { 31 | setEncoding: mock.fn(), 32 | on: mock.fn((method, func) => { 33 | mocks.stdin[method] = func; 34 | }), 35 | resume: mock.fn(), 36 | }, 37 | exit: mock.fn((code) => { mocks.code = code; }), 38 | }, 39 | }; 40 | 41 | return mocks; 42 | } 43 | 44 | function testInput({ args = [], stdin = '', stdinError = '', stdout = '', stderr = '', code = 0 } = {}) { 45 | return async() => { 46 | const mocks = createMocks(); 47 | mocks.process.argv = ['node', 'marked', ...args]; 48 | const mainPromise = main(mocks.process); 49 | if (typeof mocks.stdin.end === 'function') { 50 | if (stdin) { 51 | mocks.stdin.data(stdin); 52 | } 53 | if (stdinError) { 54 | mocks.stdin.error(stdinError); 55 | } 56 | mocks.stdin.end(); 57 | } 58 | await mainPromise; 59 | 60 | assert.ok(await htmlIsEqual(mocks.stdout, stdout)); 61 | assert.strictEqual(mocks.stderr, stderr); 62 | assert.strictEqual(mocks.code, code); 63 | }; 64 | } 65 | 66 | function fixturePath(filePath) { 67 | return resolve(__dirname, './fixtures', filePath); 68 | } 69 | 70 | describe('bin/marked', () => { 71 | describe('string', () => { 72 | it('-s', testInput({ 73 | args: ['-s', '# test'], 74 | stdout: '

test

', 75 | })); 76 | 77 | it('--string', testInput({ 78 | args: ['--string', '# test'], 79 | stdout: '

test

', 80 | })); 81 | }); 82 | 83 | describe('config', () => { 84 | it('-c', testInput({ 85 | args: ['-c', fixturePath('bin-config.js'), '-s', 'line1\nline2'], 86 | stdout: '

line1
line2

', 87 | })); 88 | 89 | it('--config', testInput({ 90 | args: ['--config', fixturePath('bin-config.js'), '-s', 'line1\nline2'], 91 | stdout: '

line1
line2

', 92 | })); 93 | 94 | it('config not found', testInput({ 95 | args: ['--config', fixturePath('does-not-exist.js'), '-s', 'line1\nline2'], 96 | stderr: `Cannot load config file '${fixturePath('does-not-exist.js')}'`, 97 | code: 1, 98 | })); 99 | }); 100 | 101 | describe('input', () => { 102 | it('input file not found', testInput({ 103 | args: [fixturePath('does-not-exist.md')], 104 | stderr: `marked: ${fixturePath('does-not-exist.md')}: No such file or directory`, 105 | code: 1, 106 | })); 107 | 108 | it('input file not found --input', testInput({ 109 | args: ['--input', fixturePath('does-not-exist.md')], 110 | stderr: `marked: ${fixturePath('does-not-exist.md')}: No such file or directory`, 111 | code: 1, 112 | })); 113 | }); 114 | }); 115 | -------------------------------------------------------------------------------- /test/unit/fixtures/bin-config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | breaks: true, 3 | }; 4 | -------------------------------------------------------------------------------- /test/unit/utils.js: -------------------------------------------------------------------------------- 1 | export async function timeout(ms = 1) { 2 | return new Promise(resolve => { 3 | setTimeout(resolve, ms); 4 | }); 5 | } 6 | -------------------------------------------------------------------------------- /test/update-specs.js: -------------------------------------------------------------------------------- 1 | import { readdirSync, unlinkSync, writeFileSync } from 'node:fs'; 2 | import { join, resolve, dirname } from 'node:path'; 3 | import { fileURLToPath } from 'node:url'; 4 | import { load } from 'cheerio'; 5 | import { htmlIsEqual } from '@markedjs/testutils'; 6 | import { Marked } from '../lib/marked.esm.js'; 7 | 8 | const __dirname = dirname(fileURLToPath(import.meta.url)); 9 | 10 | function removeFiles(dir) { 11 | readdirSync(dir).forEach(file => { 12 | unlinkSync(join(dir, file)); 13 | }); 14 | } 15 | 16 | async function updateCommonmark(dir, options) { 17 | try { 18 | const res = await fetch('https://raw.githubusercontent.com/commonmark/commonmark.js/master/package.json'); 19 | const pkg = await res.json(); 20 | const { version } = pkg; 21 | const res2 = await fetch(`https://spec.commonmark.org/${version}/spec.json`); 22 | const json = await res2.json(); 23 | const specs = await Promise.all(json.map(async(spec) => { 24 | const marked = new Marked(); 25 | const html = marked.parse(spec.markdown, options); 26 | const isEqual = await htmlIsEqual(html, spec.html); 27 | if (!isEqual) { 28 | spec.shouldFail = true; 29 | } 30 | return spec; 31 | })); 32 | writeFileSync(resolve(dir, `./commonmark.${version}.json`), JSON.stringify(specs, null, 2) + '\n'); 33 | console.log(`Saved CommonMark v${version} specs`); 34 | } catch (ex) { 35 | console.log(ex); 36 | } 37 | } 38 | 39 | async function updateGfm(dir) { 40 | try { 41 | const res = await fetch('https://github.github.com/gfm/'); 42 | const html = await res.text(); 43 | const $ = load(html); 44 | const version = $('.version').text().match(/\d+\.\d+/)[0]; 45 | if (!version) { 46 | throw new Error('No version found'); 47 | } 48 | let specs = []; 49 | $('.extension').each((i, ext) => { 50 | const section = $('.definition', ext).text().trim().replace(/^\d+\.\d+(.*?) \(extension\)[\s\S]*$/, '$1'); 51 | $('.example', ext).each((j, exa) => { 52 | const example = +$(exa).attr('id').replace(/\D/g, ''); 53 | const markdown = $('.language-markdown', exa).text().trim(); 54 | const html = $('.language-html', exa).text().trim(); 55 | specs.push({ 56 | section: `[extension] ${section}`, 57 | html, 58 | markdown, 59 | example, 60 | }); 61 | }); 62 | }); 63 | 64 | specs = await Promise.all(specs.map(async(spec) => { 65 | const marked = new Marked(); 66 | const html = marked.parse(spec.markdown, { gfm: true, pedantic: false }); 67 | const isEqual = await htmlIsEqual(html, spec.html); 68 | if (!isEqual) { 69 | spec.shouldFail = true; 70 | } 71 | return spec; 72 | })); 73 | writeFileSync(resolve(dir, `./gfm.${version}.json`), JSON.stringify(specs, null, 2) + '\n'); 74 | console.log(`Saved GFM v${version} specs.`); 75 | } catch (ex) { 76 | console.log(ex); 77 | } 78 | } 79 | 80 | const commonmarkDir = resolve(__dirname, './specs/commonmark'); 81 | const gfmDir = resolve(__dirname, './specs/gfm'); 82 | removeFiles(commonmarkDir); 83 | removeFiles(gfmDir); 84 | updateCommonmark(commonmarkDir, { gfm: false, pedantic: false }); 85 | updateCommonmark(gfmDir, { gfm: true, pedantic: false }); 86 | updateGfm(gfmDir); 87 | -------------------------------------------------------------------------------- /tsconfig-type-test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "baseUrl": ".", 5 | "paths": { 6 | "marked": [ 7 | "lib/marked.d.ts" 8 | ] 9 | } 10 | }, 11 | "include": [ 12 | "test/types/*.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2022", 4 | "module": "NodeNext", 5 | "isolatedModules": true, 6 | "strict": true, 7 | "verbatimModuleSyntax": true, 8 | "noEmit": true, 9 | "allowSyntheticDefaultImports": true, 10 | "moduleResolution": "NodeNext", 11 | "allowImportingTsExtensions": true, 12 | "sourceMap": false 13 | }, 14 | "include": [ 15 | "src/*.ts" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "cleanUrls": true 3 | } 4 | --------------------------------------------------------------------------------