Showing preview only (976K chars total). Download the full file or copy to clipboard to get everything.
Repository: markedjs/marked
Branch: master
Commit: d4c0fe58716e
Files: 411
Total size: 881.5 KB
Directory structure:
gitextract_6red701u/
├── .devcontainer/
│ └── devcontainer.json
├── .editorconfig
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── Bug_report.md
│ │ ├── Feature_request.md
│ │ └── Proposal.md
│ ├── ISSUE_TEMPLATE.md
│ ├── PULL_REQUEST_TEMPLATE/
│ │ └── badges.md
│ ├── PULL_REQUEST_TEMPLATE.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-dark.css
│ │ ├── hljs-github.css
│ │ ├── shared.css
│ │ └── style.css
│ ├── demo/
│ │ ├── demo.css
│ │ ├── demo.js
│ │ ├── index.html
│ │ ├── initial.md
│ │ ├── preview.html
│ │ ├── quickref.md
│ │ └── worker.js
│ └── js/
│ └── index.js
├── esbuild.config.js
├── eslint.config.js
├── man/
│ └── marked.1.md
├── 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.ts
│ ├── 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
│ │ │ ├── angle_brackets.html
│ │ │ ├── angle_brackets.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
│ │ │ ├── backtick_precedence.html
│ │ │ ├── backtick_precedence.md
│ │ │ ├── backticks_in_links.html
│ │ │ ├── backticks_in_links.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_flanking.html
│ │ │ ├── del_flanking.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_link_brackets.html
│ │ │ ├── em_link_brackets.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
│ │ │ ├── emoji_strikethrough.html
│ │ │ ├── emoji_strikethrough.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_newline.html
│ │ │ ├── escape_newline.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_alt.html
│ │ │ ├── image_alt.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_empty.html
│ │ │ ├── list_item_empty.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
│ │ │ ├── list_wrong_indent.html
│ │ │ ├── list_wrong_indent.md
│ │ │ ├── multiple_sub_lists.html
│ │ │ ├── multiple_sub_lists.md
│ │ │ ├── nbsp_following_tables.html
│ │ │ ├── nbsp_following_tables.md
│ │ │ ├── nested_blockquote_in_list.html
│ │ │ ├── nested_blockquote_in_list.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
│ │ │ ├── tasklist_blocks.html
│ │ │ ├── tasklist_blocks.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/
│ │ ├── backticks_alternating_in_link.html
│ │ ├── backticks_alternating_in_link.md
│ │ ├── backticks_in_link_label.html
│ │ ├── backticks_in_link_label.md
│ │ ├── cubic_def.cjs
│ │ ├── cubic_link_title.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
================================================
FILE CONTENTS
================================================
================================================
FILE: .devcontainer/devcontainer.json
================================================
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
{
"name": "marked",
// We're using node 14 for development, to keep close to the engine compatibility that marked.js uses.
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-14",
"postCreateCommand": "npm install",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"extensions": [
"dbaeumeur.vscode-eslint"
]
}
}
}
================================================
FILE: .editorconfig
================================================
root = true
[*.{json,js}]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
[*.md, !test/*.md]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4
================================================
FILE: .gitattributes
================================================
* eol=lf
test/* linguist-vendored
lib/* linguist-generated
================================================
FILE: .github/ISSUE_TEMPLATE/Bug_report.md
================================================
---
name: Bug report
about: Marked says it does this thing but does not
---
**Marked version:**
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
<!-- If possible, use the Marked Demo permalink and compare to the CommonMark Dingus permalink to demonstrate the bug -->
<!--
1. [Marked Demo](https://marked.js.org/demo/)
2. [CommonMark Demo](https://spec.commonmark.org/dingus/)
-->
<!-- If you need a specific version and options to reproduce the bug, use the following template -->
<!--
1. Install marked `npm install --save marked@0.3.19` with the version you are using
2. Run marked with input string and options such as `marked('hello *world*', {gfm: true})`
3. Actual output (or error) is...
-->
**Expected behavior**
A clear and concise description of what you expected to happen.
================================================
FILE: .github/ISSUE_TEMPLATE/Feature_request.md
================================================
---
name: Feature request
about: Marked doesn't do this thing and I think it should
---
**Describe the feature**
A clear and concise description of what you would like.
**Why is this feature necessary?**
A clear and concise description of why.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
================================================
FILE: .github/ISSUE_TEMPLATE/Proposal.md
================================================
---
name: Proposal
about: Marked doesn't do this thing and I think it should
---
**What pain point are you perceiving?.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
**Marked version:**
**Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a
<!-- The NPM version or commit hash having the issue -->
<!--
If submitting something other than a defect with Marked itself, please use the following:
**Proposal type:** new feature | project operations | other
## What pain point are you perceiving?
## What solution are you suggesting?
-->
## Expectation
**CommonMark Demo:** [demo](https://spec.commonmark.org/dingus/)
<!-- You can replace the link above with a permalink from: https://spec.commonmark.org/dingus/ -->
<!-- Describe the output you are expecting from marked -->
## Result
**Marked Demo:** [demo](https://marked.js.org/demo/)
<!-- You can replace the link above with a permalink from: https://marked.js.org/demo/ -->
<!-- Describe the output you received from marked -->
## What was attempted
<!-- Describe what code combination got you there -->
<!--
If error is thrown add the following:
## Call stack & console log
-->
================================================
FILE: .github/PULL_REQUEST_TEMPLATE/badges.md
================================================
**@mention the contributor:**
## Recommendation to:
- [ ] Change user group
- [ ] Add a badge
- [ ] Remove a badge
<!--
Explain your reasoning behind tagging that person.
Preferably by citing objective examples, like PRs, Issues, and so on.
-->
## As the one mentioned, I would like to:
- [ ] accept the recommendation; or,
- [ ] graciously decline; or,
- [ ] dispute the recommendation
within 30 days, if you have not indicated which option you are taking one of the following will happen:
1. If adding a badge, we will assume you are graciously declining.
2. If removing a badge, we will assume you do not want to dispute the recommendation; therefore, the badge will be removed.
<!--
Why would someone not accept a badge? Loads of reasons depending on the circumstances.
1. If you're a committer and someone puts a badge for you on having decision making authority in an area, do you really a) think you earned it and b) think you can do that *and* all the other stuff you got going as a committer, admin, or publisher (not to even mention your outside life)? Maybe not. And that's okay. Thank them for the recognition, explain you aren't able to take more on at the moment. It's cool to get recognized though.
2. Maybe you don't feel you actually earned it yet. I remember being in an interview once. The interviewer asked me to give an example of going above and beyond the call of duty. I said, "That's hard. Because what you consider going above and beyond may be what I consider to be 'just rising to'. If we're in battle and you get wounded and I pull you out of the frey before heading back into it, I don't consider that going above and beyond; I consider that rising to."
Why would someone remove their own badge? Loads of reasons...
1. Maybe you got a lot going on right now and want to broadcast to the Marked community that, "Hey, I don't want to say I'm going to do this unless I can really commit to it right now in a way that serves the project well." That's awesome! That takes courage! Because a) saying "no" is hard for most humans ("people pleasers") and b) the alternative, well, for those of us here since about October of 2017 (and prior), we know what the alternative can look like.
2. Maybe you just think you've done all you can to help and learned all you can from the experience. Again, very awesome and courageous. It takes courage to know when to walk away on your own accord.
Why would you want to remove someone's badge? Loads of reasons...
1. Maybe they have decision making authority on something. You asked for their advice. And, you ended up waiting almost a month before receiving a response.
2. Maybe it was relevant at the time (Master of Marked, for example) but you think they've lost their former level of skill (fell out of practice, for example). They could always get it back.
3. Maybe to signal to them that, "Hey, you seem to have forgotten about us. Are you still around (or alive)?"
Anyway, you get the idea. This isn't about good or bad...it's just about giving the community a simple game mechanic by which to publicly say, "Thank you" or "Here's what my status is" in the community or "Hey, I think something's wrong here" in a civil manner.
-->
Note: All committers must approve via review before merging, the disapproving committer can simply close the PR.
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
<!--
If badging PR, add ?template=badges.md to the PR url to use the badges PR template.
Otherwise, you are stating this PR fixes an issue that has been submitted; or,
describes the issue or proposal under consideration and contains the project-related code to implement.
-->
**Marked version:**
<!-- The NPM version or commit hash having the issue -->
**Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a
## Description
- Fixes #### (if fixing a known issue; otherwise, describe issue using the following format)
<!--
If no issue exists that you're aware of. The maintainers should be able to figure out if it's a duplicate.
## Expectation
Describe the output you are expecting from marked
## Result
Describe the output you received from marked
## What was attempted
Describe what code combination got you there
-->
## Contributor
- [ ] Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
- [ ] no tests required for this PR.
- [ ] If submitting new feature, it has been documented in the appropriate places.
## Committer
In most cases, this should be a different person than the contributor.
- [ ] CI is green (no forced merge required).
- [ ] Squash and Merge PR following [conventional commit guidelines](https://www.conventionalcommits.org/).
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm"
versioning-strategy: "increase"
directory: "/"
schedule:
interval: "weekly"
================================================
FILE: .github/workflows/tests.yml
================================================
name: "Tests"
on:
pull_request:
push:
branches:
- master
permissions:
contents: read
jobs:
UnitTests:
strategy:
matrix:
# lowest version here should also be in `engines` field
node_version: [20, "lts/*", "latest"]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Install Node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_version }}
check-latest: true
- name: Install Dependencies
run: npm ci
- name: Build 🗜️
run: npm run build
- name: Run Unit Tests 👩🏽💻
run: npm run test:unit
- name: Run Spec Tests 👩🏽💻
run: npm run test:specs
- name: Run CJS Tests 👩🏽💻
run: npm run test:cjs
OtherTests:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Install Node
uses: actions/setup-node@v6
with:
node-version: "lts/*"
- name: Install Dependencies
run: npm ci
- name: Build 🗜️
run: npm run build
- name: Run UMD Tests 👩🏽💻
run: npm run test:umd
- name: Run Types Tests 👩🏽💻
run: npm run test:types
- name: Lint ✨
run: npm run test:lint
Release:
permissions:
contents: write # to be able to publish a GitHub release
# issues: write # to be able to comment on released issues
# pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
needs: [UnitTests, OtherTests]
if: |
github.ref == 'refs/heads/master' &&
github.event.repository.fork == false
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Install Node
uses: actions/setup-node@v6
with:
node-version: "lts/*"
- name: Install Dependencies
run: npm ci
- name: Build 🗜️
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
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]+')
echo "Next Version: $SEMANTIC_RELEASE_NEXT_VERSION"
npm run build
if ! git diff --quiet; then
git config --global user.email "<>"
git config --global user.name "MarkedJS bot"
git commit -am "🗜️ build v$SEMANTIC_RELEASE_NEXT_VERSION [skip ci]"
fi
- name: Release 🎉
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
================================================
FILE: .gitignore
================================================
.DS_Store
.vercel
.vscode
node_modules/
test/compiled_tests
public
lib
docs/LICENSE.md
vuln.js
man/marked.1
test.js
================================================
FILE: .releaserc.json
================================================
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
}
================================================
FILE: CHANGELOG.md
================================================
see https://github.com/markedjs/marked/releases
================================================
FILE: LICENSE.md
================================================
# License information
## Contribution License Agreement
If you contribute code to this project, you are implicitly allowing your code
to be distributed under the MIT license. You are also implicitly verifying that
all code is your original work. `</legalese>`
## Marked
Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## Markdown
Copyright © 2004, John Gruber
http://daringfireball.net/
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
================================================
FILE: README.md
================================================
<a href="https://marked.js.org">
<img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
</a>
# Marked
[](https://www.npmjs.com/package/marked)
[](https://packagephobia.now.sh/result?p=marked)
[](https://www.npmjs.com/package/marked)
[](https://github.com/markedjs/marked/actions)
[](https://snyk.io/test/npm/marked)
- ⚡ built for speed
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
- 🌐 works in a browser, on a server, or from a command line interface (CLI)
## Demo
Check out the [demo page](https://marked.js.org/demo/) to see Marked in action ⛹️
## Docs
Our [documentation pages](https://marked.js.org) are also rendered using marked 💯
Also read about:
* [Options](https://marked.js.org/using_advanced)
* [Extensibility](https://marked.js.org/using_pro)
## Compatibility
**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.
**Browser:** [Baseline Widely Available](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Compatibility)
## Installation
**CLI:**
```sh
npm install -g marked
```
**In-browser:**
```sh
npm install marked
```
## Usage
### 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! 🚨
```
DOMPurify.sanitize(marked.parse(`<img src="x" onerror="alert('not happening')">`));
```
**CLI**
``` bash
# Example with stdin input
$ marked -o hello.html
hello world
^D
$ cat hello.html
<p>hello world</p>
```
```bash
# Print all options
$ marked --help
```
**Browser**
```html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Marked in the browser</title>
</head>
<body>
<div id="content"></div>
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
<script>
document.getElementById('content').innerHTML =
marked.parse('# Marked in the browser\n\nRendered by **marked**.');
</script>
</body>
</html>
```
or import esm module
```html
<script type="module">
import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
document.getElementById('content').innerHTML =
marked.parse('# Marked in the browser\n\nRendered by **marked**.');
</script>
```
## License
Copyright (c) 2018+, MarkedJS. (MIT License)
Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
================================================
FILE: SECURITY.md
================================================
# Security Policy
The only completely secure system is the one that doesn't exist in the first place.
Having said that, we take the security of Marked very seriously.
## Reporting a Vulnerability
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).
We will provide an initial assessment of security reports within 48 hours and should apply patches within 2 weeks
(also, feel free to contribute a fix for the issue).
================================================
FILE: api/dingus.js
================================================
import { marked } from '../lib/marked.esm.js';
import pkg from '../package.json' with { type: 'json' };
const version = pkg.version;
const name = 'Marked';
export default function dingus(req, res) {
if (req.method !== 'GET') {
return res.status(405).json({
error: {
code: 'method_not_allowed',
message: 'Only GET requests are supported for this endpoint.',
},
});
}
const { text = '' } = req.query;
const html = marked(text);
res.json({ name, version, html });
}
================================================
FILE: bin/main.js
================================================
#!/usr/bin/env node
/**
* Marked CLI
* Copyright (c) 2018+, MarkedJS. (MIT License)
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
*/
import { promises } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { homedir } from 'node:os';
import { createRequire } from 'node:module';
import { marked } from '../lib/marked.esm.js';
const { access, readFile, writeFile } = promises;
const require = createRequire(import.meta.url);
/**
* @param {Process} nodeProcess inject process so it can be mocked in tests.
*/
export async function main(nodeProcess) {
/**
* Man Page
*/
async function help() {
const { spawn } = await import('child_process');
const { fileURLToPath } = await import('url');
const options = {
cwd: nodeProcess.cwd(),
env: nodeProcess.env,
stdio: 'inherit',
};
const __dirname = dirname(fileURLToPath(import.meta.url));
const helpText = await readFile(resolve(__dirname, '../man/marked.1.md'), 'utf8');
await new Promise(res => {
const manProcess = spawn('man', [resolve(__dirname, '../man/marked.1')], options);
nodeProcess.on('SIGINT', () => {
manProcess.kill('SIGINT');
});
manProcess.on('error', () => {
console.log(helpText);
})
.on('close', res);
});
}
async function version() {
const pkg = require('../package.json');
console.log(pkg.version);
}
/**
* Main
*/
async function start(argv) {
const files = [];
const options = {};
let input;
let output;
let string;
let arg;
let tokens;
let config;
let opt;
let noclobber;
function getArg() {
let arg = argv.shift();
if (arg.indexOf('--') === 0) {
// e.g. --opt
arg = arg.split('=');
if (arg.length > 1) {
// e.g. --opt=val
argv.unshift(arg.slice(1).join('='));
}
arg = arg[0];
} else if (arg[0] === '-') {
if (arg.length > 2) {
// e.g. -abc
argv = arg.substring(1).split('').map(function(ch) {
return '-' + ch;
}).concat(argv);
arg = argv.shift();
} else {
// e.g. -a
}
} else {
// e.g. foo
}
return arg;
}
while (argv.length) {
arg = getArg();
switch (arg) {
case '-o':
case '--output':
output = argv.shift();
break;
case '-i':
case '--input':
input = argv.shift();
break;
case '-s':
case '--string':
string = argv.shift();
break;
case '-t':
case '--tokens':
tokens = true;
break;
case '-c':
case '--config':
config = argv.shift();
break;
case '-n':
case '--no-clobber':
noclobber = true;
break;
case '-h':
case '--help':
return await help();
case '-v':
case '--version':
return await version();
default:
if (arg.indexOf('--') === 0) {
opt = camelize(arg.replace(/^--(no-)?/, ''));
if (!(opt in marked.defaults)) {
continue;
}
if (arg.indexOf('--no-') === 0) {
options[opt] = typeof marked.defaults[opt] !== 'boolean'
? null
: false;
} else {
options[opt] = typeof marked.defaults[opt] !== 'boolean'
? argv.shift()
: true;
}
} else {
files.push(arg);
}
break;
}
}
async function getData() {
if (!input) {
if (files.length <= 2) {
if (string) {
return string;
}
return await getStdin();
}
input = files.pop();
}
return await readFile(input, 'utf8');
}
function resolveFile(file) {
return resolve(file.replace(/^~/, homedir));
}
function fileExists(file) {
return access(resolveFile(file)).then(() => true, () => false);
}
async function runConfig(file) {
const configFile = resolveFile(file);
let markedConfig;
try {
// try require for json
markedConfig = require(configFile);
} catch(err) {
if (err.code !== 'ERR_REQUIRE_ESM') {
throw err;
}
// must import esm
markedConfig = await import('file:///' + configFile);
}
if (markedConfig.default) {
markedConfig = markedConfig.default;
}
if (typeof markedConfig === 'function') {
markedConfig(marked);
} else {
marked.use(markedConfig);
}
}
const data = await getData();
if (config) {
if (!await fileExists(config)) {
throw Error(`Cannot load config file '${config}'`);
}
await runConfig(config);
} else {
const defaultConfig = [
'~/.marked.json',
'~/.marked.js',
'~/.marked/index.js',
];
for (const configFile of defaultConfig) {
if (await fileExists(configFile)) {
await runConfig(configFile);
break;
}
}
}
const html = tokens
? JSON.stringify(marked.lexer(data, options), null, 2)
: await marked.parse(data, options);
if (output) {
if (noclobber && await fileExists(output)) {
throw Error('marked: output file \'' + output + '\' already exists, disable the \'-n\' / \'--no-clobber\' flag to overwrite\n');
}
return await writeFile(output, html);
}
nodeProcess.stdout.write(html + '\n');
}
/**
* Helpers
*/
function getStdin() {
return new Promise((resolve, reject) => {
const stdin = nodeProcess.stdin;
let buff = '';
stdin.setEncoding('utf8');
stdin.on('data', function(data) {
buff += data;
});
stdin.on('error', function(err) {
reject(err);
});
stdin.on('end', function() {
resolve(buff);
});
stdin.resume();
});
}
/**
* @param {string} text
*/
function camelize(text) {
return text.replace(/(\w)-(\w)/g, function(_, a, b) {
return a + b.toUpperCase();
});
}
try {
await start(nodeProcess.argv.slice());
nodeProcess.exit(0);
} catch(err) {
if (err.code === 'ENOENT') {
nodeProcess.stderr.write('marked: ' + err.path + ': No such file or directory');
} else {
nodeProcess.stderr.write(err.message);
}
return nodeProcess.exit(1);
}
}
================================================
FILE: bin/marked.js
================================================
#!/usr/bin/env node
/**
* Marked CLI
* Copyright (c) 2018+, MarkedJS. (MIT License)
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
*/
import { main } from './main.js';
/**
* Expose / Entry Point
*/
process.title = 'marked';
main(process);
================================================
FILE: docs/.eslintrc.json
================================================
{
"extends": "standard",
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "script"
},
"rules": {
"semi": ["error", "always"],
"indent": ["error", 2, {
"SwitchCase": 1,
"VariableDeclarator": { "var": 2 },
"outerIIFEBody": 0
}],
"operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
"space-before-function-paren": ["error", "never"],
"no-cond-assign": "off",
"no-useless-escape": "off",
"one-var": "off",
"no-control-regex": "off",
"no-prototype-builtins": "off",
"prefer-const": "error",
"no-var": "error"
},
"env": {
"node": true,
"browser": true,
"amd": true
}
}
================================================
FILE: docs/AUTHORS.md
================================================
# Authors
Marked takes an encompassing approach to its community. As such, you can think of these as [concentric circles](https://medium.com/the-node-js-collection/healthy-open-source-967fa8be7951), where each group encompasses the following groups.
<table>
<tbody>
<tr>
<td align="center" valign="top" style="width:32%">
<a href="https://github.com/chjj">
<img width="100" height="100" src="https://github.com/chjj.png?s=150">
</a>
<br>
<a href="https://github.com/chjj">Christopher Jeffrey</a>
<div>Original Author</div>
<small>Started the fire</small>
</td>
<td align="center" valign="top" style="width:32%">
<a href="https://github.com/joshbruce">
<img width="100" height="100" src="https://github.com/joshbruce.png?s=150">
</a>
<br>
<a href="https://joshbruce.com">Josh Bruce</a>
<div>Publisher</div>
<small>Release Wrangler; Humaning Helper; Heckler of Hypertext</small>
</td>
<td align="center" valign="top" style="width:32%">
<a href="https://github.com/styfle">
<img width="100" height="100" src="https://github.com/styfle.png?s=150">
</a>
<br>
<a href="https://www.ceriously.com">Steven</a>
<div>Publisher</div>
<small>Release Wrangler; Dr. Docs; Open source, of course; GitHub Guru; Humaning Helper</small>
</td>
</tr>
<tr>
<td align="center" valign="top">
<a href="https://github.com/davisjam">
<img width="100" height="100" src="https://github.com/davisjam.png?s=150">
</a>
<br>
<a href="https://github.com/davisjam">Jamie Davis</a>
<div>Committer</div>
<small>Seeker of Security</small>
</td>
<td align="center" valign="top">
<a href="https://github.com/UziTech">
<img width="100" height="100" src="https://github.com/UziTech.png?s=150">
</a>
<br>
<a href="https://tony.brix.ninja">Tony Brix</a>
<div>Publisher</div>
<small>Release Wrangler; Titan of the test harness; Dr. DevOps</small>
</td>
<td align="center" valign="top">
<a href="https://github.com/calculuschild">
<img width="100" height="100" src="https://github.com/calculuschild.png?s=150">
</a>
<br>
<a href="https://github.com/calculuschild">Trevor Buckner</a>
<div>Committer</div>
<small>Master of Marked</small>
</td>
</tr>
</tbody>
</table>
## Contributors
<table>
<tbody>
<tr>
<td align="center" valign="top">
<a href="https://github.com/intcreator">
<img width="100" height="100" src="https://github.com/intcreator.png?s=150">
</a>
<br>
<a href="https://github.com/intcreator">Brandon der Blätter</a>
<div>Contributor</div>
<small>Curious Contributor</small>
</td>
<td align="center" valign="top">
<a href="https://github.com/carlosvalle">
<img width="100" height="100" src="https://github.com/carlosvalle.png?s=150">
</a>
<br>
<a href="https://github.com/carlosvalle">Carlos Valle</a>
<div>Contributor</div>
<small>Maker of the Marked mark from 2018 to present</small>
</td>
<td align="center" width="20%" valign="top">
<a href="https://github.com/Feder1co5oave">
<img width="100" height="100" src="https://github.com/Feder1co5oave.png?s=150">
</a>
<br>
<a href="https://github.com/Feder1co5oave">Federico Soave</a>
<div>Contributor</div>
<small>Regent of the Regex; Master of Marked</small>
</td>
<td align="center" valign="top">
<a href="https://github.com/karenyavine">
<img width="100" height="100" src="https://github.com/karenyavine.png?s=150">
</a>
<br>
<a href="https://github.com/karenyavine">Karen Yavine</a>
<div>Contributor</div>
<small>Snyk's Security Saint</small>
</td>
</tr>
<tr>
<td align="center" valign="top">
<a href="https://github.com/KostyaTretyak">
<img width="100" height="100" src="https://github.com/KostyaTretyak.png?s=150">
</a>
<br>
<a href="https://github.com/KostyaTretyak">Костя Третяк</a>
<div>Contributor</div>
<small></small>
</td>
<td align="center" width="20%" valign="top">
<a href="https://github.com/tomtheisen">
<img width="100" height="100" src="https://github.com/tomtheisen.png?s=150">
</a>
<br>
<a href="https://github.com/tomtheisen">Tom Theisen</a>
<div>Contributor</div>
<small>Defibrillator</small>
</td>
<td align="center" width="20%" valign="top">
<a href="https://github.com/mccraveiro">
<img width="100" height="100" src="https://github.com/mccraveiro.png?s=150">
</a>
<br>
<a href="https://github.com/mccraveiro">Mateus Craveiro</a>
<div>Contributor</div>
<small>Defibrillator</small>
</td>
<td align="center" width="20%" valign="top">
</td>
</tr>
</tbody>
</table>
## Publishers
Publishers are admins who also have the responsibility, privilege, and burden of publishing the new releases to NPM and performing outreach and external stakeholder communications. Further, when things go pear-shaped, they're the ones taking most of the heat. Finally, when things go well, they're the primary ones praising the contributors who made it possible.
(In other words, while Admins are focused primarily on the internal workings of the project, Publishers are focused on internal *and* external concerns.)
**Should not exceed 2:** Having more people with the authority to publish a release can quickly turn into a consensus seeking nightmare (design by committee). Having only one is preferred (Directly Responsible Individual); however, given the nature of the project and its history, having an immediate fallback, and a potential deep fallback (Original author) is probably a good idea.
[Details on badges](#badges)
## Admins
Admins are committers who also have the responsibility, privilege, and burden of selecting committers and making sure the project itself runs smoothly, which includes community maintenance, governance, dispute resolution, and so on. (Letting the contributors easily enter into, and work within, the project to begin contributing, with as little friction as possible.)
**Should not exceed 3:** When there are too many people with the ability to resolve disputes, the dispute itself can quickly turn into a dispute amongst the admins themselves; therefore, we want this group to be small enough to commit to action and large enough to not put too much burden on one person. (Should ensure faster resolution and responsiveness.)
To be listed: Admins are usually selected from the pool of committers (or they volunteer, using the same process) who demonstrate good understanding of the marked culture, operations, and do their best to help new contributors get up to speed on how to contribute effectively to the project.
To be removed: You can remove yourself through the [GitHub UI](https://help.github.com/articles/removing-yourself-from-a-collaborator-s-repository/).
[Details on badges](#badges)
## Committers
Committers are contributors who also have the responsibility, privilege, some might even say burden of being able to review and merge contributions (just usually not their own).
A note on "decision making authority". This is related to submitting PRs and the [advice process](https://reinventingorganizationswiki.com/en/theory/decision-making/). The person marked as having decision making authority over a certain area should be sought for advice in that area before committing to a course of action.
**Should not exceed 5:** For larger PRs affecting more of the codebase and, most likely, review by more people, we try to keep this pool small and responsive and let those with decision making authority have final say without negative repercussions from the other committers.
To be listed: Committers are usually selected (or they volunteer, using the same process) from contributors who enter the discussions regarding the future direction of Marked (maybe even doing informal reviews of contributions despite not being able to merge them yourself).
To be removed: You can remove yourself through the [GitHub UI](https://help.github.com/articles/removing-yourself-from-a-collaborator-s-repository/).
A note on volunteering:
1. Please do not volunteer unless you believe you can demonstrate to your peers you can do the work required.
2. Please do not overcommit yourself; we count on those committed to the project to be responsive. Really consider, with all you have going on, whether you able to really commit to it.
3. Don't let the previous frighten you away, it can always be changed later by you or your peers.
[Details on badges](#badges)
## Contributors
Contributors are users who submit a [PR](https://github.com/markedjs/marked/pulls), [Issue](https://github.com/markedjs/marked/issues), or collaborate in making Marked a better product and experience for all the users.
To be listed: make a contribution and, if it has significant impact, the committers may be able to add you here.
To be removed: please let us know or submit a PR.
[Details on badges](#badges)
## Users
Users are anyone using Marked in some fashion, without them, there's no reason for us to exist.
|Individual or Organization |Website |Project |Submitted by |
|:--------------------------|:-----------------------|:------------------------------------|:---------------------------------------------------|
|MarkedJS |https://marked.js.org |https://github.com/markedjs/marked |The marked committers |
To be listed: All fields are optional. Contact any of the committers or, more timely, submit a pull request with the following (using the first row as an example):
- **Individual or Organization:** The name you would like associated with the record.
- **Website:** A URL to a standalone website for the project.
- **Project:** A URL for the repository of the project using marked.
- **Submitted by:** The name and optional honorifics for the person adding the listing.
To be removed: Same as above. Only instead of requesting addition request deletion or delete the row yourself.
<h2 id="badges">Badges</h2>
Badges? You don't *need* no stinkin' badges.
Movie references aside. (It was either that or, "Let's play a game", but that would have been creepy…that's why it will most likely come later.)
Badges? If you *want* 'em, we got 'em, and here's how you get 'em (and…dramatic pause…why not two dramatic pauses for emphasis?… how they can be taken away).
- [ ] Add the appropriate badge to the desired contributor in the desired column of this page, even if they're not listed here yet.
- [ ] Submit a PR (we're big on PRs around here, if you haven't noticed, help us help you).
- [ ] Follow the instructions for submitting a badge PR. (There are more details to find within. Come on. Everybody likes surprises, right? No? Actually, we just try to put documentation where it belongs, closer to the code and part of the sequence of events.)
### Badges at play:
<dl>
<dt>Curious Contributor</dt>
<dd>A contributor with less than one year on this page who is actively engaged in submitting PRs, Issues, making recommendations, sharing thoughts…without being too annoying about it (let's be clear, submitting 100 Issues recommending the Marked Committers send everyone candy is trying for the badge, not honestly earning it).</dd>
<dt>Dr. DevOps</dt>
<dd>
<p>Someone who understands and contributes to improving the developer experience and flow of Marked into the world.</p>
<blockquote>
"The main characteristic of the DevOps movement is to strongly advocate automation and monitoring at all steps of software construction, from integration, testing, releasing to deployment and infrastructure management. DevOps aims at shorter development cycles, increased deployment frequency, more dependable releases, in close alignment with business objectives." ~ <a href="https://www.wikipedia.org/wiki/DevOps">Wikipedia</a>
</blockquote>
</dd>
<dt>Dr. Docs</dt>
<dd>Someone who has contributed a great deal to the creation and maintenance of the non-code areas of marked.</dd>
<dt>Eye for the CLI</dt>
<dd>At this point? Pretty much anyone who can update that `man` file to the current Marked version without regression in the CLI tool itself.</dd>
<dt>GitHub Guru</dt>
<dd>Someone who always seems to be able to tell you easier ways to do things with GitHub.</dd>
<dt>Humaning Helper</dt>
<dd>Someone who goes out of their way to help contributors feel welcomed and valued. Further, someone who takes the extra steps(s) necessary to help new contributors get up to speed. Finally, they maintain composure even in times of disagreement and dispute resolution.</dd>
<dt>Heckler of Hypertext</dt>
<dd>Someone who demonstrates an esoteric level of knowledge when it comes to HTML. In other words, someone who says things like, "Did you know most Markdown flavors don't have a way to render a description list (`dl`)? All the more reason Markdown `!==` HTML."</dd>
<dt>Markdown Maestro</dt>
<dd>You know that person who knows about way too many different flavors of Markdown? The one who maybe seems a little too obsessed with the possibilities of Markdown beyond HTML? Come on. You know who they are. Or, at least you could, if you give them this badge.</dd>
<dt>Master of Marked</dt>
<dd>Someone who demonstrates they know the ins and outs of the codebase for Marked.</dd>
<dt>Open source, of course</dt>
<dd>Someone who advocates for and has a proven understanding of how to operate within open source communities.</dd>
<dt>Regent of the Regex</dt>
<dd><p>Can you demonstrate you understand the following without Google and Stackoverflow?</p>
<p><code>/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/</code></p>
<p>Because this author can't yet. That's who gets these.</p>
</dd>
<dt>Seeker of Security</dt>
<dd>Someone who has demonstrated a high degree of expertise or authority when it comes to software security.</dd>
<dt>Titan of the Test Harness</dt>
<dd>Someone who demonstrates high-levels of understanding regarding Marked's test harness.</dd>
<dt>Totally Tron</dt>
<dd>Someone who demonstrates they are willing and able to "fight for the users", both developers dependent on marked to do their jobs as well as end-users interacting with the output (particularly in the realm of those with the disabilities).</dd>
</dl>
### Special badges that come with the job:
<dl>
<dt>Defibrillator</dt>
<dd>A contributor who stepped up to help bring Marked back to life by contributing solutions to help Marked pass when compared against the CommonMark and GitHub Flavored Markdown specifications.</dd>
<dt>Maker of the Marked mark</dt>
<dd>This badge is given to the person or organization credited with creating the logo (or logotype) used in Marked communications for a given period of time. **Maker of the Marked mark from 2017 to present**, for example.</dd>
<dt>Release Wrangler</dt>
<dd>This is a badge given to all Publishers.</dd>
<dt>Snyk's Security Saint</dt>
<dd>This is a badge given to whomever primarily reaches out from Snyk to let us know about security issues.</dd>
</dl>
================================================
FILE: docs/CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to block temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team by submitting a PR with changes to the [AUTHORS](/authors) page (or emailing josh@8fold.com). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version [1.4][version].
[homepage]: https://www.contributor-covenant.org/
[version]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
================================================
FILE: docs/CONTRIBUTING.md
================================================
# Contributing to Marked
- [ ] Fork `markedjs/marked`.
- [ ] Clone the library locally using GitHub Desktop or the command line.
- [ ] Make sure you are on the `master` branch.
- [ ] Be sure to run `npm install` or `npm update`.
- [ ] Create a branch.
- [ ] Update code in `src` folder. (`lib` folder is for auto compiled code)
- [ ] Run `npm run test:all`, fix any broken things (for linting, you can run `npm run lint` to have the linter fix them for you).
- [ ] Run `npm run build:reset` to remove changes to compiled files.
- [ ] Submit a Pull Request.
<h2 id="design-principles">Design principles</h2>
Marked tends to favor following the SOLID set of software design and development principles; mainly the [single responsibility](https://en.wikipedia.org/wiki/Single_responsibility_principle) and [open/closed principles](https://en.wikipedia.org/wiki/Open/closed_principle):
- **Single responsibility:** Marked, and the components of Marked, have the single responsibility of converting Markdown strings into HTML.
- **Open/closed:** Marked favors giving developers the means to easily extend the library and its components over changing Marked's behavior through configuration options.
<h2 id="priorities">Priorities</h2>
We think we have our priorities sorted to build quality in.
The following table lists the ticket type labels we use when there is work to be done on the code either through an Issue or a PR; in priority order.
|Ticket type label |Description |
|:----------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|L0 - security |A security vulnerability within the Marked library is discovered. |
|L1 - broken |Valid usage results in incorrect output compared to [supported specifications](/#specifications) OR causes marked to crash AND there is no known workaround for the issue. |
|L2 - annoying |Similar to L1 - broken only there is a known workaround available for the issue. |
|RR - refactor and re-engineer |Results in an improvement to developers using Marked (improved readability) or end-users (faster performance) or both. |
|NFS - new feature (spec related) |A capability Marked does not currently provide but is in one of the [supported specifications](/#specifications) |
|NFU - new feature (user requested) |A capability Marked does not currently provide but has been requested by users of Marked. |
|NFE - new feature (should be an extension) |A capability Marked does not currently provide and is not part of a spec. |
<h2 id="test-early-often-and-everything">Test early, often, and everything</h2>
We try to write test cases to validate output (writing tests based on the [supported specifications](/#specifications)) and minimize regression (writing tests for issues fixed). Therefore, if you would like to contribute, some things you should know regarding the test harness.
|Location |Description |
|:---------------------|:--------------------------------------------------------------------------------------------------------------|
|/test/specs/commonmark|Tests for [CommonMark](https://spec.commonmark.org/current/) compliance |
|/test/specs/gfm |Tests for [GFM](https://github.github.com/gfm/) compliance |
|/test/specs/new |Tests not related to the original `markdown.pl`. |
|/test/specs/original |Tests validating against the original `markdown.pl`. |
|/test/specs/redos |Tests for [ReDOS](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS) vulnerabilities|
If your test uses features or options, assuming `gfm` is set to `false`, for example, you can add [front-matter](https://www.npmjs.com/package/front-matter) to the top of
your `.md` file
``` yml
---
gfm: false
---
```
## Submitting PRs and Issues
Marked provides templates for submitting both pull requests and issues. When you begin creating a new PR or issue, you will see instructions on using the template.
The PR templates include checklists for both the submitter and the reviewer, which, in most cases, will not be the same person.
## Scripts
When it comes to NPM commands, we try to use the native scripts provided by the NPM framework.
To run the tests:
``` bash
npm test
```
To test whether you are using the standard syntax rules for the project:
```bash
npm run test:lint
```
To see time comparisons between Marked and other popular Markdown libraries:
```bash
npm run bench
```
To see the compiled rules from `src/rules.js`:
```bash
npm run rules
```
You can specify one or more `rule path`s to only show certain rules:
```bash
npm run rules -- block.gfm.item inline.pedantic.br
{
block: {
gfm: {
item: /^( *)((?:[*+-]|\\d{1,9}\\.)) ?[^\\n]*(?:\\n(?!\\1(?:[*+-]|\\d{1,9}\\.) ?)[^\\n]*)*/gm
}
},
inline: {
pedantic: {
br: /^( {2,}|\\\\)\\n(?!\\s*$)/
}
}
}
```
To check for (and fix) standardized syntax (lint):
```bash
npm run lint
```
To build your own es5, esm, and minified versions of Marked:
```bash
npm run build
```
================================================
FILE: docs/INDEX.md
================================================
Marked is
1. built for speed.<sup>*</sup>
2. a low-level markdown compiler for parsing markdown without caching or blocking for long periods of time.<sup>**</sup>
3. light-weight while implementing all markdown features from the supported flavors & specifications.<sup>***</sup>
4. available as a command line interface (CLI) and running in client- or server-side JavaScript projects.
<p><small><sup>*</sup> Still working on metrics for comparative analysis and definition.</small><br>
<small><sup>**</sup> As few dependencies as possible.</small><br>
<small><sup>***</sup> Strict compliance could result in slower processing when running comparative benchmarking.</small></p>
<h2 id="demo">Demo</h2>
Checkout the [demo page](./demo/) to see marked in action ⛹️
These documentation pages are also rendered using marked 💯
<h2 id="installation">Installation</h2>
**CLI:** `npm install -g marked`
**In-browser:**
```
npm install marked
```
<h2 id="usage">Usage</h2>
### Warning: 🚨 Marked does not [sanitize](/using_advanced#options) the output HTML. If you are processing potentially unsafe strings, it's important to filter for possible XSS attacks. Some filtering options include [DOMPurify](https://github.com/cure53/DOMPurify) (recommended), [js-xss](https://github.com/leizongmin/js-xss), [sanitize-html](https://github.com/apostrophecms/sanitize-html) and [insane](https://github.com/bevacqua/insane) on the *output* HTML! 🚨
```
DOMPurify.sanitize(marked.parse(`<img src="x" onerror="alert('not happening')">`));
```
**⚠️ Input: special ZERO WIDTH unicode characters (for example `\uFEFF`) might interfere with parsing. Some text editors add them at the start of the file (see: [#2139](https://github.com/markedjs/marked/issues/2139)).**
```js
// remove the most common zerowidth characters from the start of the file
marked.parse(
contents.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"")
)
```
**CLI**
``` bash
# Example with stdin input
$ marked -o hello.html
hello world
^D
$ cat hello.html
<p>hello world</p>
```
``` bash
# Example with string input
$ marked -s "*hello world*"
<p><em>hello world</em></p>
```
```bash
# Example with file input
echo "**bold text example**" > readme.md
$ marked -i readme.md -o readme.html
$ cat readme.html
<p><strong>bold text example</strong></p>
```
```bash
# Print all options
$ marked --help
```
*CLI Config*
A config file can be used to configure the marked cli.
If it is a `.json` file it should be a JSON object that will be passed to marked as options.
If `.js` is used it should have a default export of a marked options object or a function that takes `marked` as a parameter.
It can use the `marked` parameter to install extensions using `marked.use`.
By default the marked cli will look for a config file in your home directory in the following order.
- `~/.marked.json`
- `~/.marked.js`
- `~/.marked/index.js`
```bash
# Example with custom config
echo '{ "breaks": true }' > config.json
$ marked -s 'line1\nline2' -c config.json
<p>line1<br>line2</p>
```
**Browser**
```html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Marked in the browser</title>
</head>
<body>
<div id="content"></div>
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
<script>
document.getElementById('content').innerHTML =
marked.parse('# Marked in browser\n\nRendered by **marked**.');
</script>
</body>
</html>
```
or import esm module
```html
<script type="module">
import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
document.getElementById('content').innerHTML =
marked.parse('# Marked in the browser\n\nRendered by **marked**.');
</script>
```
**Node.js**
```js
import { marked } from 'marked';
// or const { marked } = require('marked');
const html = marked.parse('# Marked in Node.js\n\nRendered by **marked**.');
```
Marked offers [advanced configurations](/using_advanced) and [extensibility](/using_pro) as well.
<h2 id="specifications">Supported Markdown specifications</h2>
We actively support the features of the following [Markdown flavors](https://github.com/commonmark/CommonMark/wiki/Markdown-Flavors).
<!--{{test-results-table}}-->
By supporting the above Markdown flavors, it's possible that Marked can help you use other flavors as well; however, these are not actively supported by the community.
<h2 id="tools">List of Tools Using Marked</h2>
We actively support the usability of Marked in super-fast markdown transformation, some of Tools using `Marked` for single-page creations are
| Tools | Description |
| :----------------------------------------------------------------- | :------------------------------------------------------------------------ |
| [zero-md](https://zerodevx.github.io/zero-md/) | A native markdown-to-html web component to load and display an external MD file.It uses Marked for super-fast markdown transformation. |
| [texme](https://github.com/susam/texme) | TeXMe is a lightweight JavaScript utility to create self-rendering Markdown + LaTeX documents. |
| [StrapDown.js](https://naereen.github.io/StrapDown.js/) | StrapDown.js is an awesome on-the-fly Markdown to HTML text processor. |
| [raito](https://raito.arnaud.at/) | Mini Markdown Wiki/CMS in 8kb of JavaScript. |
| [Homebrewery](https://homebrewery.naturalcrit.com/) | The Homebrewery is a tool for making authentic looking D&D content using Markdown. It is distributed under the terms of the MIT. |
| [marked_reader](https://github.com/CNOCTAVE/marked_reader) | marked_reader is an open source Markdown reader packed by Electron. |
<h2 id="security">Security</h2>
The only completely secure system is the one that doesn't exist in the first place. Having said that, we take the security of Marked very seriously.
Therefore, please disclose potential security issues by email to the project [committers](/authors) as well as the [listed owners within NPM](https://docs.npmjs.com/cli/owner). We will provide an initial assessment of security reports within 48 hours and should apply patches within 2 weeks (also, feel free to contribute a fix for the issue).
================================================
FILE: docs/PUBLISHING.md
================================================
# Releasing Marked
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/).
## Overall strategy
**Master is always shippable:** We try to merge PRs in such a way that `master` is the only branch to really be concerned about *and* `master` can always be released. This allows smoother flow between new features, bug fixes, and so on.
## Versioning
We follow [semantic versioning](https://semver.org) where the following sequence is true `[major].[minor].[patch]`:
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.
2. **Minor:** There is at least one new feature added to the public API.
3. **Patch:** Changes that move Marked closer to spec compliance or change a public API that does not break backwards compatibility.
================================================
FILE: docs/USING_ADVANCED.md
================================================
<h2 id="instance">Marked instance</h2>
By default, Marked stores options and extensions in the global scope. That means changing the options in one script will also change the options in another script since they share the same instance.
If you don't want to mutate global scope, you can create a new instance of Marked to ensure options and extensions are locally scoped.
```js
import { Marked } from 'marked';
const marked = new Marked([options, extension, ...]);
```
|Argument |Type |Notes |
|:--------|:-------|:----------------------------------------------------------------------|
| options |`object`|The same arguments that can be passed to [`marked.use`](/using_pro#use)|
Be careful: marked.use(...) should not be used in a loop or function. It should only be used directly after new Marked is created or marked is imported.
## The `parse` function
```js
import { marked } from 'marked';
marked.parse(markdownString [,options])
```
|Argument |Type |Notes |
|:-----------------------------|:-------|:---------------------------------------------------------------|
|markdownString |`string`|String of markdown source to be compiled. |
|<a href="#options">options</a>|`object`|Hash of options. Can also use `marked.use` to set global options|
### Alternative using reference
```js
// Create reference instance
import { marked } from 'marked';
// Set options
marked.use({
async: true,
pedantic: false,
gfm: true,
});
// Compile
console.log(marked.parse(markdownString));
```
<h2 id="options">Options</h2>
|Member |Type |Default |Since |Notes |
|:-----------|:---------|:--------|:--------|:-------------|
|async |`boolean` |`false` |4.1.0 |If true, `walkTokens` functions can be async and `marked.parse` will return a promise that resolves when all walk tokens functions resolve.|
|breaks |`boolean` |`false` |v0.2.7 |If true, add `<br>` on a single line break (copies GitHub behavior on comments, but not on rendered markdown files). Requires `gfm` be `true`.|
|gfm |`boolean` |`true` |v0.2.1 |If true, use approved [GitHub Flavored Markdown (GFM) specification](https://github.github.com/gfm/).|
|pedantic |`boolean` |`false` |v0.2.1 |If true, conform to the original `markdown.pl` as much as possible. Don't fix original markdown bugs or behavior. Turns off and overrides `gfm`.|
|renderer |`object` |`new Renderer()`|v0.3.0|An object containing functions to render tokens to HTML. See [extensibility](/using_pro) for more details.|
|silent |`boolean` |`false` |v0.2.7 |If true, the parser does not throw any exception or log any warning. Any error will be returned as a string.|
|tokenizer |`object` |`new Tokenizer()`|v1.0.0|An object containing functions to create tokens from markdown. See [extensibility](/using_pro) for more details.|
|walkTokens |`function` |`null`|v1.1.0|A function which is called for every token. See [extensibility](/using_pro) for more details.|
## Old Options
|Member |Type |Default |Since |Notes |
|:-----------|:---------|:--------|:--------|:-------------|
|smartLists (**removed**)| `boolean` | `false` |v0.2.8 | Removed in v3.0.0. |
|baseUrl (**removed**)|`string` |`null` |v0.3.9 |Removed in v8.0.0 use [`marked-base-url`](https://www.npmjs.com/package/marked-base-url) to prefix url for any relative link. |
|headerIds (**removed**)|`boolean` |`true` |v0.4.0 |Removed in v8.0.0 use [`marked-gfm-heading-id`](https://www.npmjs.com/package/marked-gfm-heading-id) to include an `id` attribute when emitting headings (h1, h2, h3, etc).|
|headerPrefix (**removed**)|`string` |`''` |v0.3.0 |Removed in v8.0.0 use [`marked-gfm-heading-id`](https://www.npmjs.com/package/marked-gfm-heading-id) to add a string to prefix the `id` attribute when emitting headings (h1, h2, h3, etc).|
|highlight (**removed**)|`function`|`null` |v0.3.0 |Removed in v8.0.0 use [`marked-highlight`](https://www.npmjs.com/package/marked-highlight) to add highlighting to code blocks. |
|langPrefix (**removed**)|`string` |`'language-'`|v0.3.0|Removed in v8.0.0 use [`marked-highlight`](https://www.npmjs.com/package/marked-highlight) to prefix the className in a `<code>` block. Useful for syntax highlighting.|
|mangle (**removed**)|`boolean` |`true` |v0.3.4 |Removed in v8.0.0 use [`marked-mangle`](https://www.npmjs.com/package/marked-mangle) to mangle email addresses.|
|sanitize (**removed**)|`boolean` |`false` |v0.2.1 |Removed in v8.0.0 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! |
|sanitizer (**removed**)|`function`|`null` |v0.3.4 |Removed in v8.0.0 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!|
|smartypants (**removed**)|`boolean` |`false` |v0.2.9 |Removed in v8.0.0 use [`marked-smartypants`](https://www.npmjs.com/package/marked-smartypants) to use "smart" typographic punctuation for things like quotes and dashes.|
|xhtml (**removed**)|`boolean` |`false` |v0.3.2 |Removed in v8.0.0 use [`marked-xhtml`](https://www.npmjs.com/package/marked-xhtml) to emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.|
<h2 id="extensions">Known Extensions</h2>
Marked can be extended using [custom extensions](/using_pro#extensions). This is a list of extensions that can be used with `marked.use(extension)`.
<!-- Keep this list ordered alphabetically by name -->
|Name|Package Name|Description|
|:---|:-----------|:----------|
|[ABCjs](https://www.npmjs.com/package/marked-abc)|[`abcjs`](https://www.npmjs.com/package/marked-abc)|[ABCjs](https://www.abcjs.net/) sheet music rendering|
|[Admonition](https://www.npmjs.com/package/marked-admonition-extension)|[`marked-admonition-extension`](https://www.npmjs.com/package/marked-admonition-extension)| Admonition extension |
|[Alert](https://github.com/bent10/marked-extensions/tree/main/packages/alert)|[`marked-alert`](https://www.npmjs.com/package/marked-alert)|Enables [GFM alerts](https://github.com/orgs/community/discussions/16925)|
|[Base URL](https://github.com/markedjs/marked-base-url)|[`marked-base-url`](https://www.npmjs.com/package/marked-base-url)|Prefix relative urls with a base URL|
|[Bidi](https://github.com/markedjs/marked-bidi)|[`marked-bidi`](https://www.npmjs.com/package/marked-bidi)|Add Bidirectional text support to the HTML|
|[CJK Breaks](https://github.com/chirsz-ever/marked-cjk-breaks)|[`marked-cjk-breaks`](https://www.npmjs.com/package/marked-cjk-breaks)|Suppress soft linebreaks between east asian characters|
|[Code Format](https://github.com/bent10/marked-extensions/tree/main/packages/code-format)|[`marked-code-format`](https://www.npmjs.com/package/marked-code-format)|Formatting code blocks using Prettier|
|[Code JSX Renderer](https://github.com/bent10/marked-extensions/tree/main/packages/code-jsx-renderer)|[`marked-code-jsx-renderer`](https://www.npmjs.com/package/marked-code-jsx-renderer)|Render JSX code blocks using a custom renderer and components|
|[Code Preview](https://github.com/bent10/marked-extensions/tree/main/packages/code-preview)|[`marked-code-preview`](https://www.npmjs.com/package/marked-code-preview)|Transform code blocks into code previews|
|[Custom Heading ID](https://github.com/markedjs/marked-custom-heading-id)|[`marked-custom-heading-id`](https://www.npmjs.com/package/marked-custom-heading-id)|Specify a custom heading id in headings with the [Markdown Extended Syntax](https://www.markdownguide.org/extended-syntax/#heading-ids) `# heading {#custom-id}`|
|[Directive](https://github.com/bent10/marked-extensions/tree/main/packages/directive)|[`marked-directive`](https://www.npmjs.com/package/marked-directive)|Supports [directives syntax](https://talk.commonmark.org/t/generic-directives-plugins-syntax/444)|
|[Emoji](https://github.com/UziTech/marked-emoji)|[`marked-emoji`](https://www.npmjs.com/package/marked-emoji)|Add emoji support like on GitHub|
|[Extended Tables](https://github.com/calculuschild/marked-extended-tables)|[`marked-extended-tables`](https://www.npmjs.com/package/marked-extended-tables)|Extends the standard Github-Flavored tables to support advanced features: Column Spanning, Row Spanning, Multi-row headers|
|[Footnote](https://github.com/bent10/marked-extensions/tree/main/packages/footnote)|[`marked-footnote`](https://www.npmjs.com/package/marked-footnote)|Enables [GFM footnotes](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#footnotes)|
|[GFM Heading ID](https://github.com/markedjs/marked-gfm-heading-id)|[`marked-gfm-heading-id`](https://www.npmjs.com/package/marked-gfm-heading-id)|Use [`github-slugger`](https://github.com/Flet/github-slugger) to create the heading IDs and allow a custom prefix|
|[Highlight](https://github.com/markedjs/marked-highlight)|[`marked-highlight`](https://www.npmjs.com/package/marked-highlight)|Highlight code blocks|
|[HTML Renderer](https://github.com/UziTech/marked-html-renderer)|[`marked-html-renderer`](https://www.npmjs.com/package/marked-html-renderer)|Output HTML Elements instead of a string|
|[Jira Renderer](https://github.com/mrmarble/marked-jira)|[`marked-jira`](https://www.npmjs.com/package/marked-jira)|Output Jira compatible format|
|[Katex Code](https://github.com/UziTech/marked-katex-extension)|[`marked-katex-extension`](https://www.npmjs.com/package/marked-katex-extension)|Render [katex](https://katex.org/) code|
|[LinkifyIt](https://github.com/UziTech/marked-linkify-it)|[`marked-linkify-it`](https://www.npmjs.com/package/marked-linkify-it)|Use [linkify-it](https://github.com/markdown-it/linkify-it) for urls|
|[Mangle](https://github.com/markedjs/marked-mangle)|[`marked-mangle`](https://www.npmjs.com/package/marked-mangle)|Mangle mailto links with HTML character references|
|[Marked Responsive Images](https://github.com/ELowry/MarkedResponsiveImages)|[`marked-responsive-images`](https://www.npmjs.com/package/marked-responsive-images)|Generate responsive (`srcset`) images based on structured filenames|
|[Misskey-flavored Markdown](https://akkoma.dev/sfr/marked-mfm)|[`marked-mfm`](https://www.npmjs.com/package/marked-mfm)|Custom extension for [Misskey-flavored Markdown](https://github.com/misskey-dev/mfm.js/blob/develop/docs/syntax.md)|
|[More Lists](https://github.com/jasny/marked-more-lists)|[`marked-more-lists`](https://www.npmjs.com/package/marked-more-lists)|Support for alphabetical and roman numeral ordered lists|
|[Plaintify](https://github.com/bent10/marked-extensions/tree/main/packages/plaintify)|[`marked-plaintify`](https://www.npmjs.com/package/marked-plaintify)|Converts Markdown to Plaintext|
|[Shiki](https://github.com/bent10/marked-extensions/tree/main/packages/shiki)|[`marked-shiki`](https://www.npmjs.com/package/marked-shiki)|Integrating [Shiki](https://shiki.style/) syntax highlighting|
|[Sequential Hooks](https://github.com/bent10/marked-extensions/tree/main/packages/sequential-hooks)|[`marked-sequential-hooks`](https://www.npmjs.com/package/marked-sequential-hooks)|Enables the sequential preprocessing and post-processing within [sequential hooks](https://github.com/bent10/marked-extensions#sequential-hooks)|
|[Smartypants](https://github.com/markedjs/marked-smartypants)|[`marked-smartypants`](https://www.npmjs.com/package/marked-smartypants)|Use [smartypants](https://www.npmjs.com/package/smartypants) to use "smart" typographic punctuation for things like quotes and dashes|
|[Smartypants lite](https://github.com/calculuschild/marked-smartypants-lite)|[`marked-smartypants-lite`](https://www.npmjs.com/package/marked-smartypants-lite)|A faster lighter version of marked-smartypants that doesn't use any external dependencies to create "smart" typographic punctuation for things like quotes and dashes|
|[Token Position](https://github.com/UziTech/marked-token-position)|[`marked-token-position`](https://www.npmjs.com/package/marked-token-position)|Adds a `position` field to each token with `start` and `end` properties containing `line`, `column`, and `offset`|
|[Typograf](https://github.com/laidrivm/marked-typograf)|[`marked-typograf`](https://www.npmjs.com/package/marked-typograf)|Use [typograf](https://www.npmjs.com/package/typograf) as a more powerful and extendable alternative to Smartypants for creating “smart” typographic punctuation, such as quotes and dashes|
|[XHTML](https://github.com/markedjs/marked-xhtml)|[`marked-xhtml`](https://www.npmjs.com/package/marked-xhtml)|Emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML|
<h2 id="user-examples">User Examples</h2>
<details>
<summary>Marked can render on-page content as markdown in the browser.</summary>
```html
<!DOCTYPE html>
<html>
<head>
<!-- Suggested stylesheet -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.8.1/github-markdown.min.css"
crossorigin="anonymous" referrerpolicy="no-referrer" />
<title>Marked for the full page</title>
</head>
<body>
<textarea id="markdown-source" style="display: none;">
# Title
Lots of text using **markdown syntax.**
</textarea>
<div id="content" class="markdown-body"></div>
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
<script>
const source = document.getElementById('markdown-source').value;
// Parse the markdown and render it into the content div.
document.getElementById('content').innerHTML = marked.parse(source);
</script>
</body>
</html>
```
</details>
<h2 id="inline">Inline Markdown</h2>
You can parse inline markdown by running markdown through `marked.parseInline`.
```js
const blockHtml = marked.parse('**strong** _em_');
console.log(blockHtml); // '<p><strong>strong</strong> <em>em</em></p>'
const inlineHtml = marked.parseInline('**strong** _em_');
console.log(inlineHtml); // '<strong>strong</strong> <em>em</em>'
```
<h2 id="highlight">Highlighting</h2>
Use [`marked-highlight`](https://www.npmjs.com/package/marked-highlight) to highlight code blocks.
<h2 id="workers">Workers</h2>
To prevent ReDoS attacks you can run marked on a worker and terminate it when parsing takes longer than usual.
Marked can be run in a [worker thread](https://nodejs.org/api/worker_threads.html) on a node server, or a [web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) in a browser.
### Node Worker Thread
```js
// markedWorker.js
import { marked } from 'marked';
import { parentPort } from 'worker_threads';
parentPort.on('message', (markdownString) => {
parentPort.postMessage(marked.parse(markdownString));
});
```
```js
// index.js
import { Worker } from 'worker_threads';
const markedWorker = new Worker('./markedWorker.js');
const markedTimeout = setTimeout(() => {
markedWorker.terminate();
throw new Error('Marked took too long!');
}, timeoutLimit);
markedWorker.on('message', (html) => {
clearTimeout(markedTimeout);
console.log(html);
markedWorker.terminate();
});
markedWorker.postMessage(markdownString);
```
### Web Worker
> **NOTE**: Web Workers send the payload from `postMessage` in an object with the payload in a `.data` property
```js
// markedWorker.js
importScripts('path/to/marked.umd.js');
onmessage = (e) => {
const markdownString = e.data
postMessage(marked.parse(markdownString));
};
```
```js
// script.js
const markedWorker = new Worker('./markedWorker.js');
const markedTimeout = setTimeout(() => {
markedWorker.terminate();
throw new Error('Marked took too long!');
}, timeoutLimit);
markedWorker.onmessage = (e) => {
clearTimeout(markedTimeout);
const html = e.data;
console.log(html);
markedWorker.terminate();
};
markedWorker.postMessage(markdownString);
```
<h2 id="cli-extensions">CLI Extensions</h2>
You can use extensions in the CLI by creating a new CLI that imports marked and the marked binary.
```js
// file: myMarked
#!/usr/bin/node
import { marked } from 'marked';
import customHeadingId from 'marked-custom-heading-id';
marked.use(customHeadingId());
import 'marked/bin/marked';
```
```sh
$ ./myMarked -s "# heading {#custom-id}"
<h1 id="custom-id">heading</h1>
```
================================================
FILE: docs/USING_PRO.md
================================================
## Extending Marked
To champion the single-responsibility and open/closed principles, we have tried to make it relatively painless to extend Marked. If you are looking to add custom functionality, this is the place to start.
<h2 id="terminology">Terminology Note</h2>
Before diving in, it's important to understand the terminology used in this documentation:
| Term | TypeScript Type | Description |
|------|----------------|-------------|
| **Marked Extension** | `MarkedExtension` | The configuration object passed to `marked.use()`. Can contain options, hooks, renderer overrides, tokenizer overrides, and custom extensions. |
| **Custom Extension** | `TokenizerAndRendererExtension` | Objects within the `extensions` array that define custom tokenizers and renderers for new syntax. |
In other words, a **Marked Extension** is the top-level plugin configuration, while **Custom Extensions** are the individual tokenizer/renderer definitions for custom syntax within that configuration.
```js
// Marked Extension (MarkedExtension)
marked.use({
gfm: true,
breaks: false,
renderer: { /* renderer overrides */ },
tokenizer: { /* tokenizer overrides */ },
// Custom Extensions (TokenizerAndRendererExtension[])
extensions: [
{ name: 'myCustomSyntax', level: 'block', tokenizer: fn, renderer: fn }
]
});
```
<h2 id="use">marked.use()</h2>
`marked.use(extension)` is the recommended way to extend Marked. The `extension` object can contain any [option](/using_advanced#options) available in Marked:
```js
import { marked } from 'marked';
marked.use({
pedantic: false,
gfm: true,
breaks: false
});
```
You can also supply multiple `extension` objects at once.
```js
marked.use(myExtension, extension2, extension3);
\\ EQUIVALENT TO:
marked.use(myExtension);
marked.use(extension2);
marked.use(extension3);
```
All options will overwrite those previously set, except for the following options which will be merged with the existing framework and can be used to change or extend the functionality of Marked: `renderer`, `tokenizer`, `hooks`, `walkTokens`, and `extensions`.
* The `renderer`, `tokenizer`, and `hooks` options are objects with functions that will be merged into the built-in `renderer` and `tokenizer` respectively.
* The `walkTokens` option is a function that will be called to post-process every token before rendering.
* The `extensions` option is an array of objects that can contain additional custom `renderer` and `tokenizer` steps that will execute before any of the default parsing logic occurs.
Importantly, ensure that the extensions are only added to `marked` once (ie in the global scope of a regular JavaScript or TypeScript module). If they are added in a function that is called repeatedly, or in the JS for an HTML component in a library such as Svelte, your extensions will be added repeatedly, eventually causing a recursion error. If you cannot prevent the code from being run repeatedly, you should create a [Marked instance](/using_advanced#instance) so that your extensions are stored independently from the global instance Marked provides.
***
<h2>The Marked Pipeline</h2>
Before building your custom extensions, it is important to understand the components that Marked uses to translate from Markdown to HTML:
1) The user supplies Marked with an input string to be translated.
2) The `lexer` feeds segments of the input text string into each `tokenizer`, and from their output, generates a series of tokens in a nested tree structure.
3) Each `tokenizer` receives a segment of Markdown text and, if it matches a particular pattern, generates a token object containing any relevant information.
4) The `walkTokens` function will traverse every token in the tree and perform any final adjustments to the token contents.
4) The `parser` traverses the token tree and feeds each token into the appropriate `renderer`, and concatenates their outputs into the final HTML result.
5) Each `renderer` receives a token and manipulates its contents to generate a segment of HTML.
Marked provides methods for directly overriding the `renderer` and `tokenizer` for any existing token type, as well as inserting additional custom `renderer` and `tokenizer` functions to handle entirely custom syntax. For example, using `marked.use({renderer})` would modify a renderer, whereas `marked.use({extensions: [{renderer}]})` would add a new renderer. See the [custom extensions example](#custom-extensions-example) for insight on how to execute this.
***
<h2 id="renderer">The Renderer : <code>renderer</code></h2>
The renderer defines the HTML output of a given token. If you supply a `renderer` in the options object passed to `marked.use()`, any functions in the object will override the default handling of that token type.
Calling `marked.use()` to override the same function multiple times will give priority to the version that was assigned *last*. Overriding functions can return `false` to fall back to the previous override in the sequence, or resume default behavior if all overrides return `false`. Returning any other value (including nothing) will prevent fallback behavior.
**Example:** Overriding output of the default `heading` token by adding an embedded anchor tag like on GitHub.
```js
// Create reference instance
import { marked } from 'marked';
// Override function
const renderer = {
heading({ tokens, depth }) {
const text = this.parser.parseInline(tokens);
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return `
<h${depth}>
<a name="${escapedText}" class="anchor" href="#${escapedText}">
<span class="header-link"></span>
</a>
${text}
</h${depth}>`;
}
};
marked.use({ renderer });
// Run marked
console.log(marked.parse('# heading+'));
```
**Output:**
```html
<h1>
<a name="heading-" class="anchor" href="#heading-">
<span class="header-link"></span>
</a>
heading+
</h1>
```
**Note:** Calling `marked.use()` in the following way will avoid overriding the `heading` token output but create a new `heading` renderer in the process.
```js
marked.use({
extensions: [{
name: 'heading',
renderer(token) {
return /* ... */
}
}]
})
```
### Block-level renderer methods
- <code>**space**(token: *Tokens.Space*): *string*</code>
- <code>**code**(token: *Tokens.Code*): *string*</code>
- <code>**blockquote**(token: *Tokens.Blockquote*): *string*</code>
- <code>**html**(token: *Tokens.HTML | Tokens.Tag*): *string*</code>
- <code>**heading**(token: *Tokens.Heading*): *string*</code>
- <code>**hr**(token: *Tokens.Hr*): *string*</code>
- <code>**list**(token: *Tokens.List*): *string*</code>
- <code>**listitem**(token: *Tokens.ListItem*): *string*</code>
- <code>**checkbox**(token: *Tokens.Checkbox*): *string*</code>
- <code>**paragraph**(token: *Tokens.Paragraph*): *string*</code>
- <code>**table**(token: *Tokens.Table*): *string*</code>
- <code>**tablerow**(token: *Tokens.TableRow*): *string*</code>
- <code>**tablecell**(token: *Tokens.TableCell*): *string*</code>
### Inline-level renderer methods
- <code>**strong**(token: *Tokens.Strong*): *string*</code>
- <code>**em**(token: *Tokens.Em*): *string*</code>
- <code>**codespan**(token: *Tokens.Codespan*): *string*</code>
- <code>**br**(token: *Tokens.Br*): *string*</code>
- <code>**del**(token: *Tokens.Del*): *string*</code>
- <code>**link**(token: *Tokens.Link*): *string*</code>
- <code>**image**(token: *Tokens.Image*): *string*</code>
- <code>**text**(token: *Tokens.Text | Tokens.Escape | Tokens.Tag*): *string*</code>
The Tokens.* properties can be found [here](https://github.com/markedjs/marked/blob/master/src/Tokens.ts).
***
<h2 id="tokenizer">The Tokenizer : <code>tokenizer</code></h2>
The tokenizer defines how to turn markdown text into tokens. If you supply a `tokenizer` object to the Marked options, it will be merged with the built-in tokenizer and any functions inside will override the default handling of that token type.
Calling `marked.use()` to override the same function multiple times will give priority to the version that was assigned *last*. Overriding functions can return `false` to fall back to the previous override in the sequence, or resume default behavior if all overrides return `false`. Returning any other value (including nothing) will prevent fallback behavior.
**Example:** Overriding default `codespan` tokenizer to include LaTeX.
```js
// Create reference instance
import { marked } from 'marked';
// Override function
const tokenizer = {
codespan(src) {
const match = src.match(/^\$+([^\$\n]+?)\$+/);
if (match) {
return {
type: 'codespan',
raw: match[0],
text: match[1].trim()
};
}
// return false to use original codespan tokenizer
return false;
}
};
marked.use({ tokenizer });
// Run marked
console.log(marked.parse('$ latex code $\n\n` other code `'));
```
**Output:**
```html
<p><code>latex code</code></p>
<p><code>other code</code></p>
```
**NOTE**: This does not fully support latex, see issue [#1948](https://github.com/markedjs/marked/issues/1948).
### Block level tokenizer methods
- <code>**space**(src: *string*): *Tokens.Space*</code>
- <code>**code**(src: *string*): *Tokens.Code*</code>
- <code>**fences**(src: *string*): *Tokens.Code*</code>
- <code>**heading**(src: *string*): *Tokens.Heading*</code>
- <code>**hr**(src: *string*): *Tokens.Hr*</code>
- <code>**blockquote**(src: *string*): *Tokens.Blockquote*</code>
- <code>**list**(src: *string*): *Tokens.List*</code>
- <code>**html**(src: *string*): *Tokens.HTML*</code>
- <code>**def**(src: *string*): *Tokens.Def*</code>
- <code>**table**(src: *string*): *Tokens.Table*</code>
- <code>**lheading**(src: *string*): *Tokens.Heading*</code>
- <code>**paragraph**(src: *string*): *Tokens.Paragraph*</code>
- <code>**text**(src: *string*): *Tokens.Text*</code>
### Inline level tokenizer methods
- <code>**escape**(src: *string*): *Tokens.Escape*</code>
- <code>**tag**(src: *string*): *Tokens.Tag*</code>
- <code>**link**(src: *string*): *Tokens.Link | Tokens.Image*</code>
- <code>**reflink**(src: *string*, links: *object*): *Tokens.Link | Tokens.Image | Tokens.Text*</code>
- <code>**emStrong**(src: *string*, maskedSrc: *string*, prevChar: *string*): *Tokens.Em | Tokens.Strong*</code>
- <code>**codespan**(src: *string*): *Tokens.Codespan*</code>
- <code>**br**(src: *string*): *Tokens.Br*</code>
- <code>**del**(src: *string*): *Tokens.Del*</code>
- <code>**autolink**(src: *string*): *Tokens.Link*</code>
- <code>**url**(src: *string*): *Tokens.Link*</code>
- <code>**inlineText**(src: *string*): *Tokens.Text*</code>
The Tokens.* properties can be found [here](https://github.com/markedjs/marked/blob/master/src/Tokens.ts).
***
<h2 id="walk-tokens">Walk Tokens : <code>walkTokens</code></h2>
The walkTokens function gets called with every token. Child tokens are called before moving on to sibling tokens. Each token is passed by reference so updates are persisted when passed to the parser. When [`async`](#async) mode is enabled, the return value is awaited. Otherwise the return value is ignored.
`marked.use()` can be called multiple times with different `walkTokens` functions. Each function will be called in order, starting with the function that was assigned *last*.
**Example:** Overriding heading tokens to start at h2.
```js
import { marked } from 'marked';
// Override function
const walkTokens = (token) => {
if (token.type === 'heading') {
token.depth += 1;
}
};
marked.use({ walkTokens });
// Run marked
console.log(marked.parse('# heading 2\n\n## heading 3'));
```
**Output:**
```html
<h2 id="heading-2">heading 2</h2>
<h3 id="heading-3">heading 3</h3>
```
***
<h2 id="hooks">Hooks : <code>hooks</code></h2>
Hooks are methods that hook into some part of marked. The following hooks are available:
| signature | description |
|-----------|-------------|
| `preprocess(markdown: string): string` | Process markdown before sending it to marked. |
| `postprocess(html: string): string` | Process html after marked has finished parsing. |
| `processAllTokens(tokens: Token[]): Token[]` | Process all tokens before walk tokens. |
| `emStrongMask(src: string): string` | Mask part of the content that should not be interpreted as Markdown em/strong delimiters. |
| `provideLexer(): (src: string, options?: MarkedOptions) => Token[]` | Provide function to tokenize markdown. |
| `provideParser(): (tokens: Token[], options?: MarkedOptions) => string` | Provide function to parse tokens. |
`marked.use()` can be called multiple times with different `hooks` functions. Each function will be called in order, starting with the function that was assigned *last*.
**Example:** Set options based on [front-matter](https://www.npmjs.com/package/front-matter)
```js
import { marked } from 'marked';
import fm from 'front-matter';
// Override function
function preprocess(markdown) {
const { attributes, body } = fm(markdown);
for (const prop in attributes) {
if (prop in this.options) {
this.options[prop] = attributes[prop];
}
}
return body;
}
marked.use({ hooks: { preprocess } });
// Run marked
console.log(marked.parse(`
---
breaks: true
---
line1
line2
`.trim()));
```
**Output:**
```html
<p>line1<br>line2</p>
```
**Example:** Sanitize HTML with [isomorphic-dompurify](https://www.npmjs.com/package/isomorphic-dompurify)
```js
import { marked } from 'marked';
import DOMPurify from 'isomorphic-dompurify';
// Override function
function postprocess(html) {
return DOMPurify.sanitize(html);
}
marked.use({ hooks: { postprocess } });
// Run marked
console.log(marked.parse(`
<img src=x onerror=alert(1)//>
`));
```
**Output:**
```html
<img src="x">
```
**Example:** Save reflinks for chunked rendering
```js
import { marked, Lexer } from 'marked';
let refLinks = {};
// Override function
function processAllTokens(tokens) {
refLinks = tokens.links;
return tokens;
}
function provideLexer(src, options) {
return (src, options) => {
const lexer = new Lexer(options);
lexer.tokens.links = refLinks;
return this.block ? lexer.lex(src) : lexer.inlineTokens(src);
};
}
marked.use({ hooks: { processAllTokens, provideLexer } });
// Parse reflinks separately from markdown that uses them
marked.parse(`
[test]: http://example.com
`);
console.log(marked.parse(`
[test link][test]
`));
```
**Output:**
```html
<p><a href="http://example.com">test link</a></p>
```
**Example:** Mask underline characters inside Mathjax content delimited by `$`
```js
import { marked } from 'marked';
// Override function
function emStrongMask(src) {
return src.replace(/\$([^$]+)\$/g, (match) => `[${'a'.repeat(match.length - 2)}]`);
}
marked.use({ hooks: { emStrongMask } });
console.log(marked.parse(`_The formula is $a_ b=c_ d$._`));
```
**Output:**
```html
<p><em>The formula is $a_ b=c_ d$.</em></p>
```
***
<h2 id="extensions">Custom Extensions : <code>extensions</code></h2>
You may supply an `extensions` array to the `options` object. This array can contain any number of `extension` objects, using the following properties:
<dl>
<dt><code><strong>name</strong></code></dt>
<dd>A string used to identify the token that will be handled by this extension.
If the name matches an existing extension name, or an existing method in the tokenizer/renderer methods listed above, they will override the previously assigned behavior, with priority on the extension that was assigned **last**. An extension can return `false` to fall back to the previous behavior.</dd>
<dt><code><strong>level</strong></code></dt>
<dd>A string to determine when to run the extension tokenizer. Must be equal to 'block' or 'inline'.
A **block-level** extension will be handled before any of the block-level tokenizer methods listed above, and generally consists of 'container-type' text (paragraphs, tables, blockquotes, etc.).
An **inline-level** extension will be handled inside each block-level token, before any of the inline-level tokenizer methods listed above. These generally consist of 'style-type' text (italics, bold, etc.).</dd>
<dt><code><strong>start</strong>(<i>string</i> src)</code></dt>
<dd>A function that returns the index of the next potential start of the custom token.
The index can be the result of a <code>src.match().index</code>, or even a simple <code>src.indexOf()</code>. Marked will use this function to ensure that it does not skip over any text that should be part of the custom token.</dd>
<dt><code><strong>tokenizer</strong>(<i>string</i> src, <i>array</i> tokens)</code></dt>
<dd>A function that reads string of Markdown text and returns a generated token. The token pattern should be found at the beginning of the <code>src</code> string. Accordingly, if using a Regular Expression to detect a token, it should be anchored to the string start (`^`). The <code>tokens</code> parameter contains the array of tokens that have been generated by the lexer up to that point, and can be used to access the previous token, for instance.
The return value should be an object with the following parameters:
<dl>
<dt><code><strong>type</strong></code></dt>
<dd>A string that matches the <code>name</code> parameter of the extension.</dd>
<dt><code><strong>raw</strong></code></dt>
<dd>A string containing all of the text that this token consumes from the source.</dd>
<dt><code><strong>tokens</strong> [optional]</code></dt>
<dd>An array of child tokens that will be traversed by the <code>walkTokens</code> function by default.</dd>
</dl>
The returned token can also contain any other custom parameters of your choice that your custom `renderer` might need to access.
The tokenizer function has access to the lexer in the `this` object, which can be used if any internal section of the string needs to be parsed further, such as in handling any inline syntax on the text within a block token. The key functions that may be useful include:
<dl>
<dt><code><strong>this.lexer.blockTokens</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>This runs the block tokenizer functions (including any block-level extensions) on the provided text, and appends any resulting tokens onto the <code>tokens</code> array. The <code>tokens</code> array is also returned by the function. You might use this, for example, if your extension creates a "container"-type token (such as a blockquote) that can potentially include other block-level tokens inside.</dd>
<dt><code><strong>this.lexer.inline</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>Parsing of inline-level tokens only occurs after all block-level tokens have been generated. This function adds <code>text</code> and <code>tokens</code> to a queue to be processed using inline-level tokenizers (including any inline-level extensions) at that later step. Tokens will be generated using the provided <code>text</code>, and any resulting tokens will be appended to the <code>tokens</code> array. Note that this function does **NOT** return anything since the inline processing cannot happen until the block-level processing is complete.</dd>
<dt><code><strong>this.lexer.inlineTokens</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>Sometimes an inline-level token contains further nested inline tokens (such as a <pre><code>**strong**</code></pre> token inside of a <pre><code>### Heading</code></pre>). This runs the inline tokenizer functions (including any inline-level extensions) on the provided text, and appends any resulting tokens onto the <code>tokens</code> array. The <code>tokens</code> array is also returned by the function.</dd>
</dl>
</dd>
<dt><code><strong>renderer</strong>(<i>object</i> token)</code></dt>
<dd>A function that reads a token and returns the generated HTML output string.
The renderer function has access to the parser in the `this` object, which can be used if any part of the token needs needs to be parsed further, such as any child tokens. The key functions that may be useful include:
<dl>
<dt><code><strong>this.parser.parse</strong>(<i>array</i> tokens)</code></dt>
<dd>Runs the block renderer functions (including any extensions) on the provided array of tokens, and returns the resulting HTML string output. This is used to generate the HTML from any child block-level tokens, for example if your extension is a "container"-type token (such as a blockquote) that can potentially include other block-level tokens inside.</dd>
<dt><code><strong>this.parser.parseInline</strong>(<i>array</i> tokens)</code></dt>
<dd>Runs the inline renderer functions (including any extensions) on the provided array of tokens, and returns the resulting HTML string output. This is used to generate the HTML from any child inline-level tokens.</dd>
</dl>
</dd>
<dt><code><strong>childTokens</strong> [optional]</code></dt>
<dd>An array of strings that match the names of any token parameters that should be traversed by the <code>walkTokens</code> functions. For instance, if you want to use a second custom parameter to contain child tokens in addition to <code>tokens</code>, it could be listed here. If <code>childTokens</code> is provided, the <code>tokens</code> array will not be walked by default unless it is also included in the <code>childTokens</code> array.</dd>
</dl>
> Note: If you would like to release an extension as an npm package you may use the [Marked Extension Template](https://github.com/markedjs/marked-extension-template) which includes all of the things you need to get started. Feel free to create an issue in that [repo](https://github.com/markedjs/marked-extension-template) if you need help.
**Example:** <a name="custom-extensions-example"></a>Add a custom syntax to generate `<dl>` description lists.
``` js
const descriptionList = {
name: 'descriptionList',
level: 'block', // Is this a block-level or inline-level tokenizer?
start(src) { return src.match(/:[^:\n]/)?.index; }, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
const rule = /^(?::[^:\n]+:[^:\n]*(?:\n|$))+/; // Regex for the complete token, anchor to string start
const match = rule.exec(src);
if (match) {
const token = { // Token to generate
type: 'descriptionList', // Should match "name" above
raw: match[0], // Text to consume from the source
text: match[0].trim(), // Additional custom properties
tokens: [] // Array where child inline tokens will be generated
};
this.lexer.inline(token.text, token.tokens); // Queue this data to be processed for inline tokens
return token;
}
},
renderer(token) {
return `<dl>${this.parser.parseInline(token.tokens)}\n</dl>`; // parseInline to turn child tokens into HTML
}
};
const description = {
name: 'description',
level: 'inline', // Is this a block-level or inline-level tokenizer?
start(src) { return src.match(/:/)?.index; }, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
const rule = /^:([^:\n]+):([^:\n]*)(?:\n|$)/; // Regex for the complete token, anchor to string start
const match = rule.exec(src);
if (match) {
return { // Token to generate
type: 'description', // Should match "name" above
raw: match[0], // Text to consume from the source
dt: this.lexer.inlineTokens(match[1].trim()), // Additional custom properties, including
dd: this.lexer.inlineTokens(match[2].trim()) // any further-nested inline tokens
};
}
},
renderer(token) {
return `\n<dt>${this.parser.parseInline(token.dt)}</dt><dd>${this.parser.parseInline(token.dd)}</dd>`;
},
childTokens: ['dt', 'dd'], // Any child tokens to be visited by walkTokens
};
function walkTokens(token) { // Post-processing on the completed token tree
if (token.type === 'strong') {
token.text += ' walked';
token.tokens = this.Lexer.lexInline(token.text)
}
}
marked.use({ extensions: [descriptionList, description], walkTokens });
// EQUIVALENT TO:
marked.use({ extensions: [descriptionList] });
marked.use({ extensions: [description] });
marked.use({ walkTokens })
console.log(marked.parse('A Description List:\n'
+ ': Topic 1 : Description 1\n'
+ ': **Topic 2** : *Description 2*'));
```
**Output**
``` bash
<p>A Description List:</p>
<dl>
<dt>Topic 1</dt><dd>Description 1</dd>
<dt><strong>Topic 2 walked</strong></dt><dd><em>Description 2</em></dd>
</dl>
```
***
<h2 id="async">Async Marked : <code>async</code></h2>
Marked will return a promise if the `async` option is true. The `async` option will tell marked to await any `walkTokens` functions before parsing the tokens and returning an HTML string.
Simple Example:
```js
const walkTokens = async (token) => {
if (token.type === 'link') {
try {
await fetch(token.href);
} catch (ex) {
token.title = 'invalid';
}
}
};
marked.use({ walkTokens, async: true });
const markdown = `
[valid link](https://example.com)
[invalid link](https://invalidurl.com)
`;
const html = await marked.parse(markdown);
```
Custom Extension Example:
```js
const importUrl = {
extensions: [{
name: 'importUrl',
level: 'block',
start(src) { return src.indexOf('\n:'); },
tokenizer(src) {
const rule = /^:(https?:\/\/.+?):/;
const match = rule.exec(src);
if (match) {
return {
type: 'importUrl',
raw: match[0],
url: match[1],
html: '' // will be replaced in walkTokens
};
}
},
renderer(token) {
return token.html;
}
}],
async: true, // needed to tell marked to return a promise
async walkTokens(token) {
if (token.type === 'importUrl') {
const res = await fetch(token.url);
token.html = await res.text();
}
}
};
marked.use(importUrl);
const markdown = `
# example.com
:https://example.com:
`;
const html = await marked.parse(markdown);
```
<h2 id="lexer">The Lexer</h2>
The lexer takes a markdown string and calls the tokenizer functions.
<h2 id="parser">The Parser</h2>
The parser takes tokens as input and calls the renderer functions.
<h2 id="extend">Access to Lexer and Parser</h2>
You also have direct access to the lexer and parser if you so desire. The lexer and parser options are the same as passed to `marked.setOptions()` except they have to be full options objects, they don't get merged with the current or default options.
``` js
const tokens = marked.lexer(markdown, options);
console.log(marked.parser(tokens, options));
```
``` js
const lexer = new marked.Lexer(options);
const tokens = lexer.lex(markdown);
console.log(tokens);
console.log(lexer.tokenizer.rules.block); // block level rules used
console.log(lexer.tokenizer.rules.inline); // inline level rules used
console.log(marked.Lexer.rules.block); // all block level rules
console.log(marked.Lexer.rules.inline); // all inline level rules
```
Note that the lexer can be used in two different ways:
- `marked.lexer()`: this method tokenizes a string and returns its tokens. Subsequent calls to `lexer()` ignore any previous calls.
- `new marked.Lexer().lex()`: this instance tokenizes a string and returns its tokens along with any previous tokens. Subsequent calls to `lex()` accumulate tokens.
``` bash
$ node
> require('marked').lexer('> I am using marked.')
[
{
type: "blockquote",
raw: "> I am using marked.",
tokens: [
{
type: "paragraph",
raw: "I am using marked.",
text: "I am using marked.",
tokens: [
{
type: "text",
raw: "I am using marked.",
text: "I am using marked."
}
]
}
]
},
links: {}
]
```
The Lexer builds an array of tokens, which will be passed to the Parser.
The Parser processes each token in the token array:
``` js
import { marked } from 'marked';
const md = `
# heading
[link][1]
[1]: #heading "heading"
`;
const tokens = marked.lexer(md);
console.log(tokens);
const html = marked.parser(tokens);
console.log(html);
```
``` bash
[
{
type: "heading",
raw: " # heading\n\n",
depth: 1,
text: "heading",
tokens: [
{
type: "text",
raw: "heading",
text: "heading"
}
]
},
{
type: "paragraph",
raw: " [link][1]",
text: " [link][1]",
tokens: [
{
type: "text",
raw: " ",
text: " "
},
{
type: "link",
raw: "[link][1]",
text: "link",
href: "#heading",
title: "heading",
tokens: [
{
type: "text",
raw: "link",
text: "link"
}
]
}
]
},
{
type: "space",
raw: "\n\n"
},
links: {
"1": {
href: "#heading",
title: "heading"
}
}
]
<h1 id="heading">heading</h1>
<p> <a href="#heading" title="heading">link</a></p>
```
================================================
FILE: docs/_document.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><!--{{title}}-->Marked Documentation</title>
<!-- Prevent dark mode flash by applying theme before first paint -->
<script>
(function () {
try {
var STORAGE_KEY = "theme-preference";
var LEGACY_KEY = "theme";
var stored = localStorage.getItem(STORAGE_KEY) || localStorage.getItem(LEGACY_KEY);
var preference = stored === "dark" || stored === "light" || stored === "system" ? stored : "system";
var prefersDark =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches;
var shouldUseDark = prefersDark;
if (preference === "dark") {
shouldUseDark = true;
} else if (preference === "light") {
shouldUseDark = false;
}
if (shouldUseDark) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
document.documentElement.setAttribute("data-theme-preference", preference);
document.documentElement.setAttribute(
"data-theme",
shouldUseDark ? "dark" : "light",
);
localStorage.setItem(STORAGE_KEY, preference);
if (preference === "system") {
localStorage.removeItem(LEGACY_KEY);
} else {
localStorage.setItem(LEGACY_KEY, preference);
}
} catch (e) {}
})();
</script>
<script src="https://cdn.tailwindcss.com?plugins=forms,typography"></script>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
<link rel="stylesheet" href="/css/style.css" type="text/css" />
<link rel="stylesheet" href="/css/shared.css" type="text/css" />
<link rel="stylesheet" href="/css/hljs-github.css" type="text/css" />
<script>
// Tailwind configuration embedded directly
tailwind.config = {
darkMode: "class",
theme: {
extend: {
colors: {
primary: "#3B82F6",
"background-light": "#FFFFFF",
"background-dark": "#111827",
"text-light": "#1F2937",
"text-dark": "#F9FAFB",
"subtle-light": "#6B7280",
"subtle-dark": "#9CA3AF",
"border-light": "#E5E7EB",
"border-dark": "#374151",
"code-bg-light": "#F3F4F6",
"code-bg-dark": "#1F2937",
},
fontFamily: {
sans: ["Inter", "sans-serif"],
},
borderRadius: {
DEFAULT: "0.5rem",
},
// Add typography styles for dark mode
typography: ({ theme }) => ({
dark: {
css: {
"--tw-prose-body": theme("colors.gray[300]"),
"--tw-prose-headings": theme("colors.gray[100]"),
"--tw-prose-lead": theme("colors.gray[400]"),
"--tw-prose-links": theme("colors.blue[400]"),
"--tw-prose-bold": theme("colors.white"),
"--tw-prose-counters": theme("colors.gray[400]"),
"--tw-prose-bullets": theme("colors.gray[500]"),
"--tw-prose-hr": theme("colors.gray[700]"),
"--tw-prose-quotes": theme("colors.gray[200]"),
"--tw-prose-quote-borders": theme("colors.gray[600]"),
"--tw-prose-captions": theme("colors.gray[400]"),
"--tw-prose-code": theme("colors.gray[200]"),
"--tw-prose-pre-code": theme("colors.gray[200]"),
"--tw-prose-pre-bg": theme("colors.code-bg-dark"),
"--tw-prose-th-borders": theme("colors.gray[600]"),
"--tw-prose-td-borders": theme("colors.gray[700]"),
},
},
}),
},
},
};
</script>
</head>
<body
class="bg-background-light dark:bg-background-dark font-sans text-text-light dark:text-text-dark"
>
<!-- Mobile Menu Toggle Button -->
<button
id="mobile-menu-toggle"
class="mobile-menu-toggle"
aria-label="Toggle navigation menu"
aria-expanded="false"
>
<span class="material-icons">menu</span>
</button>
<!-- Mobile Overlay -->
<div id="mobile-overlay" class="mobile-overlay"></div>
<a
href="https://github.com/markedjs/marked"
class="github-corner"
aria-label="View source on Github"
>
<svg width="80" height="80" viewBox="0 0 250 250">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor"
style="transform-origin: 130px 106px"
class="octo-arm"
></path>
<path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor"
class="octo-body"
></path>
</svg>
</a>
<div class="flex min-h-screen">
<aside
id="sidebar"
class="sidebar w-64 fixed top-0 scroll-hidden left-0 h-full border-r border-border-light dark:border-border-dark bg-background-light dark:bg-background-dark z-40"
>
<div class="flex justify-center items-center mb-12 mt-8 px-8">
<a href="/" class="flex items-center">
<img
alt="logo"
src="/img/logo-black.svg"
class="bg-gray-100 rounded"
height="50px"
width="50px"
/>
</a>
</div>
<nav class="flex flex-col space-y-6 w-52 pl-4 pt-2">
<div>
<h3
class="font-semibold text-sm mb-3 text-subtle-light dark:text-subtle-dark uppercase tracking-wider"
>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/"
>Getting Started</a
>
</h3>
<ul
class="space-y-2 text-sm text-subtle-light dark:text-subtle-dark"
>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/#demo"
>Demo</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/#installation"
>Installation</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/#usage"
>Usage</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/#specifications"
>Specs</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/#tools"
>Tools</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/#security"
>Security</a
>
</li>
</ul>
</div>
<div>
<h3
class="font-semibold text-sm mb-3 text-subtle-light dark:text-subtle-dark uppercase tracking-wider"
>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced"
>Advanced Usage</a
>
</h3>
<ul
class="space-y-2 text-sm text-subtle-light dark:text-subtle-dark"
>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#instance"
>Instance</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#options"
>Options</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#extensions"
>Known Extensions</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#user-examples"
>User Examples</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#inline"
>Inline Markdown</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#highlight"
>Highlighting</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#workers"
>Workers</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_advanced#cli-extensions"
>CLI Extensions</a
>
</li>
</ul>
</div>
<div>
<h3
class="font-semibold text-sm mb-3 text-subtle-light dark:text-subtle-dark uppercase tracking-wider"
>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro"
>Extensibility</a
>
</h3>
<ul
class="space-y-2 text-sm text-subtle-light dark:text-subtle-dark"
>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#use"
>marked.use()</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#renderer"
>Renderer</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#tokenizer"
>Tokenizer</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#walk-tokens"
>Walk Tokens</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#hooks"
>Hooks</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#extensions"
>Custom Extensions</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#async"
>Async Marked</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#lexer"
>Lexer</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/using_pro#parser"
>Parser</a
>
</li>
</ul>
</div>
<div>
<h3
class="font-semibold text-sm mb-3 text-subtle-light dark:text-subtle-dark uppercase tracking-wider"
>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/contributing"
>Contributing</a
>
</h3>
<ul
class="space-y-2 text-sm text-subtle-light dark:text-subtle-dark"
>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/contributing#design-principles"
>Design Principles</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/contributing#priorities"
>Priorities</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/contributing#test-early-often-and-everything"
>Testing</a
>
</li>
</ul>
</div>
<ul
class="space-y-2 text-sm pt-6 border-t border-border-light dark:border-border-dark text-subtle-light dark:text-subtle-dark"
>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/code_of_conduct"
>Code of Conduct</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/authors"
>Authors</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/publishing"
>Publishing</a
>
</li>
<li>
<a
class="block hover:text-primary dark:hover:text-primary"
href="/license"
>License</a
>
</li>
</ul>
</nav>
</aside>
<main class="main-content flex-1 ml-64 px-12 py-8">
<div class="max-w-5xl mx-auto">
<div class="flex justify-between items-center mb-16">
<h1 class="text-5xl font-bold text-text-light dark:text-text-dark">
Marked Documentation
</h1>
<button
id="theme-toggle"
data-theme-mode="system"
aria-label="Switch theme"
class="flex items-center gap-2 px-4 py-2 rounded-lg text-subtle-light dark:text-subtle-dark hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
>
<span class="material-icons" data-theme-icon>brightness_auto</span>
<span class="text-sm font-medium" data-theme-text>System</span>
</button>
</div>
<article
id="content"
class="prose prose-lg max-w-none dark:prose-dark"
>
<!--{{content}}-->
</article>
</div>
</main>
</div>
<script src="/js/index.js"></script>
</body>
</html>
================================================
FILE: docs/broken.md
================================================
# Markdown is broken
I have a lot of scraps of markdown engine oddities that I've collected over the
years. What you see below is slightly messy, but it's what I've managed to
cobble together to illustrate the differences between markdown engines, and
why, if there ever is a markdown specification, it has to be absolutely
thorough. There are a lot more of these little differences I have documented
elsewhere. I know I will find them lingering on my disk one day, but until
then, I'll continue to add whatever strange nonsensical things I find.
Some of these examples may only mention a particular engine compared to marked.
However, the examples with markdown.pl could easily be swapped out for
discount, upskirt, or markdown.js, and you would very easily see even more
inconsistencies.
A lot of this was written when I was very unsatisfied with the inconsistencies
between markdown engines. Please excuse the frustration noticeable in my
writing.
## Examples of markdown's "stupid" list parsing
```
$ markdown.pl
* item1
* item2
text
^D
<ul>
<li><p>item1</p>
<ul>
<li>item2</li>
</ul>
<p><p>text</p></li>
</ul></p>
```
```
$ marked
* item1
* item2
text
^D
<ul>
<li><p>item1</p>
<ul>
<li>item2</li>
</ul>
<p>text</p>
</li>
</ul>
```
Which looks correct to you?
- - -
```
$ markdown.pl
* hello
> world
^D
<p><ul>
<li>hello</p>
<blockquote>
<p>world</li>
</ul></p>
</blockquote>
```
```
$ marked
* hello
> world
^D
<ul>
<li>hello<blockquote>
<p>world</p>
</blockquote>
</li>
</ul>
```
Again, which looks correct to you?
- - -
EXAMPLE:
```
$ markdown.pl
* hello
* world
* hi
code
^D
<ul>
<li>hello
<ul>
<li>world</li>
<li>hi
code</li>
</ul></li>
</ul>
```
The code isn't a code block even though it's after the bullet margin. I know,
lets give it two more spaces, effectively making it 8 spaces past the bullet.
```
$ markdown.pl
* hello
* world
* hi
code
^D
<ul>
<li>hello
<ul>
<li>world</li>
<li>hi
code</li>
</ul></li>
</ul>
```
And, it's still not a code block. Did you also notice that the 3rd item isn't
even its own list? Markdown screws that up too because of its indentation
unaware parsing.
- - -
Let's look at some more examples of markdown's list parsing:
```
$ markdown.pl
* item1
* item2
text
^D
<ul>
<li><p>item1</p>
<ul>
<li>item2</li>
</ul>
<p><p>text</p></li>
</ul></p>
```
Misnested tags.
```
$ marked
* item1
* item2
text
^D
<ul>
<li><p>item1</p>
<ul>
<li>item2</li>
</ul>
<p>text</p>
</li>
</ul>
```
Which looks correct to you?
- - -
```
$ markdown.pl
* hello
> world
^D
<p><ul>
<li>hello</p>
<blockquote>
<p>world</li>
</ul></p>
</blockquote>
```
More misnested tags.
```
$ marked
* hello
> world
^D
<ul>
<li>hello<blockquote>
<p>world</p>
</blockquote>
</li>
</ul>
```
Again, which looks correct to you?
- - -
# Why quality matters - Part 2
``` bash
$ markdown.pl
* hello
> world
^D
<p><ul>
<li>hello</p>
<blockquote>
<p>world</li>
</ul></p>
</blockquote>
```
``` bash
$ sundown # upskirt
* hello
> world
^D
<ul>
<li>hello
> world</li>
</ul>
```
``` bash
$ marked
* hello
> world
^D
<ul><li>hello <blockquote><p>world</p></blockquote></li></ul>
```
Which looks correct to you?
- - -
See: https://github.com/evilstreak/markdown-js/issues/23
``` bash
$ markdown.pl # upskirt/markdown.js/discount
* hello
var a = 1;
* world
^D
<ul>
<li>hello
var a = 1;</li>
<li>world</li>
</ul>
```
``` bash
$ marked
* hello
var a = 1;
* world
^D
<ul><li>hello
<pre>code>var a = 1;</code></pre></li>
<li>world</li></ul>
```
Which looks more reasonable? Why shouldn't code blocks be able to appear in
list items in a sane way?
- - -
``` bash
$ markdown.js
<div>hello</div>
<span>hello</span>
^D
<p><div>hello</div></p>
<p><span>hello</span></p>
```
``` bash
$ marked
<div>hello</div>
<span>hello</span>
^D
<div>hello</div>
<p><span>hello</span>
</p>
```
- - -
See: https://github.com/evilstreak/markdown-js/issues/27
``` bash
$ markdown.js
[](/link)
^D
<p><a href="/image)](/link">](/link)
^D
<p><a href="/link"><img src="/image" alt="an image"></a>
</p>
```
- - -
See: https://github.com/evilstreak/markdown-js/issues/24
``` bash
$ markdown.js
> a
> b
> c
^D
<blockquote><p>a</p><p>bundefined> c</p></blockquote>
```
``` bash
$ marked
> a
> b
> c
^D
<blockquote><p>a
</p></blockquote>
<blockquote><p>b
</p></blockquote>
<blockquote><p>c
</p></blockquote>
```
- - -
``` bash
$ markdown.pl
* hello
* world
how
are
you
* today
* hi
^D
<ul>
<li><p>hello</p>
<ul>
<li>world
how</li>
</ul>
<p>are
you</p>
<ul>
<li>today</li>
</ul></li>
<li>hi</li>
</ul>
```
``` bash
$ marked
* hello
* world
how
are
you
* today
* hi
^D
<ul>
<li><p>hello</p>
<ul>
<li><p>world
how</p>
<p>are
you</p>
</li>
<li><p>today</p>
</li>
</ul>
</li>
<li>hi</li>
</ul>
```
================================================
FILE: docs/build.js
================================================
/* global marked */
import '../lib/marked.umd.js';
import { promises } from 'fs';
import { join, dirname, parse, format } from 'path';
import { fileURLToPath } from 'url';
import { markedHighlight } from 'marked-highlight';
import { HighlightJS } from 'highlight.js';
import titleize from 'titleize';
import { getTests } from '@markedjs/testutils';
const { mkdir, rm, readdir, stat, readFile, writeFile, copyFile } = promises;
const { highlight, highlightAuto } = HighlightJS;
const cwd = process.cwd();
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const inputDir = join(cwd, 'docs');
const outputDir = join(cwd, 'public');
const templateFile = join(inputDir, '_document.html');
const isUppercase = str => /[A-Z_]+/.test(str);
const getTitle = str => str === 'INDEX' ? '' : titleize(str.replace(/_/g, ' ')) + ' - ';
function convertTestsToTable(name, tests) {
let total = 0;
let passing = 0;
let table = '\n| Section | Passing | Percent |\n';
table += '|:--------|:--------|--------:|\n';
for (const [key, value] of Object.entries(tests)) {
total += value.total;
passing += value.pass;
table += ` | ${key}`;
table += ` | ${(value.pass)} of ${(value.total)}`;
table += ` | ${((value.pass) / value.total * 100).toFixed()}%`;
table += ' |\n';
}
return `\n<details name="markdown-spec">
<summary>${name} (${(passing / total * 100).toFixed()}%)</summary>
${table}
</details>\n`;
}
const markedInstance = new marked.Marked(markedHighlight((code, language) => {
if (!language) {
return highlightAuto(code).value;
}
return highlight(code, { language }).value;
}));
async function init() {
console.log('Cleaning up output directory ' + outputDir);
await rm(outputDir, { force: true, recursive: true });
await mkdir(outputDir);
await mkdir(join(outputDir, 'lib'));
console.log(`Copying file ${join(inputDir, 'LICENSE.md')}`);
await copyFile(join(cwd, 'LICENSE.md'), join(inputDir, 'LICENSE.md'));
console.log(`Copying file ${join(outputDir, 'lib/marked.umd.js')}`);
await copyFile(join(cwd, 'lib/marked.umd.js'), join(outputDir, 'lib/marked.umd.js'));
console.log(`Copying file ${join(outputDir, 'lib/marked.umd.js.map')}`);
await copyFile(join(cwd, 'lib/marked.umd.js.map'), join(outputDir, 'lib/marked.umd.js.map'));
console.log(`Copying file ${join(outputDir, 'lib/marked.esm.js')}`);
await copyFile(join(cwd, 'lib/marked.esm.js'), join(outputDir, 'lib/marked.esm.js'));
console.log(`Copying file ${join(outputDir, 'lib/marked.esm.js.map')}`);
await copyFile(join(cwd, 'lib/marked.esm.js.map'), join(outputDir, 'lib/marked.esm.js.map'));
const tmpl = await readFile(templateFile, 'utf8');
console.log('Building markdown...');
const [original, commonmark, gfm] = await getTests([
join(__dirname, '../test/specs/original'),
join(__dirname, '../test/specs/commonmark'),
join(__dirname, '../test/specs/gfm'),
]);
const testResultsTable =
convertTestsToTable('Markdown 1.0', original)
+ convertTestsToTable('CommonMark 0.31', commonmark)
+ convertTestsToTable('GitHub Flavored Markdown 0.29', gfm);
await build(inputDir, tmpl, testResultsTable);
console.log('Build complete!');
}
const ignoredFiles = [
join(cwd, 'docs', 'build.js'),
join(cwd, 'docs', '.eslintrc.json'),
join(cwd, 'docs', '_document.html'),
];
async function build(currentDir, tmpl, testResultsTable) {
const files = await readdir(currentDir);
for (const file of files) {
const filename = join(currentDir, file);
if (ignoredFiles.includes(filename)) {
continue;
}
const stats = await stat(filename);
const { mode } = stats;
if (stats.isDirectory()) {
await build(filename, tmpl);
} else {
let html = await readFile(filename, 'utf8');
const parsed = parse(filename);
if (parsed.ext === '.md' && isUppercase(parsed.name)) {
const mdHtml = markedInstance.parse(
html.replace('<!--{{test-results-table}}-->', testResultsTable),
);
html = tmpl
.replace('<!--{{title}}-->', getTitle(parsed.name))
.replace('<!--{{content}}-->', mdHtml);
parsed.ext = '.html';
parsed.name = parsed.name.toLowerCase();
delete parsed.base;
}
parsed.dir = parsed.dir.replace(inputDir, outputDir);
const outfile = format(parsed);
await mkdir(dirname(outfile), { recursive: true });
console.log('Writing file ' + outfile);
await writeFile(outfile, html, { mode });
}
}
}
init().catch(console.error);
================================================
FILE: docs/css/hljs-github-dark.css
================================================
/*!
Theme: GitHub Dark
Description: Dark theme for syntax highlighting
Based on GitHub's dark theme colors
*/
/* Dark theme syntax highlighting - Manual dark mode */
[data-theme="dark"] .hljs {
color: #e6edf3;
background: #262c36;
}
[data-theme="dark"] .hljs-doctag,
[data-theme="dark"] .hljs-keyword,
[data-theme="dark"] .hljs-meta .hljs-keyword,
[data-theme="dark"] .hljs-template-tag,
[data-theme="dark"] .hljs-template-variable,
[data-theme="dark"] .hljs-type,
[data-theme="dark"] .hljs-variable.language_ {
color: #ff7b72;
}
[data-theme="dark"] .hljs-title,
[data-theme="dark"] .hljs-title.class_,
[data-theme="dark"] .hljs-title.class_.inherited__,
[data-theme="dark"] .hljs-title.function_ {
color: #d2a8ff;
}
[data-theme="dark"] .hljs-attr,
[data-theme="dark"] .hljs-attribute,
[data-theme="dark"] .hljs-literal,
[data-theme="dark"] .hljs-meta,
[data-theme="dark"] .hljs-number,
[data-theme="dark"] .hljs-operator,
[data-theme="dark"] .hljs-variable,
[data-theme="dark"] .hljs-selector-attr,
[data-theme="dark"] .hljs-selector-class,
[data-theme="dark"] .hljs-selector-id {
color: #79c0ff;
}
[data-theme="dark"] .hljs-regexp,
[data-theme="dark"] .hljs-string {
color: #a5d6ff;
}
[data-theme="dark"] .hljs-built_in,
[data-theme="dark"] .hljs-symbol {
color: #ffa657;
}
[data-theme="dark"] .hljs-comment,
[data-theme="dark"] .hljs-code,
[data-theme="dark"] .hljs-formula {
color: #8b949e;
}
[data-theme="dark"] .hljs-name,
[data-theme="dark"] .hljs-quote,
[data-theme="dark"] .hljs-selector-tag,
[data-theme="dark"] .hljs-selector-pseudo {
color: #7ee787;
}
[data-theme="dark"] .hljs-subst {
color: #e6edf3;
}
[data-theme="dark"] .hljs-section {
color: #1f6feb;
font-weight: bold;
}
[data-theme="dark"] .hljs-bullet {
color: #f2cc60;
}
[data-theme="dark"] .hljs-emphasis {
color: #e6edf3;
font-style: italic;
}
[data-theme="dark"] .hljs-strong {
color: #e6edf3;
font-weight: bold;
}
[data-theme="dark"] .hljs-addition {
color: #aff5b4;
background-color: #033a16;
}
[data-theme="dark"] .hljs-deletion {
color: #ffdcd7;
background-color: #67060c;
}
/* Dark theme syntax highlighting - System preference auto mode */
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .hljs {
color: #e6edf3;
background: #262c36;
}
:root:not([data-theme="light"]) .hljs-doctag,
:root:not([data-theme="light"]) .hljs-keyword,
:root:not([data-theme="light"]) .hljs-meta .hljs-keyword,
:root:not([data-theme="light"]) .hljs-template-tag,
:root:not([data-theme="light"]) .hljs-template-variable,
:root:not([data-theme="light"]) .hljs-type,
:root:not([data-theme="light"]) .hljs-variable.language_ {
color: #ff7b72;
}
:root:not([data-theme="light"]) .hljs-title,
:root:not([data-theme="light"]) .hljs-title.class_,
:root:not([data-theme="light"]) .hljs-title.class_.inherited__,
:root:not([data-theme="light"]) .hljs-title.function_ {
color: #d2a8ff;
}
:root:not([data-theme="light"]) .hljs-attr,
:root:not([data-theme="light"]) .hljs-attribute,
:root:not([data-theme="light"]) .hljs-literal,
:root:not([data-theme="light"]) .hljs-meta,
:root:not([data-theme="light"]) .hljs-number,
:root:not([data-theme="light"]) .hljs-operator,
:root:not([data-theme="light"]) .hljs-variable,
:root:not([data-theme="light"]) .hljs-selector-attr,
:root:not([data-theme="light"]) .hljs-selector-class,
:root:not([data-theme="light"]) .hljs-selector-id {
color: #79c0ff;
}
:root:not([data-theme="light"]) .hljs-regexp,
:root:not([data-theme="light"]) .hljs-string {
color: #a5d6ff;
}
:root:not([data-theme="light"]) .hljs-built_in,
:root:not([data-theme="light"]) .hljs-symbol {
color: #ffa657;
}
:root:not([data-theme="light"]) .hljs-comment,
:root:not([data-theme="light"]) .hljs-code,
:root:not([data-theme="light"]) .hljs-formula {
color: #8b949e;
}
:root:not([data-theme="light"]) .hljs-name,
:root:not([data-theme="light"]) .hljs-quote,
:root:not([data-theme="light"]) .hljs-selector-tag,
:root:not([data-theme="light"]) .hljs-selector-pseudo {
color: #7ee787;
}
:root:not([data-theme="light"]) .hljs-subst {
color: #e6edf3;
}
:root:not([data-theme="light"]) .hljs-section {
color: #1f6feb;
font-weight: bold;
}
:root:not([data-theme="light"]) .hljs-bullet {
color: #f2cc60;
}
:root:not([data-theme="light"]) .hljs-emphasis {
color: #e6edf3;
font-style: italic;
}
:root:not([data-theme="light"]) .hljs-strong {
color: #e6edf3;
font-weight: bold;
}
:root:not([data-theme="light"]) .hljs-addition {
color: #aff5b4;
background-color: #033a16;
}
:root:not([data-theme="light"]) .hljs-deletion {
color: #ffdcd7;
background-color: #67060c;
}
}
================================================
FILE: docs/css/hljs-github.css
================================================
/*!
Theme: GitHub (Adapted for dynamic light/dark mode)
*/
.hljs {
color: var(--text-color);
background: var(--background-color);
}
.hljs-doctag,
.hljs-keyword,
.hljs-meta .hljs-keyword,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-variable.language_ {
color: #d73a49;
}
.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-title.function_ {
color: #6f42c1;
}
.hljs-attr,
.hljs-attribute,
.hljs-literal,
.hljs-meta,
.hljs-number,
.hljs-operator,
.hljs-variable,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-id {
color: #005cc5;
}
.hljs-regexp,
.hljs-string,
.hljs-meta .hljs-string {
color: #032f62;
}
.hljs-built_in,
.hljs-symbol {
color: #e36209;
}
.hljs-comment,
.hljs-code,
.hljs-formula {
color: var(--subtle-text-color);
}
.hljs-name,
.hljs-quote,
.hljs-selector-tag,
.hljs-selector-pseudo {
color: #22863a;
}
.hljs-subst {
color: var(--text-color);
}
.hljs-section {
color: #005cc5;
font-weight: bold;
}
.hljs-bullet {
color: #735c0f;
}
.hljs-emphasis {
color: var(--text-color);
font-style: italic;
}
.hljs-strong {
color: var(--text-color);
font-weight: bold;
}
.hljs-addition {
color: #22863a;
background-color: #f0fff4;
}
.hljs-deletion {
color: #b31d28;
background-color: #ffeef0;
}
/*!
Theme: GitHub Dark
Description: Dark theme as seen on github.com
*/
.dark .hljs {
color: #c9d1d9;
}
.dark .hljs-doctag,
.dark .hljs-keyword,
.dark .hljs-meta .hljs-keyword,
.dark .hljs-template-tag,
.dark .hljs-template-variable,
.dark .hljs-type,
.dark .hljs-variable.language_ {
color: #ff7b72;
}
.dark .hljs-title,
.dark .hljs-title.class_,
.dark .hljs-title.class_.inherited__,
.dark .hljs-title.function_ {
color: #d2a8ff;
}
.dark .hljs-attr,
.dark .hljs-attribute,
.dark .hljs-literal,
.dark .hljs-meta,
.dark .hljs-number,
.dark .hljs-operator,
.dark .hljs-variable,
.dark .hljs-selector-attr,
.dark .hljs-selector-class,
.dark .hljs-selector-id {
color: #79c0ff; /* This is the light blue for variables */
}
.dark .hljs-regexp,
.dark .hljs-string,
.dark .hljs-meta .hljs-string {
color: #a5d6ff; /* This is the light blue for strings */
}
.dark .hljs-built_in,
.dark .hljs-symbol {
color: #ffa657;
}
.dark .hljs-comment,
.dark .hljs-code,
.dark .heading.local .hljs-formula {
color: #8b949e;
}
.dark .hljs-name,
.dark .hljs-quote,
.dark .hljs-selector-tag,
.dark .s.h.s .hljs-selector-pseudo {
color: #7ee787;
}
.dark .hljs-subst {
color: #c9d1d9;
}
.dark .hljs-section {
color: #1f6feb;
font-weight: bold;
}
.dark .hljs-bullet {
color: #f2cc60;
}
.dark .hljs-emphasis {
color: #c9d1d9;
font-style: italic;
}
.dark .hljs-strong {
color: #c9d1d9;
font-weight: bold;
}
.dark .hljs-addition {
color: #aff5b4;
background-color: #033a16;
}
.dark .hljs-deletion {
color: #ffdcd7;
background-color: #67060c;
}
================================================
FILE: docs/css/shared.css
================================================
a.github-corner {
position: fixed !important;
top: 0;
right: 0;
border: 0;
z-index: 9999 !important;
display: block;
}
/*
FIX: Explicitly apply light mode styles ONLY when .dark is NOT present.
This prevents the light mode rule from conflicting with the dark mode rule.
*/
html:not(.dark) a.github-corner svg {
fill: #0d1117 !important; /* Dark triangle */
color: #f0f6fc !important; /* White octocat */
}
/*
FIX: Increased specificity for the dark mode rule.
*/
html.dark a.github-corner svg {
fill: #f0f6fc !important; /* White triangle */
color: #0d1117 !important; /* Dark octocat */
}
a.github-corner:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out;
}
@keyframes octocat-wave {
0%, 100% { transform: rotate(0); }
20%, 60% { transform: rotate(-25deg); }
40%, 80% { transform: rotate(10deg); }
}
/* Mobile: Hide GitHub corner on small screens */
@media (max-width: 768px) {
a.github-corner {
display: none;
}
}
================================================
FILE: docs/css/style.css
================================================
/*
This file contains custom styles and CSS variables that supplement Tailwind CSS.
*/
/* Define color scheme variables based on the Tailwind config */
@layer utilities {
.scroll-hidden {
overflow-y: auto;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.scroll-hidden::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera */
}
}
/* Improved section spacing */
.prose h2 {
margin-top: 3rem;
margin-bottom: 1.5rem;
}
.prose h3 {
margin-top: 2.5rem;
margin-bottom: 1.25rem;
}
.prose p {
margin-bottom: 1.25rem;
line-height: 1.75;
}
.prose ul, .prose ol {
margin-top: 1.25rem;
margin-bottom: 1.25rem;
}
.prose pre {
margin-top: 1.5rem;
margin-bottom: 1.5rem;
}
:root {
--primary-color: #3B82F6;
--background-color: #FFFFFF;
--text-color: #1F2937;
--subtle-text-color: #6B7280;
--border-color: #E5E7EB;
--code-bg-color: #F3F4F6;
}
.dark {
--background-color: #111827;
--text-color: #F9FAFB;
--subtle-text-color: #9CA3AF;
--border-color: #374151;
--code-bg-color: #1F2937;
}
/* Custom styles for the warning box */
.alert-warning {
background-color: #FEF2F2;
border-left: 4px solid #EF4444;
color: #B91C1C;
padding: 1rem;
border-radius: 0 0.5rem 0.5rem 0;
margin: 1.5rem 0;
}
.dark .alert-warning {
background-color: #2c1d1d;
border-left-color: #F87171;
color: #FCA5A5;
}
.alert-warning a {
text-decoration: underline;
font-weight: 500;
}
/* --- Add this to the end of docs/css/style.css --- */
/* --- Add this to the end of docs/css/style.css --- */
/* This sets the background color for all code blocks
and lets height be dynamic.
*/
pre {
height: auto;
align-items: center;
}
.prose pre {
background-color: #D1D5DB; /* Your light mode bg-gray-300 */
color:black;
}
.dark .prose pre {
background-color: #1F2937; /* Your dark mode dark:bg-gray-800 */
color: white;
}
/* This fixes a conflict where the <code> tag
itself has a background, hiding the <pre> background.
*/
.prose pre code.hljs {
background-color: transparent !important;
}
/* ============================================
MOBILE RESPONSIVE STYLES
============================================ */
/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
display: none; /* Hidden on desktop by default */
position: fixed;
top: 16px;
left: 16px;
z-index: 9998;
width: 48px;
height: 48px;
border: none;
border-radius: 8px;
background-color: var(--background-color);
color: var(--text-color);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
align-items: center;
justify-content: center;
}
.mobile-menu-toggle:hover {
background-color: var(--code-bg-color);
transform: scale(1.05);
}
.mobile-menu-toggle:active {
transform: scale(0.95);
}
.dark .mobile-menu-toggle {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
/* Mobile Overlay */
.mobile-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 39;
opacity: 0;
transition: opacity 0.3s ease;
}
.mobile-overlay.active {
opacity: 1;
}
/* Mobile Styles - Changed breakpoint from 768px to 1024px */
@media (max-width: 1024px) {
/* Show mobile menu button */
.mobile-menu-toggle {
display: flex;
}
/* Hide sidebar by default on mobile */
.sidebar {
transform: translateX(-100%);
transition: transform 0.3s ease;
}
/* Show sidebar when menu is open */
.sidebar.mobile-open {
transform: translateX(0);
}
/* Show overlay when menu is open */
.mobile-overlay.active {
display: block;
}
/* Adjust main content for mobile */
.main-content {
margin-left: 0 !important;
padding: 80px 20px 20px 20px !important;
width: 100%;
}
/* Adjust theme toggle button position on mobile */
#theme-toggle {
position: fixed;
top: 16px;
right: 16px;
z-index: 9998;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
background-color: var(--background-color);
}
.dark #theme-toggle {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
/* Adjust GitHub corner for mobile */
.github-corner {
display: none;
}
/* Make sidebar full height on mobile */
.sidebar {
width: 280px;
max-width: 85vw;
}
/* Adjust heading sizes for mobile */
.main-content h1 {
font-size: 2rem !important;
}
/* Adjust prose max-width for mobile */
.prose {
max-width: 100% !important;
}
/* Make tables scrollable on mobile */
.prose table {
display: block;
overflow-x: auto;
white-space: nowrap;
}
/* Adjust code blocks for mobile */
.prose pre {
font-size: 0.875rem;
padding: 1rem;
}
}
/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
overflow: hidden;
}
@media (max-width: 1024px) {
body.mobile-menu-open {
overflow: hidden;
}
}
================================================
FILE: docs/demo/demo.css
================================================
html, body {
margin: 0;
padding: 0;
font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: var(--text-color);
background-color: var(--background-color);
height: 100%;
overflow: auto;
transition: background-color 0.3s ease, color 0.3s ease;
}
textarea {
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
font-size: 12px;
resize: none;
}
header {
padding: 16px 24px;
display: flex;
align-items: center;
height: 68px;
box-sizing: border-box;
border-bottom: 1px solid var(--border-color);
gap: 16px;
}
header .logo-link {
display: flex;
align-items: center;
}
header h1 {
margin: 0;
font-size: 24px;
font-weight: 700;
color: inherit;
}
.other-demos {
margin-left: auto;
display: flex;
align-items: center;
gap: 8px;
font-size: 14px;
}
.other-demos a {
color: var(--subtle-text-color);
text-decoration: none;
transition: color 0.2s ease;
}
.other-demos a:hover {
color: #3B82F6;
}
.other-demos .separator {
color: var(--subtle-text-color);
}
.theme-toggle {
margin-left: 16px;
display: flex;
align-items: center;
gap: 8px;
padding: 8px 16px;
border: none;
border-radius: 8px;
background-color: transparent;
color: var(--subtle-text-color);
cursor: pointer;
font-family: inherit;
font-size: 14px;
font-weight: 500;
transition: background-color 0.2s ease, color 0.2s ease;
}
.theme-toggle:hover {
background-color: var(--code-bg-color);
color: var(--text-color);
}
.theme-toggle .material-icons {
font-size: 20px;
}
.containers {
display: flex;
height: calc(100vh - 68px);
gap: 12px;
padding: 12px;
box-sizing: border-box;
}
.container {
flex-basis: 50%;
display: flex;
flex-direction: column;
height: 100%;
box-sizing: border-box;
}
.label {
padding: 8px 12px;
background-color: var(--code-bg-color);
border: 1px solid var(--border-color);
border-radius: 8px 8px 0 0;
font-size: 14px;
font-weight: 500;
display: flex;
align-items: center;
gap: 8px;
color: var(--text-color);
}
.label select,
.label button {
padding: 4px 8px;
border-radius: 4px;
border: 1px solid var(--border-color);
background-color: var(--background-color);
color: var(--text-color);
font-size: 13px;
cursor: pointer;
transition: border-color 0.2s ease;
}
.label select:hover,
.label button:hover {
border-color: #3B82F6;
}
.label a {
color: #3B82F6;
text-decoration: none;
}
.label a:hover {
text-decoration: underline;
}
.pane, .inputPane {
padding: 12px;
border: 1px solid var(--border-color);
border-top: none;
border-radius: 0 0 8px 8px;
overflow: auto;
flex-grow: 1;
flex-shrink: 1;
background-color: var(--background-color);
color: var(--text-color);
transition: background-color 0.3s ease, border-color 0.3s ease;
}
#preview {
display: flex;
}
#preview iframe {
flex-grow: 1;
border-radius: 0 0 8px 8px;
}
#main {
display: none;
}
#loading {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
font-size: 18px;
color: var(--subtle-text-color);
}
.error {
border-color: #EF4444 !important;
background-color: #FEF2F2 !important;
}
.loadingError {
background-color: #FEF2F2;
font-weight: 600;
color: #DC2626;
text-align: center;
padding: 16px;
border-radius: 8px;
margin: 20px;
}
#responseTime {
display: inline-block;
font-weight: 600;
color: #3B82F6;
}
/* Dark mode specific overrides */
html.dark .error {
background-color: #2c1d1d !important;
border-color: #F87171 !important;
color: #FCA5A5;
}
html.dark .loadingError {
background-color: #2c1d1d;
color: #FCA5A5;
}
html.dark #loading {
color: #9CA3AF;
}
================================================
FILE: docs/demo/demo.js
================================================
onunhandledrejection = (e) => {
throw e.reason;
};
const $loadingElem = document.querySelector('#loading');
const $mainElem = document.querySelector('#main');
const $markdownElem = document.querySelector('#markdown');
const $markedVerElem = document.querySelector('#markedVersion');
const $optionsElem = document.querySelector('#options');
const $outputTypeElem = document.querySelector('#outputType');
const $inputTypeElem = document.querySelector('#inputType');
const $responseTimeElem = document.querySelector('#responseTime');
const $previewElem = document.querySelector('#preview');
const $previewIframe = document.querySelector('#preview iframe');
const $permalinkElem = document.querySelector('#permalink');
const $clearElem = document.querySelector('#clear');
const $htmlElem = document.querySelector('#html');
const $lexerElem = document.querySelector('#lexer');
const $panes = document.querySelectorAll('.pane');
const $inputPanes = document.querySelectorAll('.inputPane');
let lastInput = '';
let inputDirty = true;
let $activeOutputElem = null;
let latestVersion = 'master';
const search = searchToObject();
const markedVersions = {
master: '../',
};
let delayTime = 1;
let checkChangeTimeout = null;
let markedWorker;
$previewIframe.addEventListener('load', handleIframeLoad);
$outputTypeElem.addEventListener('change', handleOutputChange, false);
$inputTypeElem.addEventListener('change', handleInputChange, false);
$markedVerElem.addEventListener('change', handleVersionChange, false);
$markdownElem.addEventListener('change', handleInput, false);
$markdownElem.addEventListener('keyup', handleInput, false);
$markdownElem.addEventListener('keypress', handleInput, false);
$markdownElem.addEventListener('keydown', handleInput, false);
$optionsElem.addEventListener('change', handleInput, false);
$optionsElem.addEventListener('keyup', handleInput, false);
$optionsElem.addEventListener('keypress', handleInput, false);
$optionsElem.addEventListener('keydown', handleInput, false);
$clearElem.addEventListener('click', handleClearClick, false);
// --- Theme Toggle Setup ---
const $themeToggle = document.getElementById('theme-toggle');
const $themeToggleIcon = $themeToggle ? $themeToggle.querySelector('[data-theme-icon]') : null;
const $themeToggleText = $themeToggle ? $themeToggle.querySelector('[data-theme-text]') : null;
const THEME_STORAGE_KEY = 'theme-preference';
const LEGACY_STORAGE_KEY = 'theme';
const THEME_ORDER = ['system', 'light', 'dark'];
const TOGGLE_UI = {
system: { icon: 'brightness_auto', text: 'System' },
light: { icon: 'light_mode', text: 'Light' },
dark: { icon: 'dark_mode', text: 'Dark' },
};
function applyTheme(theme) {
if (theme === 'dark') {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
document.documentElement.setAttribute('data-theme', theme);
try {
if ($previewIframe && $previewIframe.contentDocument) {
if (theme === 'dark') {
$previewIframe.contentDocument.documentElement.classList.add('dark');
} else {
$previewIframe.contentDocument.documentElement.classList.remove('dark');
}
}
} catch {
// Ignore cross-origin errors
}
}
function getSystemTheme() {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
return 'dark';
}
return 'light';
}
function sanitisePreference(value) {
return THEME_ORDER.includes(value) ? value : null;
}
function readStoredPreference() {
try {
const stored = sanitisePreference(localStorage.getItem(THEME_STORAGE_KEY));
if (stored) {
return stored;
}
return sanitisePreference(localStorage.getItem(LEGACY_STORAGE_KEY));
} catch {
return null;
}
}
function writeStoredPreference(preference) {
try {
localStorage.setItem(THEME_STORAGE_KEY, preference);
if (preference === 'light' || preference === 'dark') {
localStorage.setItem(LEGACY_STORAGE_KEY, preference);
} else {
localStorage.removeItem(LEGACY_STORAGE_KEY);
}
} catch {
// Storage might be unavailable; ignore
}
}
function getEffectiveTheme(preference) {
return preference === 'system' ? getSystemTheme() : preference;
}
function updateToggle(preference) {
if (!$themeToggle) {
return;
}
const details = TOGGLE_UI[preference] || TOGGLE_UI.system;
if ($themeToggleIcon) {
$themeToggleIcon.textContent = details.icon;
}
if ($themeToggleText) {
$themeToggleText.textContent = details.text;
}
$themeToggle.setAttribute('data-theme-mode', preference);
const label = `Switch theme (current: ${details.text})`;
$themeToggle.setAttribute('aria-label', label);
$themeToggle.title = label;
}
let currentPreference = readStoredPreference() || 'system';
function applyPreference(preference, persist) {
currentPreference = preference;
const effectiveTheme = getEffectiveTheme(preference);
applyTheme(effectiveTheme);
document.documentElement.setAttribute('data-theme-preference', preference);
updateToggle(preference);
if (persist) {
writeStoredPreference(preference);
}
}
applyPreference(currentPreference, true);
if ($themeToggle) {
$themeToggle.addEventListener('click', function() {
const index = THEME_ORDER.indexOf(currentPreference);
const nextIndex = (index + 1) % THEME_ORDER.length;
const nextPreference = THEME_ORDER[nextIndex];
applyPreference(nextPreference, true);
});
}
const systemMatcher = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
if (systemMatcher) {
const handleSystemChange = function() {
if (currentPreference === 'system') {
applyPreference('system', false);
}
};
if (typeof systemMatcher.addEventListener === 'function') {
systemMatcher.addEventListener('change', handleSystemChange);
} else if (typeof systemMatcher.addListener === 'function') {
systemMatcher.addListener(handleSystemChange);
}
}
Promise.all([
setInitialQuickref(),
setInitialOutputType(),
setInitialText(),
setInitialVersion().then(setInitialOptions),
])
.then(() => {
handleInputChange();
handleOutputChange();
checkForChanges();
setScrollPercent(0);
$loadingElem.style.display = 'none';
$mainElem.style.display = 'block';
})
.catch(() => {
$loadingElem.classList.add('loadingError');
$loadingElem.textContent =
'Failed to load marked. Refresh the page to try again.';
});
function setInitialText() {
if ('text' in search) {
$markdownElem.value = search.text;
} else {
return fetch('./initial.md')
.then((res) => res.text())
.then((text) => {
if ($markdownElem.value === '') {
$markdownElem.value = text;
}
});
}
}
function setInitialQuickref() {
return fetch('./quickref.md')
.then((res) => res.text())
.then((text) => {
document.querySelector('#quickref').value = text;
});
}
function setInitialVersion() {
return fetch('https://data.jsdelivr.com/v1/package/npm/marked')
.then((res) => res.json())
.then((json) => {
for (const ver of json.versions) {
markedVersions[ver] = 'https://cdn.jsdelivr.net/npm/marked@' + ver;
const opt = document.createElement('option');
opt.textContent = ver;
opt.value = ver;
$markedVerElem.appendChild(opt);
}
if (location.host === 'marked.js.org') {
latestVersion = json.tags.latest;
} else {
$markedVerElem.querySelector('option[value="master"]').textContent =
'This Build';
}
if (search.version && markedVersions[search.version]) {
$markedVerElem.value = search.version;
return;
}
$markedVerElem.value = latestVersion;
})
.then(updateVersion);
}
function setInitialOptions() {
if ('options' in search) {
$optionsElem.value = search.options;
} else {
return setDefaultOptions();
}
}
function setInitialOutputType() {
if (search.outputType) {
$outputTypeElem.value = search.outputType;
}
}
function handleIframeLoad() {
lastInput = '';
inputDirty = true;
// Apply current theme to the iframe
try {
const currentTheme = document.documentElement.classList.contains('dark')
? 'dark'
: 'light';
if ($previewIframe && $previewIframe.contentDocument) {
if (currentTheme === 'dark') {
$previewIframe.contentDocument.documentElement.classList.add('dark');
} else {
$previewIframe.contentDocument.documentElement.classList.remove('dark');
}
}
} catch {
// Ignore cross-origin errors
}
}
function handleInput() {
inputDirty = true;
}
function handleVersionChange() {
updateVersion();
}
function handleClearClick() {
$markdownElem.value = '';
$markedVerElem.value = latestVersion;
updateVersion();
setDefaultOptions();
}
function handleInputChange() {
handleChange($inputPanes, $inputTypeElem.value);
}
function handleOutputChange() {
$activeOutputElem = handleChange($panes, $outputTypeElem.value);
updateLink();
}
function handleChange(panes, visiblePane) {
let active = null;
for (let i = 0; i < panes.length; i++) {
if (panes[i].id === visiblePane) {
panes[i].style.display = '';
active = panes[i];
} else {
panes[i].style.display = 'none';
}
}
return active;
}
function setDefaultOptions() {
return messageWorker({
task: 'defaults',
version: markedVersions[$markedVerElem.value],
});
}
function setOptions(opts) {
$optionsElem.value = JSON.stringify(
opts,
(key, value) => {
if (value !== null
&& typeof value === 'object'
&& Object.getPrototypeOf(value) !== Object.prototype
) {
return undefined;
}
return value;
},
' ',
);
}
function searchToObject() {
// modified from https://stackoverflow.com/a/7090123/806777
const pairs = location.search.slice(1).split('&');
const obj = {};
for (let i = 0; i < pairs.length; i++) {
if (pairs[i] === '') {
continue;
}
const pair = pairs[i].split('=');
obj[decodeURIComponent(pair.shift())] = decodeURIComponent(pair.join('='));
}
return obj;
}
function getScrollSize() {
if (!$activeOutputElem) {
return 0;
}
const e = $activeOutputElem;
return e.scrollHeight - e.clientHeight;
}
function getScrollPercent() {
if (!$activeOutputElem) {
return 1;
}
const size = getScrollSize();
if (size <= 0) {
return 1;
}
return $activeOutputElem.scrollTop / size;
}
function setScrollPercent(percent) {
if ($activeOutputElem) {
$activeOutputElem.scrollTop = percent * getScrollSize();
}
}
function updateLink() {
let outputType = '';
if ($outputTypeElem.value !== 'preview') {
outputType = 'outputType='
+ $outputTypeElem.value
+ '&';
}
$permalinkElem.href = '?'
+ outputType
+ 'text='
+ encodeURIComponent($markdownElem.value)
+ '&options='
+ encodeURIComponent($optionsElem.value)
+ '&version='
+ encodeURIComponent($markedVerElem.value);
history.replaceState('', document.title, $permalinkElem.href);
}
function updateVersion() {
handleInput();
}
function checkForChanges() {
if (inputDirty && $markedVerElem.value !== 'pr') {
inputDirty = false;
updateLink();
let options = {};
const optionsString = $optionsElem.value || '{}';
try {
const newOptions = JSON.parse(optionsString);
options = newOptions;
$optionsElem.classList.remove('error');
} catch {
$optionsElem.classList.add('error');
}
const version = markedVersions[$markedVerElem.value];
const markdown = $markdownElem.value;
const hash = version + markdown + optionsString;
if (lastInput !== hash) {
lastInput = hash;
delayTime = 100;
messageWorker({
task: 'parse',
version,
markdown,
options,
});
}
}
checkChangeTimeout = window.setTimeout(checkForChanges, delayTime);
}
function setResponseTime(ms) {
let amount = ms;
let suffix = 'ms';
if (ms > 1000 * 60 * 60) {
amount = 'Too Long';
suffix = '';
} else if (ms > 1000 * 60) {
amount = '>'
+ Math.floor(ms / (1000 * 60));
suffix = 'm';
} else if (ms > 1000) {
amount = '>'
+ Math.floor(ms / 1000);
suffix = 's';
}
$responseTimeElem.textContent = amount + suffix;
$responseTimeElem.animate(
[{ transform: 'scale(1.2)' }, { transform: 'scale(1)' }],
200,
);
}
function setParsed(parsed, lexed) {
try {
$previewIframe.contentDocument.body.innerHTML = parsed;
} catch {}
$htmlElem.value = parsed;
$lexerElem.value = lexed;
}
const workerPromises = {};
function messageWorker(message) {
if (!markedWorker || markedWorker.working) {
if (markedWorker) {
clearTimeout(markedWorker.timeout);
markedWorker.terminate();
}
markedWorker = new Worker('worker.js');
markedWorker.onmessage = (e) => {
clearTimeout(markedWorker.timeout);
markedWorker.working = false;
switch (e.data.task) {
case 'defaults': {
setOptions(e.data.defaults);
break;
}
case 'parse': {
$previewElem.classList.remove('error');
$htmlElem.classList.remove('error');
$lexerElem.classList.remove('error');
const scrollPercent = getScrollPercent();
setParsed(e.data.parsed, e.data.lexed);
setScrollPercent(scrollPercent);
setResponseTime(e.data.time);
break;
}
}
clearTimeout(checkChangeTimeout);
delayTime = 10;
checkForChanges();
workerPromises[e.data.id]();
delete workerPromises[e.data.id];
};
markedWorker.onerror = markedWorker.onmessageerror = (err) => {
clearTimeout(markedWorker.timeout);
let error = 'There was an error in the Worker';
if (err) {
if (err.message) {
error = err.message;
} else {
error = err;
}
}
error = error.replace(/^Uncaught Error: /, '');
$previewElem.classList.add('error');
$htmlElem.classList.add('error');
$lexerElem.classList.add('error');
setParsed(error, error);
setScrollPercent(0);
};
}
if (message.task !== 'defaults') {
markedWorker.working = true;
workerTimeout(0);
}
return new Promise((resolve) => {
message.id = uniqueWorkerMessageId();
workerPromises[message.id] = resolve;
markedWorker.postMessage(message);
});
}
function uniqueWorkerMessageId() {
let id;
do {
id = Math.random().toString(36);
} while (id in workerPromises);
return id;
}
function workerTimeout(seconds) {
markedWorker.timeout = setTimeout(() => {
seconds++;
markedWorker.onerror(
'Marked has taken longer than '
+ seconds
+ ' second'
+ (seconds > 1 ? 's' : '')
+ ' to respond...',
);
workerTimeout(seconds);
}, 1000);
}
================================================
FILE: docs/demo/index.html
================================================
<!doctype html>
<html lang="en">
<head>
<title>Marked Demo</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Prevent dark mode flash by applying theme before first paint -->
<script>
(function () {
try {
var STORAGE_KEY = "theme-preference";
var LEGACY_KEY = "theme";
var stored = localStorage.getItem(STORAGE_KEY) || localStorage.getItem(LEGACY_KEY);
var preference = stored === "dark" || stored === "light" || stored === "system" ? stored : "system";
var prefersDark =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches;
var shouldUseDark = prefersDark;
if (preference === "dark") {
shouldUseDark = true;
} else if (preference === "light") {
shouldUseDark = false;
}
if (shouldUseDark) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
document.documentElement.setAttribute("data-theme-preference", preference);
document.documentElement.setAttribute(
"data-theme",
shouldUseDark ? "dark" : "light",
);
localStorage.setItem(STORAGE_KEY, preference);
if (preference === "system") {
localStorage.removeItem(LEGACY_KEY);
} else {
localStorage.setItem(LEGACY_KEY, preference);
}
} catch (e) {}
})();
</script>
<link rel="stylesheet" href="./demo.css" type="text/css" />
<link rel="stylesheet" href="../css/shared.css" type="text/css" />
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<link rel="stylesheet" href="../css/hljs-github.css" type="text/css" />
<link rel="stylesheet" href="../css/hljs-github-dark.css" type="text/css" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
</head>
<body>
<a href="https://github.com/markedjs/marked" class="github-corner" aria-label="View source on Github">
<svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
</svg>
</a>
<header>
<a href="../" class="logo-link">
<img src="../img/logo-black.svg" height="50px" width="50px" alt="Marked Logo" />
</a>
<h1>Marked Demo</h1>
<div class="other-demos">
<a href="https://spec.commonmark.org/dingus/">CommonMark Demo</a>
<span class="separator">·</span>
<a href="https://daringfireball.net/projects/markdown/dingus">Daring Fireball Demo</a>
</div>
<button id="theme-toggle" class="theme-toggle" data-theme-mode="system" aria-label="Switch theme">
<span class="material-icons" data-theme-icon>brightness_auto</span>
<span class="text" data-theme-text>System</span>
</button>
</header>
<div id="loading">Loading...</div>
<div id="main">
<div class="containers">
<div class="container">
<div class="label">
<span>Input</span> ·
<a id="permalink">Permalink</a> ·
<span>Version: </span>
<select id="markedVersion">
<option value="master"selected>master</option>
</select> ·
<button id="clear">Clear</button>
<select id="inputType">
<option value="markdown">Markdown</option>
<option value="options">Options</option>
</select>
</div>
<textarea id="markdown" class="inputPane"></textarea>
<textarea id="options" class="inputPane" placeholder="Options (as JSON)"></textarea>
</div>
<div class="container">
<div class="label">
<select id="outputType">
<option value="preview">Preview</option>
<option value="html">HTML Source</option>
<option value="lexer">Lexer Data</option>
<option value="quickref">Quick Reference</option>
</select> ·
Response Time:
<span id="responseTime"></span>
</div>
<div id="preview" class="pane">
<noscript>
<h2>You'll need to enable Javascript to use this tool.</h2>
</noscript>
<iframe src="./preview.html" frameborder="0" sandbox="allow-same-origin allow-top-navigation-by-user-activation"></iframe>
</div>
<textarea id="html" class="pane" readonly="readonly"></textarea>
<textarea id="lexer" class="pane" readonly="readonly"></textarea>
<textarea id="quickref" class="pane" readonly="readonly"></textarea>
</div>
</div>
</div>
<script src="../js/index.js"></script>
<script src="./demo.js" type="module"></script>
</body>
</html>
================================================
FILE: docs/demo/initial.md
================================================
Marked - Markdown Parser
========================
[Marked] lets you convert [Markdown] into HTML. Markdown is a simple text format whose goal is to be very easy to read and write, even when not converted to HTML. This demo page will let you type anything you like and see how it gets converted. Live. No more waiting around.
How To Use The Demo
-------------------
1. Type in stuff on the left.
2. See the live updates on the right.
That's it. Pretty simple. There's also a drop-down option above to switch between various views:
- **Preview:** A live display of the generated HTML as it would render in a browser.
- **HTML Source:** The generated HTML before your browser makes it pretty.
- **Lexer Data:** What [marked] uses internally, in case you like gory stuff like this.
- **Quick Reference:** A brief run-down of how to format things using markdown.
Why Markdown?
-------------
It's easy. It's not overly bloated, unlike HTML. Also, as the creator of [markdown] says,
> The overriding design goal for Markdown's
> formatting syntax is to make it as readable
> as possible. The idea is that a
> Markdown-formatted document should be
> publishable as-is, as plain text, without
> looking like it's been marked up with tags
> or formatting instructions.
Ready to start writing? Either start changing stuff on the left or
[clear everything](/demo/?text=) with a simple click.
[Marked]: https://github.com/markedjs/marked/
[Markdown]: http://daringfireball.net/projects/markdown/
================================================
FILE: docs/demo/preview.html
================================================
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>marked.js preview</title>
<script>
(function () {
try {
var STORAGE_KEY = "theme-preference";
var LEGACY_KEY = "theme";
var stored = localStorage.getItem(STORAGE_KEY) || localStorage.getItem(LEGACY_KEY);
var preference = stored === "dark" || stored === "light" || stored === "system" ? stored : "system";
var prefersDark =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches;
var shouldUseDark = prefersDark;
if (preference === "dark") {
shouldUseDark = true;
} else if (preference === "light") {
shouldUseDark = false;
}
if (shouldUseDark) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
document.documentElement.setAttribute("data-theme-preference", preference);
document.documentElement.setAttribute(
"data-theme",
shouldUseDark ? "dark" : "light",
);
localStorage.setItem(STORAGE_KEY, preference);
if (preference === "system") {
localStorage.removeItem(LEGACY_KEY);
} else {
localStorage.setItem(LEGACY_KEY, preference);
}
} catch (e) {}
})();
</script>
<link rel="stylesheet" href="./demo.css" />
<link rel="stylesheet" href="../css/style.css" />
<link rel="stylesheet" href="../css/hljs-github.css" />
<link rel="stylesheet" href="../css/hljs-github-dark.css" />
<base target="_parent">
<style>
html, body {
margin: 0;
padding: 0;
background: #FFFFFF;
color: #1F2937;
font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 1.6;
transition: background-color 0.3s ease, color 0.3s ease;
}
html.dark, html.dark body {
background: #1F2937;
color: #F9FAFB;
}
/* Ensure links are visible in dark mode */
html.dark a {
color: #60A5FA;
}
html.dark a:hover {
color: #93C5FD;
}
/* Code blocks in dark mode */
html.dark pre {
background-color: #111827 !important;
color: #F9FAFB;
}
html.dark code {
background-color: #111827;
color: #F9FAFB;
}
/* Tables in dark mode */
html.dark table {
border-color: #374151;
}
html.dark th,
html.dark td {
border-color: #374151;
}
</style>
</head>
<body>
</body>
</html>
================================================
FILE: docs/demo/quickref.md
================================================
Markdown Quick Reference
========================
This guide is a very brief overview, with examples, of the syntax that [Markdown] supports. It is itself written in Markdown and you can copy the samples over to the left-hand pane for experimentation. It's shown as *text* and not *rendered HTML*.
[Markdown]: http://daringfireball.net/projects/markdown/
Simple Text Formatting
======================
First thing is first. You can use *stars* or _underscores_ for italics. **Double stars** and __double underscores__ for bold. ***Three together*** for ___both___.
Paragraphs are pretty easy too. Just have a blank line between chunks of text.
> This chunk of text is in a block quote. Its multiple lines will all be
> indented a bit from the rest of the text.
>
> > Multiple levels of block quotes also work.
Sometimes you want to include code, such as when you are explaining how `<h1>` HTML tags work, or maybe you are a programmer and you are discussing `someMethod()`.
If you want to include code and have new
lines preserved, indent the line with a tab
or at least four spaces:
Extra spaces work here too.
This is also called preformatted text and it is useful for showing examples.
The text will stay as text, so any *markdown* or <u>HTML</u> you add will
not show up formatted. This way you can show markdown examples in a
markdown document.
> You can also use preformatted text with your blockquotes
> as long as you add at least five spaces.
Headings
========
There are a couple of ways to make headings. Using three or more equals signs on a line under a heading makes it into an "h1" style. Three or more hyphens under a line makes it "h2" (slightly smaller). You can also use multiple pound symbols (`#`) before and after a heading. Pounds after the title are ignored. Here are some examples:
This is H1
==========
This is H2
----------
# This is H1
## This is H2
### This is H3 with some extra pounds ###
#### You get the idea ####
##### I don't need extra pounds at the end
###### H6 is the max
Links
=====
Let's link to a few sites. First, let's use the bare URL, like <https://www.github.com>. Great for text, but ugly for HTML.
Next is an inline link to [Google](https://www.google.com). A little nicer.
This is a reference-style link to [Wikipedia] [1].
Lastly, here's a pretty link to [Yahoo]. The reference-style and pretty links both automatically use the links defined below, but they could be defined *anywhere* in the markdown and are removed from the HTML. The names are also case insensitive, so you can use [YaHoO] and have it link properly.
[1]: https://www.wikipedia.org
[Yahoo]: https://www.yahoo.com
Title attributes may be added to links by adding text after a link.
This is the [inline link](https://www.bing.com "Bing") with a "Bing" title.
You can also go to [W3C] [2] and maybe visit a [friend].
[2]: https://w3c.org (The W3C puts out specs for web-based things)
[Friend]: https://facebook.com "Facebook!"
Email addresses in plain text are not linked: test@example.com.
Email addresses wrapped in angle brackets are linked: <test@example.com>.
They are also obfuscated so that email harvesting spam robots hopefully won't get them.
Lists
=====
* This is a bulleted list
* Great for shopping lists
- You can also use hyphens
+ Or plus symbols
The above is an "unordered" list. Now, on for a bit of order.
1. Numbered lists are also easy
2. Just start with a number
3738762. However, the actual number doesn't matter when converted to HTML.
1. This will still show up as 4.
You might want a few advanced lists:
- This top-level list is wrapped in paragraph tags
- This generates an extra space between each top-level item.
- You do it by adding a blank line
- This nested list also has blank lines between the list items.
- How to create nested lists
1. Start your regular list
2. Indent nested lists with two spaces
3. Further nesting means you should indent with two more spaces
* This line is indented with four spaces.
- List items can be quite lengthy. You can keep typing and either continue
them on the next line with no indentation.
- Alternately, if that looks ugly, you can also
indent the next line a bit for a prettier look.
- You can put large blocks of text in your list by just indenting with two spaces.
This is formatted the same as code, but you can inspect the HTML
and find that it's just wrapped in a `<p>` tag and *won't* be shown
as preformatted text.
You can keep adding more and more paragraphs to a single
list item by adding the traditional blank line and then keep
on indenting the paragraphs with two spaces.
You really only need to indent the first line,
but that looks ugly.
- Lists support blockquotes
> Just like this example here. By the way, you can
> nest lists inside blockquotes!
> - Fantastic!
- Lists support preformatted text
You just need to indent an additional four spaces.
Even More
=========
Horizontal Rule
---------------
If you need a horizontal rule you just need to put at least three hyphens, asterisks, or underscores on a line by themselves. You can also even put spaces between the characters.
---
****************************
_ _ _ _ _ _ _
Those three all produced horizontal lines. Keep in mind that three hyphens under any text turns that text into a heading, so add a blank like if you use hyphens.
Images
------
Images work exactly like links, but they have exclamation points in front. They work with references and titles too.
 and ![Happy].
[Happy]: https://wpclipart.com/smiley/happy/simple_colors/smiley_face_simple_green_small.png ("Smiley face")
Inline HTML
-----------
If markdown is too limiting, you can just insert your own <strike>crazy</strike> HTML. Span-level HTML <u>can *still* use markdown</u>. Block level elements must be separated from text by a blank line and must not have any spaces before the opening and closing HTML.
<div style='font-family: "Comic Sans MS", "Comic Sans", cursive;'>
It is a pity, but markdown does **not** work in here for most markdown parsers.
[Marked] handles it pretty well.
</div>
================================================
FILE: docs/demo/worker.js
================================================
const versionCache = {};
let currentVersion;
onunhandledrejection = (e) => {
throw e.reason;
};
onmessage = function(e) {
if (e.data.version === currentVersion) {
parse(e);
} else {
loadVersion(e.data.version).then(() => {
parse(e);
});
}
};
function getDefaults() {
const marked = versionCache[currentVersion];
let defaults = {};
if (typeof marked.getDefaults === 'function') {
defaults = marked.getDefaults();
delete defaults.renderer;
} else if ('defaults' in marked) {
for (const prop in marked.defaults) {
if (prop !== 'renderer') {
defaults[prop] = marked.defaults[prop];
}
}
}
return defaults;
}
function mergeOptions(options) {
const defaults = getDefaults();
const opts = {};
const invalidOptions = [
'renderer',
'tokenizer',
'walkTokens',
'extensions',
'highlight',
'sanitizer',
];
for (const prop in defaults) {
opts[prop] = invalidOptions.includes(prop) || !(prop in options)
? defaults[prop]
: options[prop];
}
return opts;
}
function parse(e) {
switch (e.data.task) {
case 'defaults': {
postMessage({
id: e.data.id,
task: e.data.task,
defaults: getDefaults(),
});
break;
}
case 'parse': {
const marked = versionCache[currentVersion];
// marked 0.0.1 had tokens array as the second parameter of lexer and no options
const options = currentVersion.endsWith('@0.0.1') ? [] : mergeOptions(e.data.options);
const startTime = new Date();
const lexed = marked.lexer(e.data.markdown, options);
const lexedList = jsonString(lexed);
const parsed = marked.parser(lexed, options);
const endTime = new Date();
postMessage({
id: e.data.id,
task: e.data.task,
lexed: lexedList,
parsed,
time: endTime - startTime,
});
break;
}
}
}
function jsonString(input, level) {
level = level || 0;
if (Array.isArray(input)) {
if (input.length === 0) {
return '[]';
}
const items = [];
let i;
if (!Array.isArray(input[0]) && typeof input[0] === 'object' && input[0] !== null) {
for (i = 0; i < input.length; i++) {
items.push(' '.repeat(2 * level) + jsonString(input[i], level + 1));
}
return '[\n' + items.join('\n') + '\n]';
}
for (i = 0; i < input.length; i++) {
items.push(jsonString(input[i], level));
}
return '[' + items.join(', ') + ']';
} else if (typeof input === 'object' && input !== null) {
const props = [];
for (const prop in input) {
props.push(prop + ':' + jsonString(input[prop], level));
}
return '{' + props.join(', ') + '}';
} else {
return JSON.stringify(input);
}
}
function fetchMarked(file) {
return () =>
fetch(file)
.then((res) => res.text())
.then((text) => {
const g = globalThis || global;
g.module = { };
try {
// eslint-disable-next-line no-new-func
Function(text)();
} catch {
throw new Error(`Cannot find ${file}`);
}
const marked = g.marked || g.module.exports;
return marked;
});
}
function loadVersion(ver) {
let promise;
if (versionCache[ver]) {
promise = Promise.resolve();
} else {
promise = import(ver + '/lib/marked.esm.js')
.catch(fetchMarked(ver + '/marked.min.js'))
.catch(fetchMarked(ver + '/lib/marked.umd.js'))
.catch(fetchMarked(ver + '/lib/marked.js'))
.then((marked) => {
if (!marked) {
throw Error('No marked');
} else if (marked.marked) {
versionCache[ver] = marked.marked;
} else if (marked.default) {
versionCache[ver] = marked.default;
} else if (marked.lexer && marked.parser) {
versionCache[ver] = marked;
} else {
throw new Error('Cannot find marked');
}
});
}
return promise.then(() => {
currentVersion = ver;
}).catch((err) => {
console.error(err);
throw new Error('Cannot load that version of marked');
});
}
================================================
FILE: docs/js/index.js
================================================
document.addEventListener('DOMContentLoaded', function() {
// --- Theme Toggling ---
const themeToggle = document.getElementById('theme-toggle');
const themeToggleIcon = themeToggle ? themeToggle.querySelector('[data-theme-icon]') : null;
const themeToggleText = themeToggle ? themeToggle.querySelector('[data-theme-text]') : null;
const THEME_STORAGE_KEY = 'theme-preference';
const LEGACY_STORAGE_KEY = 'theme';
const THEME_ORDER = ['system', 'light', 'dark'];
const TOGGLE_UI = {
system: { icon: 'brightness_auto', text: 'System' },
light: { icon: 'light_mode', text: 'Light' },
dark: { icon: 'dark_mode', text: 'Dark' },
};
function applyTheme(theme) {
if (theme === 'dark') {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
document.documentElement.setAttribute('data-theme', theme);
}
function getSystemTheme() {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
return 'dark';
}
return 'light';
}
function sanitisePreference(value) {
return THEME_ORDER.includes(value) ? value : null;
}
function readStoredPreference() {
try {
const stored = sanitisePreference(localStorage.getItem(THEME_STORAGE_KEY));
if (stored) {
return stored;
}
return sanitisePreference(localStorage.getItem(LEGACY_STORAGE_KEY));
} catch {
return null;
}
}
function writeStoredPreference(preference) {
try {
localStorage.setItem(THEME_STORAGE_KEY, preference);
if (preference === 'light' || preference === 'dark') {
localStorage.setItem(LEGACY_STORAGE_KEY, preference);
} else {
localStorage.removeItem(LEGACY_STORAGE_KEY);
}
} catch {
// Storage might be unavailable; ignore
}
}
function getEffectiveTheme(preference) {
return preference === 'system' ? getSystemTheme() : preference;
}
function updateToggle(preference) {
if (!themeToggle) {
return;
}
const details = TOGGLE_UI[preference] || TOGGLE_UI.system;
if (themeToggleIcon) {
themeToggleIcon.textContent = details.icon;
}
if (themeToggleText) {
themeToggleText.textContent = details.text;
}
themeToggle.setAttribute('data-theme-mode', preference);
const label = `Switch theme (current: ${details.text})`;
themeToggle.setAttribute('aria-label', label);
themeToggle.title = label;
}
let currentPreference = readStoredPreference() || 'system';
function applyPreference(preference, persist) {
currentPreference = preference;
const effectiveTheme = getEffectiveTheme(preference);
applyTheme(effectiveTheme);
document.documentElement.setAttribute('data-theme-preference', preference);
updateToggle(preference);
if (persist) {
writeStoredPreference(preference);
}
}
applyPreference(currentPreference, true);
if (themeToggle) {
themeToggle.addEventListener('click', function() {
const index = THEME_ORDER.indexOf(currentPreference);
const nextIndex = index === -1 ? 0 : (index + 1) % THEME_ORDER.length;
const nextPreference = THEME_ORDER[nextIndex];
applyPreference(nextPreference, true);
});
}
const systemMatcher = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
if (systemMatcher) {
const handleSystemChange = function() {
if (currentPreference === 'system') {
applyPreference('system', false);
}
};
if (typeof systemMatcher.addEventListener === 'function') {
systemMatcher.addEventListener('change', handleSystemChange);
} else if (typeof systemMatcher.addListener === 'function') {
systemMatcher.addListener(handleSystemChange);
}
}
// --- Copy-to-Clipboard Button ---
const allPres = document.querySelectorAll('pre');
allPres.forEach(function(pre) {
let timeout = null;
const copyButton = document.createElement('button');
copyButton.className =
'absolute top-2 right-2 p-2 rounded-md bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 opacity-0 group-hover:opacity-100 transition-opacity';
copyButton.innerHTML =
'<span class="material-icons text-sm">content_copy</span>';
copyButton.setAttribute('aria-label', 'Copy to clipboard');
pre.classList.add('group', 'relative'); // Add group for hover effect
pre.appendChild(copyButton);
copyButton.onclick = function() {
// Exclude the button's own text from being copied
const code = pre.querySelector('code').innerText;
navigator.clipboard.writeText(code);
copyButton.innerHTML = '<span class="material-icons text-sm">done</span>';
clearTimeout(timeout);
timeout = setTimeout(function() {
copyButton.innerHTML =
'<span class="material-icons text-sm">content_copy</span>';
}, 2000);
};
});
// --- LEGACY URL Redirect ---
const match = /#\/(.+)\\.md(.*)/g.exec(window.location.hash);
if (match && match[1]) {
const pageName = match[1].toLowerCase();
const sectionName = match[2];
window.location.href = '/' + pageName + sectionName;
}
// --- Mobile Menu Toggle ---
const mobileMenuToggle = document.getElementById('mobile-menu-toggle');
const sidebar = document.getElementById('sidebar');
const mobileOverlay = document.getElementById('mobile-overlay');
const body = document.body;
function openMobileMenu() {
sidebar.classList.add('mobile-open');
mobileOverlay.classList.add('active');
body.classList.add('mobile-menu-open');
mobileMenuToggle.setAttribute('aria-expanded', 'true');
}
function closeMobileMenu() {
sidebar.classList.remove('mobile-open');
mobileOverlay.classList.remove('active');
body.classList.remove('mobile-menu-open');
mobileMenuToggle.setAttribute('aria-expanded', 'false');
}
if (mobileMenuToggle) {
mobileMenuToggle.addEventListener('click', function() {
const isOpen = sidebar.classList.contains('mobile-open');
if (isOpen) {
closeMobileMenu();
} else {
openMobileMenu();
}
});
}
if (mobileOverlay) {
mobileOverlay.addEventListener('click', closeMobileMenu);
}
// Close mobile menu when clicking a navigation link
if (sidebar) {
const sidebarLinks = sidebar.querySelectorAll('a');
sidebarLinks.forEach(function(link) {
link.addEventListener('click', function() {
// Only close on mobile/tablet (up to 1024px)
if (window.innerWidth <= 1024) {
closeMobileMenu();
}
});
});
}
// Close mobile menu on window resize to desktop size
window.addEventListener('resize', function() {
if (window.innerWidth > 1024) {
closeMobileMenu();
}
});
});
================================================
FILE: esbuild.config.js
================================================
import * as esbuild from 'esbuild';
import { umdWrapper } from 'esbuild-plugin-umd-wrapper';
import fs from 'fs';
const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(fs.readFileSync('./package.json')).version;
console.log('building version:', version);
const banner = `/**
* marked v${version} - a markdown parser
* Copyright (c) 2018-${new Date().getFullYear()}, MarkedJS. (MIT License)
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
* https://github.com/markedjs/marked
*/
/**
* DO NOT EDIT THIS FILE
* The code in this file is generated from files in ./src/
*/
`;
function config(options) {
return {
entryPoints: ['src/marked.ts'],
banner: {
js: banner,
},
sourcemap: true,
bundle: true,
minify: true,
...(options.format === 'umd'
? {
plugins: [umdWrapper({
libraryName: 'marked',
})],
}
: {}),
...options,
};
}
await esbuild.build(config({
format: 'esm',
outfile: 'lib/marked.esm.js',
}));
await esbuild.build(config({
format: 'umd',
outfile: 'lib/marked.umd.js',
}));
================================================
FILE: eslint.config.js
================================================
import markedEslintConfig from '@markedjs/eslint-config';
export default [
{
ignores: ['**/lib', '**/public', 'test.js', 'vuln.js'],
},
...markedEslintConfig,
];
================================================
FILE: man/marked.1.md
================================================
# marked(1) -- a javascript markdown parser
## SYNOPSIS
`marked` [`-o` <output file>] [`-i` <input file>] [`-s` <markdown string>] [`-c` <config file>] [`--help`] [`--version`] [`--tokens`] [`--no-clobber`] [`--pedantic`] [`--gfm`] [`--breaks`] [`--no-etc...`] [`--silent`] [filename]
## DESCRIPTION
marked is a full-featured javascript markdown parser, built for speed.
It also includes multiple GFM features.
## EXAMPLES
```sh
cat in.md | marked > out.html
```
```sh
echo "hello *world*" | marked
```
```sh
marked -o out.html -i in.md --gfm
```
```sh
marked --output="hello world.html" -i in.md --no-breaks
```
## OPTIONS
* -o, --output [output file]
Specify file output. If none is specified, write to stdout.
* -i, --input [input file]
Specify file input, otherwise use last argument as input file.
If no input file is specified, read from stdin.
* -s, --string [markdown string]
Specify string input instead of a file.
* -c, --config [config file]
Specify config file to use instead of the default `~/.marked.json` or `~/.marked.js` or `~/.marked/index.js`.
* -t, --tokens
Output a token list instead of html.
* -n, --no-clobber
Do not overwrite `output` if it exists.
* --pedantic
Conform to obscure parts of markdown.pl as much as possible.
Don't fix original markdown bugs.
* --gfm
Enable github flavored markdown.
* --breaks
Enable GFM line breaks. Only
gitextract_6red701u/ ├── .devcontainer/ │ └── devcontainer.json ├── .editorconfig ├── .gitattributes ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── Bug_report.md │ │ ├── Feature_request.md │ │ └── Proposal.md │ ├── ISSUE_TEMPLATE.md │ ├── PULL_REQUEST_TEMPLATE/ │ │ └── badges.md │ ├── PULL_REQUEST_TEMPLATE.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-dark.css │ │ ├── hljs-github.css │ │ ├── shared.css │ │ └── style.css │ ├── demo/ │ │ ├── demo.css │ │ ├── demo.js │ │ ├── index.html │ │ ├── initial.md │ │ ├── preview.html │ │ ├── quickref.md │ │ └── worker.js │ └── js/ │ └── index.js ├── esbuild.config.js ├── eslint.config.js ├── man/ │ └── marked.1.md ├── 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.ts │ ├── 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 │ │ │ ├── angle_brackets.html │ │ │ ├── angle_brackets.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 │ │ │ ├── backtick_precedence.html │ │ │ ├── backtick_precedence.md │ │ │ ├── backticks_in_links.html │ │ │ ├── backticks_in_links.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_flanking.html │ │ │ ├── del_flanking.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_link_brackets.html │ │ │ ├── em_link_brackets.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 │ │ │ ├── emoji_strikethrough.html │ │ │ ├── emoji_strikethrough.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_newline.html │ │ │ ├── escape_newline.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_alt.html │ │ │ ├── image_alt.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_empty.html │ │ │ ├── list_item_empty.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 │ │ │ ├── list_wrong_indent.html │ │ │ ├── list_wrong_indent.md │ │ │ ├── multiple_sub_lists.html │ │ │ ├── multiple_sub_lists.md │ │ │ ├── nbsp_following_tables.html │ │ │ ├── nbsp_following_tables.md │ │ │ ├── nested_blockquote_in_list.html │ │ │ ├── nested_blockquote_in_list.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 │ │ │ ├── tasklist_blocks.html │ │ │ ├── tasklist_blocks.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/ │ │ ├── backticks_alternating_in_link.html │ │ ├── backticks_alternating_in_link.md │ │ ├── backticks_in_link_label.html │ │ ├── backticks_in_link_label.md │ │ ├── cubic_def.cjs │ │ ├── cubic_link_title.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
SYMBOL INDEX (353 symbols across 33 files)
FILE: api/dingus.js
function dingus (line 7) | function dingus(req, res) {
FILE: bin/main.js
function main (line 21) | async function main(nodeProcess) {
FILE: docs/build.js
function convertTestsToTable (line 21) | function convertTestsToTable(name, tests) {
function init (line 47) | async function init() {
function build (line 83) | async function build(currentDir, tmpl, testResultsTable) {
FILE: docs/demo/demo.js
constant THEME_STORAGE_KEY (line 58) | const THEME_STORAGE_KEY = 'theme-preference';
constant LEGACY_STORAGE_KEY (line 59) | const LEGACY_STORAGE_KEY = 'theme';
constant THEME_ORDER (line 60) | const THEME_ORDER = ['system', 'light', 'dark'];
constant TOGGLE_UI (line 61) | const TOGGLE_UI = {
function applyTheme (line 67) | function applyTheme(theme) {
function getSystemTheme (line 88) | function getSystemTheme() {
function sanitisePreference (line 95) | function sanitisePreference(value) {
function readStoredPreference (line 99) | function readStoredPreference() {
function writeStoredPreference (line 111) | function writeStoredPreference(preference) {
function getEffectiveTheme (line 124) | function getEffectiveTheme(preference) {
function updateToggle (line 128) | function updateToggle(preference) {
function applyPreference (line 147) | function applyPreference(preference, persist) {
function setInitialText (line 204) | function setInitialText() {
function setInitialQuickref (line 218) | function setInitialQuickref() {
function setInitialVersion (line 226) | function setInitialVersion() {
function setInitialOptions (line 255) | function setInitialOptions() {
function setInitialOutputType (line 263) | function setInitialOutputType() {
function handleIframeLoad (line 269) | function handleIframeLoad() {
function handleInput (line 290) | function handleInput() {
function handleVersionChange (line 294) | function handleVersionChange() {
function handleClearClick (line 298) | function handleClearClick() {
function handleInputChange (line 305) | function handleInputChange() {
function handleOutputChange (line 309) | function handleOutputChange() {
function handleChange (line 314) | function handleChange(panes, visiblePane) {
function setDefaultOptions (line 327) | function setDefaultOptions() {
function setOptions (line 334) | function setOptions(opts) {
function searchToObject (line 350) | function searchToObject() {
function getScrollSize (line 368) | function getScrollSize() {
function getScrollPercent (line 378) | function getScrollPercent() {
function setScrollPercent (line 392) | function setScrollPercent(percent) {
function updateLink (line 398) | function updateLink() {
function updateVersion (line 417) | function updateVersion() {
function checkForChanges (line 421) | function checkForChanges() {
function setResponseTime (line 454) | function setResponseTime(ms) {
function setParsed (line 476) | function setParsed(parsed, lexed) {
function messageWorker (line 485) | function messageWorker(message) {
function uniqueWorkerMessageId (line 546) | function uniqueWorkerMessageId() {
function workerTimeout (line 554) | function workerTimeout(seconds) {
FILE: docs/demo/worker.js
function getDefaults (line 18) | function getDefaults() {
function mergeOptions (line 34) | function mergeOptions(options) {
function parse (line 53) | function parse(e) {
function jsonString (line 84) | function jsonString(input, level) {
function fetchMarked (line 113) | function fetchMarked(file) {
function loadVersion (line 131) | function loadVersion(ver) {
FILE: docs/js/index.js
function applyTheme (line 16) | function applyTheme(theme) {
function getSystemTheme (line 25) | function getSystemTheme() {
function sanitisePreference (line 32) | function sanitisePreference(value) {
function readStoredPreference (line 36) | function readStoredPreference() {
function writeStoredPreference (line 48) | function writeStoredPreference(preference) {
function getEffectiveTheme (line 61) | function getEffectiveTheme(preference) {
function updateToggle (line 65) | function updateToggle(preference) {
function applyPreference (line 84) | function applyPreference(preference, persist) {
function openMobileMenu (line 165) | function openMobileMenu() {
function closeMobileMenu (line 172) | function closeMobileMenu() {
FILE: esbuild.config.js
function config (line 22) | function config(options) {
FILE: src/Hooks.ts
class _Hooks (line 7) | class _Hooks<ParserOutput = string, RendererOutput = string> {
method constructor (line 11) | constructor(options?: MarkedOptions<ParserOutput, RendererOutput>) {
method preprocess (line 31) | preprocess(markdown: string) {
method postprocess (line 38) | postprocess(html: ParserOutput) {
method processAllTokens (line 45) | processAllTokens(tokens: Token[] | TokensList) {
method emStrongMask (line 52) | emStrongMask(src: string) {
method provideLexer (line 59) | provideLexer() {
method provideParser (line 66) | provideParser() {
FILE: src/Instance.ts
type MaybePromise (line 12) | type MaybePromise = void | Promise<void>;
type UnknownFunction (line 14) | type UnknownFunction = (...args: unknown[]) => unknown;
type GenericRendererFunction (line 15) | type GenericRendererFunction = (...args: unknown[]) => string | false;
class Marked (line 17) | class Marked<ParserOutput = string, RendererOutput = string> {
method constructor (line 31) | constructor(...args: MarkedExtension<ParserOutput, RendererOutput>[]) {
method walkTokens (line 38) | walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => M...
method use (line 76) | use(...args: MarkedExtension<ParserOutput, RendererOutput>[]) {
method setOptions (line 262) | setOptions(opt: MarkedOptions<ParserOutput, RendererOutput>) {
method lexer (line 267) | lexer(src: string, options?: MarkedOptions<ParserOutput, RendererOutpu...
method parser (line 271) | parser(tokens: Token[], options?: MarkedOptions<ParserOutput, Renderer...
method parseMarkdown (line 275) | private parseMarkdown(blockType: boolean) {
method onError (line 349) | private onError(silent: boolean, async: boolean) {
FILE: src/Lexer.ts
class _Lexer (line 10) | class _Lexer<ParserOutput = string, RendererOutput = string> {
method constructor (line 23) | constructor(options?: MarkedOptions<ParserOutput, RendererOutput>) {
method rules (line 62) | static get rules() {
method lex (line 72) | static lex<ParserOutput = string, RendererOutput = string>(src: string...
method lexInline (line 80) | static lexInline<ParserOutput = string, RendererOutput = string>(src: ...
method lex (line 88) | lex(src: string) {
method blockTokens (line 107) | blockTokens(src: string, tokens: Token[] = [], lastParagraphClipped = ...
method inline (line 291) | inline(src: string, tokens: Token[] = []) {
method inlineTokens (line 299) | inlineTokens(src: string, tokens: Token[] = []): Token[] {
FILE: src/MarkedOptions.ts
type TokenizerThis (line 8) | interface TokenizerThis {
type TokenizerExtensionFunction (line 12) | type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tok...
type TokenizerStartFunction (line 14) | type TokenizerStartFunction = (this: TokenizerThis, src: string) => numb...
type TokenizerExtension (line 16) | interface TokenizerExtension {
type RendererThis (line 24) | interface RendererThis<ParserOutput = string, RendererOutput = string> {
type RendererExtensionFunction (line 28) | type RendererExtensionFunction<ParserOutput = string, RendererOutput = s...
type RendererExtension (line 30) | interface RendererExtension<ParserOutput = string, RendererOutput = stri...
type TokenizerAndRendererExtension (line 35) | type TokenizerAndRendererExtension<ParserOutput = string, RendererOutput...
type HooksApi (line 37) | type HooksApi<ParserOutput = string, RendererOutput = string> = Omit<_Ho...
type HooksObject (line 38) | type HooksObject<ParserOutput = string, RendererOutput = string> = {
type RendererApi (line 42) | type RendererApi<ParserOutput = string, RendererOutput = string> = Omit<...
type RendererObject (line 43) | type RendererObject<ParserOutput = string, RendererOutput = string> = {
type TokenizerApi (line 47) | type TokenizerApi<ParserOutput = string, RendererOutput = string> = Omit...
type TokenizerObject (line 48) | type TokenizerObject<ParserOutput = string, RendererOutput = string> = {
type MarkedExtension (line 52) | interface MarkedExtension<ParserOutput = string, RendererOutput = string> {
type MarkedOptions (line 117) | interface MarkedOptions<ParserOutput = string, RendererOutput = string> ...
FILE: src/Parser.ts
class _Parser (line 10) | class _Parser<ParserOutput = string, RendererOutput = string> {
method constructor (line 14) | constructor(options?: MarkedOptions<ParserOutput, RendererOutput>) {
method parse (line 26) | static parse<ParserOutput = string, RendererOutput = string>(tokens: T...
method parseInline (line 34) | static parseInline<ParserOutput = string, RendererOutput = string>(tok...
method parse (line 42) | parse(tokens: Token[]): ParserOutput {
method parseInline (line 128) | parseInline(tokens: Token[], renderer: _Renderer<ParserOutput, Rendere...
FILE: src/Renderer.ts
class _Renderer (line 14) | class _Renderer<ParserOutput = string, RendererOutput = string> {
method constructor (line 17) | constructor(options?: MarkedOptions<ParserOutput, RendererOutput>) {
method space (line 21) | space(token: Tokens.Space): RendererOutput {
method code (line 25) | code({ text, lang, escaped }: Tokens.Code): RendererOutput {
method blockquote (line 43) | blockquote({ tokens }: Tokens.Blockquote): RendererOutput {
method html (line 48) | html({ text }: Tokens.HTML | Tokens.Tag): RendererOutput {
method def (line 52) | def(token: Tokens.Def): RendererOutput {
method heading (line 56) | heading({ tokens, depth }: Tokens.Heading): RendererOutput {
method hr (line 60) | hr(token: Tokens.Hr): RendererOutput {
method list (line 64) | list(token: Tokens.List): RendererOutput {
method listitem (line 79) | listitem(item: Tokens.ListItem): RendererOutput {
method checkbox (line 83) | checkbox({ checked }: Tokens.Checkbox): RendererOutput {
method paragraph (line 89) | paragraph({ tokens }: Tokens.Paragraph): RendererOutput {
method table (line 93) | table(token: Tokens.Table): RendererOutput {
method tablerow (line 124) | tablerow({ text }: Tokens.TableRow<ParserOutput>): RendererOutput {
method tablecell (line 128) | tablecell(token: Tokens.TableCell): RendererOutput {
method strong (line 140) | strong({ tokens }: Tokens.Strong): RendererOutput {
method em (line 144) | em({ tokens }: Tokens.Em): RendererOutput {
method codespan (line 148) | codespan({ text }: Tokens.Codespan): RendererOutput {
method br (line 152) | br(token: Tokens.Br): RendererOutput {
method del (line 156) | del({ tokens }: Tokens.Del): RendererOutput {
method link (line 160) | link({ href, title, tokens }: Tokens.Link): RendererOutput {
method image (line 175) | image({ href, title, text, tokens }: Tokens.Image): RendererOutput {
method text (line 193) | text(token: Tokens.Text | Tokens.Escape): RendererOutput {
FILE: src/TextRenderer.ts
class _TextRenderer (line 7) | class _TextRenderer<RendererOutput = string> {
method strong (line 9) | strong({ text }: Tokens.Strong): RendererOutput {
method em (line 13) | em({ text }: Tokens.Em): RendererOutput {
method codespan (line 17) | codespan({ text }: Tokens.Codespan): RendererOutput {
method del (line 21) | del({ text }: Tokens.Del): RendererOutput {
method html (line 25) | html({ text }: Tokens.HTML | Tokens.Tag): RendererOutput {
method text (line 29) | text({ text }: Tokens.Text | Tokens.Escape | Tokens.Tag): RendererOutp...
method link (line 33) | link({ text }: Tokens.Link): RendererOutput {
method image (line 37) | image({ text }: Tokens.Image): RendererOutput {
method br (line 41) | br(): RendererOutput {
method checkbox (line 45) | checkbox({ raw }: Tokens.Checkbox): RendererOutput {
FILE: src/Tokenizer.ts
function outputLink (line 13) | function outputLink(cap: string[], link: Pick<Tokens.Link, 'href' | 'tit...
function indentCodeCompensation (line 31) | function indentCodeCompensation(raw: string, text: string, rules: Rules) {
class _Tokenizer (line 62) | class _Tokenizer<ParserOutput = string, RendererOutput = string> {
method constructor (line 67) | constructor(options?: MarkedOptions<ParserOutput, RendererOutput>) {
method space (line 71) | space(src: string): Tokens.Space | undefined {
method code (line 81) | code(src: string): Tokens.Code | undefined {
method fences (line 96) | fences(src: string): Tokens.Code | undefined {
method heading (line 111) | heading(src: string): Tokens.Heading | undefined {
method hr (line 137) | hr(src: string): Tokens.Hr | undefined {
method blockquote (line 147) | blockquote(src: string): Tokens.Blockquote | undefined {
method list (line 231) | list(src: string): Tokens.List | undefined {
method html (line 481) | html(src: string): Tokens.HTML | undefined {
method def (line 495) | def(src: string): Tokens.Def | undefined {
method table (line 511) | table(src: string): Tokens.Table | undefined {
method lheading (line 574) | lheading(src: string): Tokens.Heading | undefined {
method paragraph (line 587) | paragraph(src: string): Tokens.Paragraph | undefined {
method text (line 602) | text(src: string): Tokens.Text | undefined {
method escape (line 614) | escape(src: string): Tokens.Escape | undefined {
method tag (line 625) | tag(src: string): Tokens.Tag | undefined {
method link (line 650) | link(src: string): Tokens.Link | Tokens.Image | undefined {
method reflink (line 711) | reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Token...
method emStrong (line 729) | emStrong(src: string, maskedSrc: string, prevChar = ''): Tokens.Em | T...
method codespan (line 799) | codespan(src: string): Tokens.Codespan | undefined {
method br (line 816) | br(src: string): Tokens.Br | undefined {
method del (line 826) | del(src: string, maskedSrc: string, prevChar = ''): Tokens.Del | undef...
method autolink (line 879) | autolink(src: string): Tokens.Link | undefined {
method url (line 907) | url(src: string): Tokens.Link | undefined {
method inlineText (line 944) | inlineText(src: string): Tokens.Text | undefined {
FILE: src/Tokens.ts
type MarkedToken (line 3) | type MarkedToken = (
type Token (line 28) | type Token = (
type Blockquote (line 33) | interface Blockquote {
type Br (line 40) | interface Br {
type Checkbox (line 45) | interface Checkbox {
type Code (line 51) | interface Code {
type Codespan (line 60) | interface Codespan {
type Def (line 66) | interface Def {
type Del (line 74) | interface Del {
type Em (line 81) | interface Em {
type Escape (line 88) | interface Escape {
type Generic (line 94) | interface Generic {
type Heading (line 102) | interface Heading {
type Hr (line 110) | interface Hr {
type HTML (line 115) | interface HTML {
type Image (line 123) | interface Image {
type Link (line 132) | interface Link {
type List (line 141) | interface List {
type ListItem (line 150) | interface ListItem {
type Paragraph (line 160) | interface Paragraph {
type Space (line 168) | interface Space {
type Strong (line 173) | interface Strong {
type Table (line 180) | interface Table {
type TableCell (line 188) | interface TableCell {
type TableRow (line 195) | interface TableRow<P = string> {
type Tag (line 199) | interface Tag {
type Text (line 208) | interface Text {
type Links (line 217) | type Links = Record<string, Pick<Tokens.Link | Tokens.Image, 'href' | 't...
type TokensList (line 219) | type TokensList = Token[] & {
FILE: src/defaults.ts
function _getDefaults (line 6) | function _getDefaults<ParserOutput = string, RendererOutput = string>():...
function changeDefaults (line 23) | function changeDefaults<ParserOutput = string, RendererOutput = string>(...
FILE: src/helpers.ts
function escapeHtmlEntities (line 15) | function escapeHtmlEntities(html: string, encode?: boolean) {
function cleanUrl (line 29) | function cleanUrl(href: string) {
function splitCells (line 38) | function splitCells(tableRow: string, count?: number) {
function rtrim (line 88) | function rtrim(str: string, c: string, invert?: boolean) {
function findClosingBracket (line 112) | function findClosingBracket(str: string, b: string) {
function expandTabs (line 137) | function expandTabs(line: string, indent = 0) {
FILE: src/marked.ts
function marked (line 38) | function marked(src: string, opt?: MarkedOptions | null): string | Promi...
FILE: src/rules.ts
function edit (line 3) | function edit(regex: string | RegExp, opt = '') {
type BlockKeys (line 189) | type BlockKeys = keyof typeof blockNormal;
type InlineKeys (line 433) | type InlineKeys = keyof typeof inlineNormal;
type Rules (line 500) | interface Rules {
FILE: test/bench.js
function load (line 12) | async function load() {
function runBench (line 27) | async function runBench(options) {
function bench (line 68) | async function bench(tests, specs) {
function parseArg (line 119) | function parseArg(argv) {
function camelize (line 189) | function camelize(text) {
function main (line 196) | async function main(argv) {
function prettyElapsedTime (line 206) | function prettyElapsedTime(hrtimeElapsed) {
FILE: test/recheck.ts
type RegexpObj (line 4) | interface RegexpObj {
function checkRegexp (line 8) | async function checkRegexp(obj: RegexpObj, name: string) {
FILE: test/rules.js
constant COLOR (line 4) | const COLOR = {
function propsToString (line 32) | function propsToString(obj) {
FILE: test/run-spec-tests.js
function parse (line 6) | function parse(markdown, options) {
FILE: test/types/marked.ts
class ExtendedRenderer (line 88) | class ExtendedRenderer extends marked.Renderer {
method heading (line 134) | heading({ tokens, depth }) {
method listitem (line 141) | listitem({ text, task, checked }) {
method heading (line 147) | heading(src) {
method codespan (line 161) | codespan(src) {
type NameToken (line 177) | interface NameToken extends Tokens.Generic {
method tokenizer (line 189) | tokenizer(src: string): NameToken | undefined {
method renderer (line 207) | renderer(t) {
method tokenizer (line 221) | tokenizer(src: string) {
method renderer (line 230) | renderer(token: Tokens.Generic) {
method walkTokens (line 245) | async walkTokens(token) {
method preprocess (line 326) | preprocess(markdown) {
method postprocess (line 332) | postprocess(html) {
method processAllTokens (line 339) | processAllTokens(tokens) {
method provideLexer (line 346) | provideLexer() {
method provideParser (line 349) | provideParser() {
method preprocess (line 357) | async preprocess(markdown) {
method postprocess (line 360) | async postprocess(html) {
method processAllTokens (line 363) | async processAllTokens(tokens) {
method html (line 404) | html() {
function parserNumber (line 408) | function parserNumber(tokens: Token[], options?: MarkedOptions<number, n...
method provideParser (line 411) | provideParser() { return parserNumber; }
FILE: test/unit/Hooks.test.js
function createHeadingToken (line 6) | function createHeadingToken(text) {
method preprocess (line 27) | preprocess(markdown) {
method preprocess (line 40) | async preprocess(markdown) {
method preprocess (line 55) | preprocess(markdown) {
method preprocess (line 69) | async preprocess(markdown) {
method postprocess (line 83) | postprocess(html) {
method postprocess (line 96) | async postprocess(html) {
method processAllTokens (line 111) | processAllTokens(tokens) {
method walkTokens (line 116) | walkTokens(token) {
method processAllTokens (line 131) | async processAllTokens(tokens) {
method walkTokens (line 137) | walkTokens(token) {
method preprocess (line 153) | preprocess(markdown) {
method postprocess (line 156) | postprocess(html) {
method processAllTokens (line 159) | processAllTokens(tokens) {
method preprocess (line 168) | preprocess(markdown) {
method postprocess (line 171) | async postprocess(html) {
method processAllTokens (line 175) | processAllTokens(tokens) {
method provideLexer (line 197) | provideLexer() {
method provideLexer (line 210) | provideLexer() {
method provideLexer (line 226) | async provideLexer() {
method provideLexer (line 242) | async provideLexer() {
method provideParser (line 258) | provideParser() {
method provideParser (line 270) | provideParser() {
method provideParser (line 283) | provideParser() {
method provideParser (line 299) | async provideParser() {
method provideParser (line 315) | async provideParser() {
FILE: test/unit/Lexer.test.js
function expectTokens (line 5) | function expectTokens({ md, options, tokens = [], links = {}, log = fals...
function expectInlineTokens (line 20) | function expectInlineTokens({ md, options, tokens, links = {} }) {
FILE: test/unit/Parser.test.js
function expectHtml (line 6) | async function expectHtml({ tokens, options, html, inline }) {
FILE: test/unit/bin.test.js
function createMocks (line 10) | function createMocks() {
function testInput (line 44) | function testInput({ args = [], stdin = '', stdinError = '', stdout = ''...
function fixturePath (line 66) | function fixturePath(filePath) {
FILE: test/unit/instance.test.js
method heading (line 10) | heading() {
method heading (line 19) | heading() {
method heading (line 35) | heading() {
method heading (line 45) | heading() {
method heading (line 82) | heading() {
FILE: test/unit/marked.test.js
method tokenizer (line 80) | tokenizer(src) {
method renderer (line 91) | renderer(token) {
method start (line 108) | start(src) { return src.indexOf(':'); }
method tokenizer (line 109) | tokenizer(src) {
method renderer (line 120) | renderer(token) {
method hr (line 133) | hr() {
method start (line 148) | start(src) { return src.indexOf('='); }
method tokenizer (line 149) | tokenizer(src) {
method renderer (line 160) | renderer(token) {
method start (line 173) | start(src) { return src.indexOf('='); }
method tokenizer (line 174) | tokenizer(src) {
method renderer (line 185) | renderer(token) {
method start (line 213) | start(src) {
method tokenizer (line 219) | tokenizer(src, tokens) {
method renderer (line 233) | renderer(token) {
method start (line 241) | start(src) { return src.indexOf(':'); }
method tokenizer (line 242) | tokenizer(src, tokens) {
method renderer (line 257) | renderer(token) {
method start (line 276) | start(src) { return src.indexOf(':'); }
method tokenizer (line 277) | tokenizer(src) {
method renderer (line 288) | renderer(token) {
method tokenizer (line 301) | tokenizer(src) {
method renderer (line 312) | renderer(token) {
method renderer (line 322) | renderer(token) {
method tokenizer (line 338) | tokenizer(src) {
method renderer (line 350) | renderer(token) {
method tokenizer (line 357) | tokenizer(src) {
method tokenizer (line 382) | tokenizer(src) {
method renderer (line 385) | renderer(token) {
method tokenizer (line 392) | tokenizer(src) {
method renderer (line 403) | renderer(token) {
method start (line 418) | start(src) { return src.indexOf(':'); }
method tokenizer (line 419) | tokenizer(src, tokens) {
method renderer (line 435) | renderer(token) {
method walkTokens (line 440) | walkTokens(token) {
method start (line 458) | start(src) { return src.indexOf(':'); }
method tokenizer (line 459) | tokenizer(src, tokens) {
method renderer (line 472) | renderer(token) {
method walkTokens (line 477) | walkTokens(token) {
function createExtension (line 491) | function createExtension(name) {
function createFalseExtension (line 563) | function createFalseExtension(name) {
function runTest (line 589) | function runTest() {
method start (line 697) | start(src) { return src.indexOf('='); }
method tokenizer (line 698) | tokenizer(src) {
method renderer (line 709) | renderer(token) {
method start (line 730) | start(src) {
method tokenizer (line 736) | tokenizer(src, tokens) {
method renderer (line 750) | renderer(token) {
method walkTokens (line 760) | walkTokens(token) {
method paragraph (line 783) | paragraph() {
method paragraph (line 798) | paragraph(text) {
method walkTokens (line 820) | walkTokens(token) {
method walkTokens (line 842) | walkTokens(token) {
method walkTokens (line 849) | walkTokens(token) {
method paragraph (line 865) | paragraph() {
method html (line 868) | html() {
method paragraph (line 876) | paragraph() {
method paragraph (line 897) | paragraph({ text }) {
method paragraph (line 908) | paragraph({ text }) {
method paragraph (line 938) | paragraph() {
method walkTokens (line 1060) | walkTokens(token) {
method walkTokens (line 1073) | async walkTokens(token) {
FILE: test/unit/utils.js
function timeout (line 1) | async function timeout(ms = 1) {
FILE: test/update-specs.js
function removeFiles (line 10) | function removeFiles(dir) {
function updateCommonmark (line 16) | async function updateCommonmark(dir, options) {
function updateGfm (line 39) | async function updateGfm(dir) {
Condensed preview — 411 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,002K chars).
[
{
"path": ".devcontainer/devcontainer.json",
"chars": 590,
"preview": "// For format details, see https://aka.ms/devcontainer.json. For config options, see the\n// README at: https://github.co"
},
{
"path": ".editorconfig",
"chars": 272,
"preview": "root = true\n\n[*.{json,js}]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\nindent_style = space\nindent_size"
},
{
"path": ".gitattributes",
"chars": 76,
"preview": "* eol=lf\ntest/* linguist-vendored\nlib/* linguist-generated\n"
},
{
"path": ".github/ISSUE_TEMPLATE/Bug_report.md",
"chars": 865,
"preview": "---\nname: Bug report\nabout: Marked says it does this thing but does not\n\n---\n**Marked version:**\n\n**Describe the bug**\nA"
},
{
"path": ".github/ISSUE_TEMPLATE/Feature_request.md",
"chars": 384,
"preview": "---\nname: Feature request\nabout: Marked doesn't do this thing and I think it should\n\n---\n\n**Describe the feature**\nA cle"
},
{
"path": ".github/ISSUE_TEMPLATE/Proposal.md",
"chars": 315,
"preview": "---\nname: Proposal\nabout: Marked doesn't do this thing and I think it should\n\n---\n\n**What pain point are you perceiving?"
},
{
"path": ".github/ISSUE_TEMPLATE.md",
"chars": 1003,
"preview": "**Marked version:**\n\n**Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a\n\n<!-- The NPM version or c"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE/badges.md",
"chars": 3346,
"preview": "**@mention the contributor:**\n\n## Recommendation to:\n\n- [ ] Change user group\n- [ ] Add a badge\n- [ ] Remove a badge\n\n<!"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"chars": 1359,
"preview": "\n<!--\n\n\tIf badging PR, add ?template=badges.md to the PR url to use the badges PR template.\n\n\tOtherwise, you are stating"
},
{
"path": ".github/dependabot.yml",
"chars": 241,
"preview": "version: 2\nupdates:\n - package-ecosystem: \"github-actions\"\n directory: \"/\"\n schedule:\n interval: \"weekly\"\n "
},
{
"path": ".github/workflows/tests.yml",
"chars": 2750,
"preview": "name: \"Tests\"\non:\n pull_request:\n push:\n branches:\n - master\n\npermissions:\n contents: read\n\njobs:\n UnitTests"
},
{
"path": ".gitignore",
"chars": 116,
"preview": ".DS_Store\n.vercel\n.vscode\nnode_modules/\ntest/compiled_tests\npublic\nlib\ndocs/LICENSE.md\nvuln.js\nman/marked.1\ntest.js\n"
},
{
"path": ".releaserc.json",
"chars": 202,
"preview": "{\n \"plugins\": [\n \"@semantic-release/commit-analyzer\",\n \"@semantic-release/release-notes-generator\",\n \"@semanti"
},
{
"path": "CHANGELOG.md",
"chars": 48,
"preview": "see https://github.com/markedjs/marked/releases\n"
},
{
"path": "LICENSE.md",
"chars": 2933,
"preview": "# License information\n\n## Contribution License Agreement\n\nIf you contribute code to this project, you are implicitly all"
},
{
"path": "README.md",
"chars": 3090,
"preview": "<a href=\"https://marked.js.org\">\n <img width=\"60px\" height=\"60px\" src=\"https://marked.js.org/img/logo-black.svg\" align="
},
{
"path": "SECURITY.md",
"chars": 554,
"preview": "# Security Policy\n\nThe only completely secure system is the one that doesn't exist in the first place.\nHaving said that,"
},
{
"path": "api/dingus.js",
"chars": 511,
"preview": "import { marked } from '../lib/marked.esm.js';\nimport pkg from '../package.json' with { type: 'json' };\n\nconst version ="
},
{
"path": "bin/main.js",
"chars": 6656,
"preview": "#!/usr/bin/env node\n\n/**\n * Marked CLI\n * Copyright (c) 2018+, MarkedJS. (MIT License)\n * Copyright (c) 2011-2018, Chris"
},
{
"path": "bin/marked.js",
"chars": 264,
"preview": "#!/usr/bin/env node\n\n/**\n * Marked CLI\n * Copyright (c) 2018+, MarkedJS. (MIT License)\n * Copyright (c) 2011-2018, Chris"
},
{
"path": "docs/.eslintrc.json",
"chars": 694,
"preview": "{\n \"extends\": \"standard\",\n \"parserOptions\": {\n \"ecmaVersion\": 2015,\n \"sourceType\": \"script\"\n },\n \"rules\": {\n "
},
{
"path": "docs/AUTHORS.md",
"chars": 15774,
"preview": "# Authors\n\nMarked takes an encompassing approach to its community. As such, you can think of these as [concentric circle"
},
{
"path": "docs/CODE_OF_CONDUCT.md",
"chars": 3273,
"preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, w"
},
{
"path": "docs/CONTRIBUTING.md",
"chars": 6204,
"preview": "# Contributing to Marked\n\n- [ ] Fork `markedjs/marked`.\n- [ ] Clone the library locally using GitHub Desktop or the comm"
},
{
"path": "docs/INDEX.md",
"chars": 6431,
"preview": "Marked is\n\n1. built for speed.<sup>*</sup>\n2. a low-level markdown compiler for parsing markdown without caching or bloc"
},
{
"path": "docs/PUBLISHING.md",
"chars": 1276,
"preview": "# Releasing Marked\n\nMarked uses [semantic-release](https://github.com/semantic-release/semantic-release) to release new "
},
{
"path": "docs/USING_ADVANCED.md",
"chars": 16782,
"preview": "<h2 id=\"instance\">Marked instance</h2>\n\nBy default, Marked stores options and extensions in the global scope. That means"
},
{
"path": "docs/USING_PRO.md",
"chars": 29452,
"preview": "## Extending Marked\n\nTo champion the single-responsibility and open/closed principles, we have tried to make it relative"
},
{
"path": "docs/_document.html",
"chars": 16738,
"preview": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-w"
},
{
"path": "docs/broken.md",
"chars": 4981,
"preview": "# Markdown is broken\n\nI have a lot of scraps of markdown engine oddities that I've collected over the\nyears. What you se"
},
{
"path": "docs/build.js",
"chars": 4583,
"preview": "/* global marked */\nimport '../lib/marked.umd.js';\nimport { promises } from 'fs';\nimport { join, dirname, parse, format "
},
{
"path": "docs/css/hljs-github-dark.css",
"chars": 4798,
"preview": "/*!\n Theme: GitHub Dark\n Description: Dark theme for syntax highlighting\n Based on GitHub's dark theme colors\n*/\n\n/* "
},
{
"path": "docs/css/hljs-github.css",
"chars": 2877,
"preview": "/*!\n Theme: GitHub (Adapted for dynamic light/dark mode)\n*/\n\n.hljs {\n color: var(--text-color);\n background: var(--ba"
},
{
"path": "docs/css/shared.css",
"chars": 954,
"preview": "a.github-corner {\n\tposition: fixed !important;\n\ttop: 0;\n\tright: 0;\n\tborder: 0;\n\tz-index: 9999 !important;\n\tdisplay: bloc"
},
{
"path": "docs/css/style.css",
"chars": 5039,
"preview": "/*\n This file contains custom styles and CSS variables that supplement Tailwind CSS.\n*/\n\n/* Define color scheme variabl"
},
{
"path": "docs/demo/demo.css",
"chars": 3594,
"preview": "html, body {\n\tmargin: 0;\n\tpadding: 0;\n\tfont-family: \"Inter\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n\tcolor: var"
},
{
"path": "docs/demo/demo.js",
"chars": 15033,
"preview": "onunhandledrejection = (e) => {\n throw e.reason;\n};\n\nconst $loadingElem = document.querySelector('#loading');\nconst $ma"
},
{
"path": "docs/demo/index.html",
"chars": 6079,
"preview": "<!doctype html>\n<html lang=\"en\">\n\n <head>\n <title>Marked Demo</title>\n <meta charset=\"utf-8\" />\n <meta name=\"v"
},
{
"path": "docs/demo/initial.md",
"chars": 1506,
"preview": "Marked - Markdown Parser\n========================\n\n[Marked] lets you convert [Markdown] into HTML. Markdown is a simple"
},
{
"path": "docs/demo/preview.html",
"chars": 2648,
"preview": "\n<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>marked.js preview</title>\n <script>\n ("
},
{
"path": "docs/demo/quickref.md",
"chars": 6213,
"preview": "Markdown Quick Reference\n========================\n\nThis guide is a very brief overview, with examples, of the syntax tha"
},
{
"path": "docs/demo/worker.js",
"chars": 4143,
"preview": "const versionCache = {};\nlet currentVersion;\n\nonunhandledrejection = (e) => {\n throw e.reason;\n};\n\nonmessage = function"
},
{
"path": "docs/js/index.js",
"chars": 6859,
"preview": "document.addEventListener('DOMContentLoaded', function() {\n // --- Theme Toggling ---\n const themeToggle = document.ge"
},
{
"path": "esbuild.config.js",
"chars": 1117,
"preview": "import * as esbuild from 'esbuild';\nimport { umdWrapper } from 'esbuild-plugin-umd-wrapper';\nimport fs from 'fs';\n\nconst"
},
{
"path": "eslint.config.js",
"chars": 173,
"preview": "import markedEslintConfig from '@markedjs/eslint-config';\n\nexport default [\n {\n ignores: ['**/lib', '**/public', 'te"
},
{
"path": "man/marked.1.md",
"chars": 1970,
"preview": "# marked(1) -- a javascript markdown parser\n\n## SYNOPSIS\n\n`marked` [`-o` <output file>] [`-i` <input file>] [`-s` <markd"
},
{
"path": "package.json",
"chars": 3396,
"preview": "{\n \"name\": \"marked\",\n \"description\": \"A markdown parser built for speed\",\n \"author\": \"Christopher Jeffrey\",\n \"versio"
},
{
"path": "src/Hooks.ts",
"chars": 1556,
"preview": "import { _defaults } from './defaults.ts';\nimport { _Lexer } from './Lexer.ts';\nimport { _Parser } from './Parser.ts';\ni"
},
{
"path": "src/Instance.ts",
"chars": 14577,
"preview": "import { _getDefaults } from './defaults.ts';\nimport { _Lexer } from './Lexer.ts';\nimport { _Parser } from './Parser.ts'"
},
{
"path": "src/Lexer.ts",
"chars": 14234,
"preview": "import { _Tokenizer } from './Tokenizer.ts';\nimport { _defaults } from './defaults.ts';\nimport { other, block, inline } "
},
{
"path": "src/MarkedOptions.ts",
"chars": 6248,
"preview": "import type { Token, Tokens, TokensList } from './Tokens.ts';\nimport type { _Parser } from './Parser.ts';\nimport type { "
},
{
"path": "src/Parser.ts",
"chars": 5847,
"preview": "import { _Renderer } from './Renderer.ts';\nimport { _TextRenderer } from './TextRenderer.ts';\nimport { _defaults } from "
},
{
"path": "src/Renderer.ts",
"chars": 5956,
"preview": "import { _defaults } from './defaults.ts';\nimport {\n cleanUrl,\n escapeHtmlEntities,\n} from './helpers.ts';\nimport { ot"
},
{
"path": "src/TextRenderer.ts",
"chars": 1129,
"preview": "import type { Tokens } from './Tokens.ts';\n\n/**\n * TextRenderer\n * returns only the textual part of the token\n */\nexport"
},
{
"path": "src/Tokenizer.ts",
"chars": 29844,
"preview": "import { _defaults } from './defaults.ts';\nimport {\n rtrim,\n splitCells,\n findClosingBracket,\n expandTabs,\n} from '."
},
{
"path": "src/Tokens.ts",
"chars": 3710,
"preview": "/* eslint-disable no-use-before-define */\n\nexport type MarkedToken = (\n Tokens.Blockquote\n | Tokens.Br\n | Tokens.Chec"
},
{
"path": "src/defaults.ts",
"chars": 745,
"preview": "import type { MarkedOptions } from './MarkedOptions.ts';\n\n/**\n * Gets the original marked default options.\n */\nexport fu"
},
{
"path": "src/helpers.ts",
"chars": 3442,
"preview": "import { other } from './rules.ts';\n\n/**\n * Helpers\n */\nconst escapeReplacements: { [index: string]: string } = {\n '&':"
},
{
"path": "src/marked.ts",
"chars": 3739,
"preview": "import { _Lexer } from './Lexer.ts';\nimport { _Parser } from './Parser.ts';\nimport { _Tokenizer } from './Tokenizer.ts';"
},
{
"path": "src/rules.ts",
"chars": 19235,
"preview": "const noopTest = { exec: () => null } as unknown as RegExp;\n\nfunction edit(regex: string | RegExp, opt = '') {\n let sou"
},
{
"path": "test/.eslintrc.json",
"chars": 628,
"preview": "{\n \"extends\": \"standard\",\n \"globals\": {\n \"expectAsync\": \"readonly\"\n },\n \"rules\": {\n \"semi\": [\"error\", \"always\""
},
{
"path": "test/bench.js",
"chars": 4883,
"preview": "import { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { htmlIsEqual, getTests }"
},
{
"path": "test/cjs-test.cjs",
"chars": 207,
"preview": "// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst { marked } = require('../lib/marked.esm.js');\n\ni"
},
{
"path": "test/recheck.ts",
"chars": 1750,
"preview": "import { block, inline, other } from '../src/rules.ts';\nimport { check } from 'recheck';\n\ninterface RegexpObj {\n [k: st"
},
{
"path": "test/rules.js",
"chars": 1942,
"preview": "import { Lexer } from '../lib/marked.esm.js';\nconst rules = Lexer.rules;\n\nconst COLOR = {\n reset: '\\x1b[0m',\n bright: "
},
{
"path": "test/run-spec-tests.js",
"chars": 1191,
"preview": "import { Marked } from '../lib/marked.esm.js';\nimport { getTests, runTests, outputCompletionTable } from '@markedjs/test"
},
{
"path": "test/specs/commonmark/commonmark.0.31.2.json",
"chars": 140625,
"preview": "[\n {\n \"markdown\": \"\\tfoo\\tbaz\\t\\tbim\\n\",\n \"html\": \"<pre><code>foo\\tbaz\\t\\tbim\\n</code></pre>\\n\",\n \"example\": 1"
},
{
"path": "test/specs/gfm/commonmark.0.31.2.json",
"chars": 140721,
"preview": "[\n {\n \"markdown\": \"\\tfoo\\tbaz\\t\\tbim\\n\",\n \"html\": \"<pre><code>foo\\tbaz\\t\\tbim\\n</code></pre>\\n\",\n \"example\": 1"
},
{
"path": "test/specs/gfm/gfm.0.29.json",
"chars": 8884,
"preview": "[\n {\n \"section\": \"[extension] Tables\",\n \"html\": \"<table>\\n<thead>\\n<tr>\\n<th>foo</th>\\n<th>bar</th>\\n</tr>\\n</the"
},
{
"path": "test/specs/new/adjacent_lists.html",
"chars": 125,
"preview": "<ul>\n<li>This should be</li>\n<li>An unordered list</li>\n</ul>\n\n<ol>\n<li>This should be</li>\n<li>An unordered list</li>\n<"
},
{
"path": "test/specs/new/adjacent_lists.md",
"chars": 77,
"preview": "* This should be\n* An unordered list\n\n1. This should be\n2. An unordered list\n"
},
{
"path": "test/specs/new/angle_brackets.html",
"chars": 45,
"preview": "<p>1 < 2 <strong>OR</strong> 4 > 3</p>\n"
},
{
"path": "test/specs/new/angle_brackets.md",
"chars": 19,
"preview": "1 < 2 **OR** 4 > 3\n"
},
{
"path": "test/specs/new/autolink_after_link.html",
"chars": 107,
"preview": "<p><a href=\"https://github.com\">Github</a></p>\n\n<p><a href=\"https://github.com\">https://github.com</a></p>\n"
},
{
"path": "test/specs/new/autolink_after_link.md",
"chars": 67,
"preview": "---\ngfm: true\n---\n[Github](https://github.com)\n\nhttps://github.com\n"
},
{
"path": "test/specs/new/autolink_lines.html",
"chars": 72,
"preview": "<p>hello world\n<a href=\"http://example.com\">http://example.com</a>\n</p>\n"
},
{
"path": "test/specs/new/autolink_lines.md",
"chars": 33,
"preview": "hello world\n<http://example.com>\n"
},
{
"path": "test/specs/new/autolinks.html",
"chars": 733,
"preview": "<p>(See <a href=\"https://www.example.com/fhqwhgads\">https://www.example.com/fhqwhgads</a>.)</p>\n\n<p>((<a href=\"http://fo"
},
{
"path": "test/specs/new/autolinks.md",
"chars": 263,
"preview": "(See https://www.example.com/fhqwhgads.)\n\n((http://foo.com))\n\n((http://foo.com.))\n\nHTTP://FOO.COM\n\nhTtP://fOo.CoM\n\n~~hel"
},
{
"path": "test/specs/new/autolinks_quotes.html",
"chars": 252,
"preview": "<p>"<a href=\"https://www.example.com?test=quote-in-%22-url\">https://www.example.com?test=quote-in-"-url</a>&qu"
},
{
"path": "test/specs/new/autolinks_quotes.md",
"chars": 93,
"preview": "\"https://www.example.com?test=quote-in-\"-url\"\n\n'https://www.example.com?test=quote-in-'-url'\n"
},
{
"path": "test/specs/new/backtick_precedence.html",
"chars": 563,
"preview": "<p>**You might think this should be bold, but: <code>**</code></p>\n<p>**You might think this should be bold, but: <code>"
},
{
"path": "test/specs/new/backtick_precedence.md",
"chars": 380,
"preview": "**You might think this should be bold, but: `**`\n\n**You might think this should be bold, but: ``**``\n\n**You might think "
},
{
"path": "test/specs/new/backticks_in_links.html",
"chars": 95,
"preview": "<p><a href=\"https://example.com\"><code>this is a backtick ` and it breaks stuff</code></a></p>\n"
},
{
"path": "test/specs/new/backticks_in_links.md",
"chars": 70,
"preview": "[`` this is a backtick ` and it breaks stuff ``](https://example.com)\n"
},
{
"path": "test/specs/new/blockquote_following_nptable.html",
"chars": 550,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/blockquote_following_nptable.md",
"chars": 122,
"preview": " abc | def\n --- | ---\n bar | foo\n baz | boo\n> a blockquote\n\n abc | def\n --- | ---\n bar | foo\n baz | boo\n > a blockquot"
},
{
"path": "test/specs/new/blockquote_following_table.html",
"chars": 550,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/blockquote_following_table.md",
"chars": 146,
"preview": "| abc | def |\n| --- | --- |\n| bar | foo |\n| baz | boo |\n> a blockquote\n\n| abc | def |\n| --- | --- |\n| bar | foo |\n| baz "
},
{
"path": "test/specs/new/blockquote_list_item.html",
"chars": 108,
"preview": "<p>This fails in markdown.pl and upskirt:</p>\n\n<ul><li>hello<blockquote><p>world</p></blockquote></li></ul>\n"
},
{
"path": "test/specs/new/blockquote_list_item.md",
"chars": 58,
"preview": "This fails in markdown.pl and upskirt:\n\n* hello\n > world\n"
},
{
"path": "test/specs/new/blockquote_setext.html",
"chars": 289,
"preview": "<blockquote>\n <p>not heading 1 ==</p>\n</blockquote>\n\n<blockquote>\n <p>not heading 2 --</p>\n</blockquote>\n\n<blockquote>"
},
{
"path": "test/specs/new/blockquote_setext.md",
"chars": 124,
"preview": "> not heading 1\n==\n\n> not heading 2\n--\n\n> heading 1\n> ==\n\n> heading 2\n> --\n\n> not heading 1\n==\n> not heading 2 with br "
},
{
"path": "test/specs/new/breakline.html",
"chars": 80,
"preview": "<p>A<br>break line test<br>Special <code>code</code>A<br>break line test</p> \n"
},
{
"path": "test/specs/new/breakline.md",
"chars": 55,
"preview": "A \nbreak line test \nSpecial `code`A \nbreak line test"
},
{
"path": "test/specs/new/breaks.html",
"chars": 14,
"preview": "<p>A<br>B</p>\n"
},
{
"path": "test/specs/new/breaks.md",
"chars": 35,
"preview": "---\nbreaks: true\ngfm: true\n---\nA\nB\n"
},
{
"path": "test/specs/new/case_insensitive_refs.html",
"chars": 29,
"preview": "<p><a href=\"/url\">hi</a></p>\n"
},
{
"path": "test/specs/new/case_insensitive_refs.md",
"chars": 17,
"preview": "[hi]\n\n[HI]: /url\n"
},
{
"path": "test/specs/new/code_block_no_ending_newline.html",
"chars": 62,
"preview": "<pre>\n <code>\n no newline at end of file\n </code>\n</pre>\n"
},
{
"path": "test/specs/new/code_block_no_ending_newline.md",
"chars": 29,
"preview": "```\nno newline at end of file"
},
{
"path": "test/specs/new/code_compensation_indent.html",
"chars": 133,
"preview": "<p>This is some text.</p>\n<ol>\n<li><p>This is a list element.</p>\n<pre><code>const x = 5;\nconst y = x + 5;\n</code></pre>"
},
{
"path": "test/specs/new/code_compensation_indent.md",
"chars": 115,
"preview": "---\nrenderExact: true\n---\nThis is some text.\n\n1. This is a list element.\n\n\t```\n\tconst x = 5;\n\tconst y = x + 5;\n\t```"
},
{
"path": "test/specs/new/code_consistent_newline.html",
"chars": 152,
"preview": "<pre><code class=\"language-js\">const value = 42;\n</code></pre>\n<pre><code>const value = 42;\n</code></pre>\n<p>Code blocks"
},
{
"path": "test/specs/new/code_consistent_newline.md",
"chars": 117,
"preview": "---\nrenderExact: true\n---\n```js\nconst value = 42;\n```\n\n const value = 42;\n\nCode blocks contain trailing new line.\n"
},
{
"path": "test/specs/new/code_following_nptable.html",
"chars": 575,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/code_following_nptable.md",
"chars": 175,
"preview": "abc | def\n--- | ---\nbar | foo\nbaz | boo\n a simple\n *indented* code block\n\n abc | def\n --- | ---\n bar | foo"
},
{
"path": "test/specs/new/code_following_table.html",
"chars": 575,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/code_following_table.md",
"chars": 207,
"preview": "| abc | def |\n| --- | --- |\n| bar | foo |\n| baz | boo |\n a simple\n *indented* code block\n\n | abc | def |\n | "
},
{
"path": "test/specs/new/code_spans.html",
"chars": 64,
"preview": "<p><code>someone@example.com</code></p>\n\n<p>``<em>test`</em></p>"
},
{
"path": "test/specs/new/code_spans.md",
"chars": 32,
"preview": "`someone@example.com`\n\n``*test`*"
},
{
"path": "test/specs/new/codespan_newline.html",
"chars": 74,
"preview": "<p><code>code code</code></p>\n\n<ul>\n<li><code>code code</code></li>\n</ul>\n"
},
{
"path": "test/specs/new/codespan_newline.md",
"chars": 27,
"preview": "`code\ncode`\n\n- `code\ncode`\n"
},
{
"path": "test/specs/new/def_blocks.html",
"chars": 258,
"preview": "<blockquote>\n <p>hello\n[1]: hello</p>\n</blockquote>\n\n<hr>\n\n<blockquote>\n <p>hello\n[2]: hello</p>\n</blockquote>\n\n\n<ul>\n"
},
{
"path": "test/specs/new/def_blocks.md",
"chars": 121,
"preview": "> hello\n> [1]: hello\n\n* * *\n\n> hello\n[2]: hello\n\n\n* hello\n* [3]: hello\n\n\n* hello\n[4]: hello\n\n\n> foo\n> bar\n[5]: foo\n> bar"
},
{
"path": "test/specs/new/del_flanking.html",
"chars": 107,
"preview": "<p>~1,~2</p>\n<p>Between ~1.34 and ~5.4</p>\n<p>Between (~1.34) and (~5.4)</p>\n<p>~ test~</p>\n<p>~test ~</p>\n"
},
{
"path": "test/specs/new/del_flanking.md",
"chars": 76,
"preview": "~1,~2\n\nBetween ~1.34 and ~5.4\n\nBetween (~1.34) and (~5.4)\n\n~ test~\n\n~test ~\n"
},
{
"path": "test/specs/new/del_strikethrough.html",
"chars": 189,
"preview": "<p><del>test</del></p>\n\n<p>~~test~</p>\n\n<p>~test~~</p>\n\n<p><del>test</del></p>\n\n<p><del>test\ntest</del></p>\n\n<p>~~test</"
},
{
"path": "test/specs/new/del_strikethrough.md",
"chars": 78,
"preview": "~~test~~\n\n~~test~\n\n~test~~\n\n~test~\n\n~~test\ntest~~\n\n~~test\n\ntest~~\n\n~~~test~~~\n"
},
{
"path": "test/specs/new/double_link.html",
"chars": 668,
"preview": "<p>Already linked: <a href=\"http://example.com/\">http://example.com/</a>.</p>\n\n<p>Already linked: <a href=\"http://exampl"
},
{
"path": "test/specs/new/double_link.md",
"chars": 563,
"preview": "<p>Already linked: <a href=\"http://example.com/\">http://example.com/</a>.</p>\n\nAlready linked: [http://example.com/](htt"
},
{
"path": "test/specs/new/em_2char.html",
"chars": 295,
"preview": "<p><em>123</em></p>\n\n<p><em>123</em></p>\n\n<p><em>12</em></p>\n\n<p><em>12</em></p>\n\n<p><em>1</em></p>\n\n<p><em>1</em></p>\n\n"
},
{
"path": "test/specs/new/em_2char.md",
"chars": 137,
"preview": "_123_\n\n*123*\n\n_12_\n\n*12*\n\n_1_\n\n*1*\n\n__\n\n**\n\n_123 _\n\n*123 *\n\n_ 123_\n\nIt’s levi*OH*sa, not levio*SAH.*\n\n__ test [test](htt"
},
{
"path": "test/specs/new/em_after_inline.html",
"chars": 296,
"preview": "<p>a<br><em>@</em></p>\n\n<p>a<em>a</em><em>a</em><em>@</em></p>\n\n<p>a<strong>a</strong><em>a</em><em>@</em></p>\n\n<p>a<del"
},
{
"path": "test/specs/new/em_after_inline.md",
"chars": 92,
"preview": "a\\\n*@*\n\na*a*_a_*@*\n\na**a**_a_*@*\n\na~a~*@*\n\na`a`*@*\n\na<http://a.com>*@*\n\na[a](a)*@*\n\na<a>*@*\n"
},
{
"path": "test/specs/new/em_and_reflinks.html",
"chars": 285,
"preview": "<p><em>Hello<a href=\"theaddress\">reflink*top</a>guys</em>!</p>\n<p><em>Hello [not</em>reflink] guys*!</p>\n<p><em>Hello [n"
},
{
"path": "test/specs/new/em_and_reflinks.md",
"chars": 233,
"preview": "[reflink*top]: theaddress\n\n*Hello [reflink*top] guys*!\n\n*Hello [not*reflink] guys*!\n\n*Hello [not*a*reflink] guys*!\n\n*Hel"
},
{
"path": "test/specs/new/em_link_brackets.html",
"chars": 74,
"preview": "<p><em><a href=\"http://example.com/_/path\"><code>a[b]c</code></a></em></p>"
},
{
"path": "test/specs/new/em_link_brackets.md",
"chars": 38,
"preview": "_[`a[b]c`](http://example.com/_/path)_"
},
{
"path": "test/specs/new/em_list_links.html",
"chars": 2766,
"preview": "<ul>\n<li>italic<ul>\n<li><a href=\"https://www.google.com\"><em>named link</em></a></li>\n<li><em><a href=\"https://www.googl"
},
{
"path": "test/specs/new/em_list_links.md",
"chars": 1118,
"preview": "- italic\n - [*named link*][some-url]\n - *[named link][some-url]*\n - [_named link_][some-url]\n - _[named link][some-u"
},
{
"path": "test/specs/new/em_strong_adjacent.html",
"chars": 311,
"preview": "<p><em>te</em><em>st</em></p>\n\n<p><em>te</em><strong>st</strong></p>\n\n<p><em>te</em><em>st</em></p>\n\n<p><em>te</em><stro"
},
{
"path": "test/specs/new/em_strong_adjacent.md",
"chars": 95,
"preview": "_te_*st*\n\n_te_**st**\n\n*te*_st_\n\n*te*__st__\n\n__te__*st*\n\n__te__**st**\n\n**te**_st_\n\n**te**__st__\n"
},
{
"path": "test/specs/new/em_strong_adjacent_mixed.html",
"chars": 295,
"preview": "<p><em><strong>foo</strong></em> <strong>bar</strong></p>\n\n<p><em><strong>foo</strong></em> <strong>bar</strong> <em><st"
},
{
"path": "test/specs/new/em_strong_adjacent_mixed.md",
"chars": 95,
"preview": "_**foo**_ **bar**\n\n_**foo**_ **bar** _**foo**_\n\n*__foo__* __bar__\n\n*__foo__* __bar__ *__foo__*\n"
},
{
"path": "test/specs/new/em_strong_complex_nesting.html",
"chars": 77,
"preview": "<p><strong>E<em>mp</em><em><strong>ha</strong></em><em>si</em>s</strong></p>\n"
},
{
"path": "test/specs/new/em_strong_complex_nesting.md",
"chars": 23,
"preview": "**E*mp****ha****si*s**\n"
},
{
"path": "test/specs/new/em_strong_multiline.html",
"chars": 142,
"preview": "<p><em>italic <strong>bold</strong> italic</em>\n<em>italic <strong>bold</strong> italic</em>\n<em>italic <strong>bold</st"
},
{
"path": "test/specs/new/em_strong_multiline.md",
"chars": 75,
"preview": "_italic **bold** italic_\n_italic **bold** italic_\n_italic **bold** italic_\n"
},
{
"path": "test/specs/new/em_strong_orphaned_nesting.html",
"chars": 41,
"preview": "<p><em><strong>foo_bar</strong></em></p>\n"
},
{
"path": "test/specs/new/em_strong_orphaned_nesting.md",
"chars": 14,
"preview": "_**foo_bar**_\n"
},
{
"path": "test/specs/new/email_after_space.html",
"chars": 56,
"preview": "<p><a href=\"mailto:info@email.io\">info@email.io</a></p>\n"
},
{
"path": "test/specs/new/email_after_space.md",
"chars": 15,
"preview": " info@email.io\n"
},
{
"path": "test/specs/new/emoji_inline.html",
"chars": 820,
"preview": "<p>Situations where it fails:</p>\n<p><strong>test 💁</strong></p>\n<p><strong>💁 test</strong></p>\n<p><strong>🤓 test</stron"
},
{
"path": "test/specs/new/emoji_inline.md",
"chars": 417,
"preview": "Situations where it fails:\n\n**test 💁**\n\n**💁 test**\n\n**🤓 test**\n\n**🏖️ test**\n\n**🏖️🤓💁 test**\n\n**💁 test** test\n\ntest **💁 te"
},
{
"path": "test/specs/new/emoji_strikethrough.html",
"chars": 399,
"preview": "<p><del>test 💁</del></p>\n<p><del>💁 test</del></p>\n<p><del>🤓 test</del></p>\n<p><del>🏖️ test</del></p>\n<p><del>🏖️🤓💁 test</"
},
{
"path": "test/specs/new/emoji_strikethrough.md",
"chars": 207,
"preview": "~~test 💁~~\n\n~~💁 test~~\n\n~~🤓 test~~\n\n~~🏖️ test~~\n\n~~🏖️🤓💁 test~~\n\n~~💁 test~~ test\n\ntest ~~💁 test~~\n\ntest ~~💁 test~~ test\n\n"
},
{
"path": "test/specs/new/emphasis_extra tests.html",
"chars": 97,
"preview": "<p><em>test</em>. <em>test</em>: <em>test</em>! <em>test</em>? <em>test</em>- <em>test</em>,</p>\n"
},
{
"path": "test/specs/new/emphasis_extra tests.md",
"chars": 48,
"preview": "_test_.\n_test_:\n_test_!\n_test_?\n_test_-\n_test_,\n"
},
{
"path": "test/specs/new/empty_heading_following_paragraph.html",
"chars": 79,
"preview": "<p>Newline after heading</p>\n<h2></h2>\n\n<p>No newline at the end</p>\n<h2></h2>\n"
},
{
"path": "test/specs/new/empty_heading_following_paragraph.md",
"chars": 50,
"preview": "Newline after heading\n##\n\nNo newline at the end\n##"
},
{
"path": "test/specs/new/empty_heading_following_paragraph_nogfm.html",
"chars": 79,
"preview": "<p>Newline after heading</p>\n<h2></h2>\n\n<p>No newline at the end</p>\n<h2></h2>\n"
},
{
"path": "test/specs/new/empty_heading_following_paragraph_nogfm.md",
"chars": 69,
"preview": "---\ngfm: false\n---\nNewline after heading\n##\n\nNo newline at the end\n##"
},
{
"path": "test/specs/new/empty_heading_following_table.html",
"chars": 487,
"preview": "<table>\n <thead>\n <tr>\n <th>a</th>\n <th>b</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>1</td>\n "
},
{
"path": "test/specs/new/empty_heading_following_table.md",
"chars": 109,
"preview": "| a | b |\n| - | - |\n| 1 | 2 |\n| 3 | 4 |\n##\n\nNo newline at the end\n\n| a | b |\n| - | - |\n| 1 | 2 |\n| 3 | 4 |\n##"
},
{
"path": "test/specs/new/escape_newline.html",
"chars": 184,
"preview": "<p>\n <a href=\"https://example.com\">foo<br />\nbar</a>\n</p>\n\n<p>\n <a href=\"https://example2.com\">foo2<br />\nbar2</a>\n</p"
},
{
"path": "test/specs/new/escape_newline.md",
"chars": 104,
"preview": "[foo\\\nbar]\n\n[foo\\\nbar]: https://example.com\n\n[foo2\\\nbar2](https://example2.com)\n\n[foo3\\\nbar3][foo\\\nbar]\n"
},
{
"path": "test/specs/new/escape_tick.html",
"chars": 368,
"preview": "<p><em>italics</em></p>\n<p><strong>bold</strong></p>\n<p><em><strong>bold italics</strong></em></p>\n<p><code>*quoted ital"
},
{
"path": "test/specs/new/escape_tick.md",
"chars": 206,
"preview": "*italics*\n\n**bold**\n\n***bold italics***\n\n`*quoted italics*`\n\n`**quoted bold**`\n\n`***quoted bold italics***`\n\n\\`*escaped "
},
{
"path": "test/specs/new/escape_within_del.html",
"chars": 87,
"preview": "<p><del>\\</del></p>\n<p>~\\~</p>\n<p><del>~</del></p>\n<p>~\\~~</p>\n<p>~~ ~</p>\n<p>~ ~~</p>\n"
},
{
"path": "test/specs/new/escape_within_del.md",
"chars": 39,
"preview": "~\\\\~\n\n~\\\\\\~\n\n~\\~~\n\n~\\\\~~\n\n~\\~ ~\n\n~ \\~~\n"
},
{
"path": "test/specs/new/escape_within_emphasis.html",
"chars": 416,
"preview": "<p><strong>strong text[</strong>]</p>\n\n<p><strong>strong text\\[</strong>]</p>\n\n<p><strong>strong text\\[</strong>]</p>\n\n<"
},
{
"path": "test/specs/new/escape_within_emphasis.md",
"chars": 233,
"preview": "**strong text\\[**\\]\n\n**strong text\\\\[**\\]\n\n**strong text\\\\\\[**\\]\n\n**strong text\\\\\\\\[**\\]\n\n__strong text\\[__\\]\n\n__strong "
},
{
"path": "test/specs/new/escaped_angles.html",
"chars": 12,
"preview": "<p>></p>\n"
},
{
"path": "test/specs/new/escaped_angles.md",
"chars": 3,
"preview": "\\>\n"
},
{
"path": "test/specs/new/fences_breaking_paragraphs.html",
"chars": 421,
"preview": "<p>A paragraph</p>\n<pre><code class=\"language-A\">Here is code in\nbacktick fences</code></pre>\n<p>B paragraph</p>\n<pre><c"
},
{
"path": "test/specs/new/fences_breaking_paragraphs.md",
"chars": 274,
"preview": "A paragraph\n```A\nHere is code in\nbacktick fences\n```\n\nB paragraph\n~~~B\nHere is code in\ntilde fences\n~~~\n\nC paragraph\n~~~"
},
{
"path": "test/specs/new/fences_following_list.html",
"chars": 58,
"preview": "<ol>\n<li>abcd</li>\n</ol>\n<pre><code>if {\n\n}\n</code></pre>\n"
},
{
"path": "test/specs/new/fences_following_list.md",
"chars": 23,
"preview": "1. abcd\n```\nif {\n}\n```\n"
},
{
"path": "test/specs/new/fences_following_nptable.html",
"chars": 263,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/fences_following_nptable.md",
"chars": 61,
"preview": " abc | def\n --- | ---\n bar | foo\n baz | boo\n```\nfoobar()\n```\n"
},
{
"path": "test/specs/new/fences_following_table.html",
"chars": 263,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/fences_following_table.md",
"chars": 73,
"preview": "| abc | def |\n| --- | --- |\n| bar | foo |\n| baz | boo |\n```\nfoobar()\n```\n"
},
{
"path": "test/specs/new/fences_with_blankline_following_list_0.html",
"chars": 257,
"preview": "<ol>\n<li>code with blankline</li>\n</ol>\n<pre><code>if {\n\n}\n</code></pre>\n<ol start=\"2\">\n<li>code and text</li>\n</ol>\n<pr"
},
{
"path": "test/specs/new/fences_with_blankline_following_list_0.md",
"chars": 130,
"preview": "1. code with blankline\n```\nif {\n\n}\n```\n\n2. code and text\n```\nif {\n\n\n}\n```\ntext after fenced code block.\n\n3. tilde\n~~~\nif"
},
{
"path": "test/specs/new/fences_with_blankline_following_list_1.html",
"chars": 239,
"preview": "<ol>\n<li><p>code with blankline</p>\n<pre><code>if {\n\n}\n</code></pre>\n</li>\n<li><p>code and text</p>\n<pre><code>if {\n\n}\n<"
},
{
"path": "test/specs/new/fences_with_blankline_following_list_1.md",
"chars": 182,
"preview": "1. code with blankline\n ```\n if {\n \n }\n ```\n\n2. code and text\n ```\n if {\n \n \n }\n ```\n text after"
},
{
"path": "test/specs/new/heading_following_list.html",
"chars": 115,
"preview": "<h1>level1</h1>\n<h2>level2</h2>\n<h3>level3</h3>\n<ul>\n <li>foo=bar</li>\n <li>foo2=bar2</li>\n</ul>\n<h3>level3</h3>\n"
},
{
"path": "test/specs/new/heading_following_list.md",
"chars": 63,
"preview": "# level1\n## level2\n### level3\n- foo=bar\n- foo2=bar2\n### level3\n"
},
{
"path": "test/specs/new/heading_following_nptable.html",
"chars": 245,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/heading_following_nptable.md",
"chars": 52,
"preview": " abc | def\n --- | ---\n bar | foo\n baz | boo\n# title\n"
},
{
"path": "test/specs/new/heading_following_table.html",
"chars": 245,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/heading_following_table.md",
"chars": 64,
"preview": "| abc | def |\n| --- | --- |\n| bar | foo |\n| baz | boo |\n# title\n"
},
{
"path": "test/specs/new/hr_following_nptables.html",
"chars": 730,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/hr_following_nptables.md",
"chars": 162,
"preview": " abc | def\n --- | ---\n bar | foo\n baz | boo\n___\n\n abc | def\n --- | ---\n bar | foo\n baz | boo\n---\n\ntext then table\n abc |"
},
{
"path": "test/specs/new/hr_following_tables.html",
"chars": 730,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/hr_following_tables.md",
"chars": 198,
"preview": "| abc | def |\n| --- | --- |\n| bar | foo |\n| baz | boo |\n___\n\n| abc | def |\n| --- | --- |\n| bar | foo |\n| baz | boo |\n---"
},
{
"path": "test/specs/new/hr_list_break.html",
"chars": 74,
"preview": "<ul>\n<li>hello\nworld</li>\n<li>how\nare</li>\n</ul>\n\n<hr>\n\n<p>you today?</p>\n"
},
{
"path": "test/specs/new/hr_list_break.md",
"chars": 41,
"preview": "* hello\nworld\n* how\nare\n* * *\nyou today?\n"
},
{
"path": "test/specs/new/html_comments.html",
"chars": 689,
"preview": "<h3>Example 1</h3>\n\n<!-- comment -->\n\n<h3>Example 2</h3>\n\n<!---->\n\n<h3>Example 3</h3>\n\n<!-- -->\n\n<h3>Example 4</h3>\n\n<!-"
},
{
"path": "test/specs/new/html_comments.md",
"chars": 591,
"preview": "### Example 1\n\n<!-- comment -->\n\n### Example 2\n\n<!---->\n\n### Example 3\n\n<!-- -->\n\n### Example 4\n\n<!-- - -->\n\n### Example"
},
{
"path": "test/specs/new/html_following_list.html",
"chars": 172,
"preview": "<ul>\n <li>list item 1</li>\n <li>list item 2</li>\n</ul>\n<div class=\"some-class\">\nContent\n</div>\n\n<ul>\n <li>list item 1"
},
{
"path": "test/specs/new/html_following_list.md",
"chars": 114,
"preview": "- list item 1\n- list item 2\n<div class=\"some-class\">\nContent\n</div>\n\n- list item 1\n- list item 2\n<!--\nComment\n-->\n"
},
{
"path": "test/specs/new/html_following_nptable.html",
"chars": 251,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/html_following_nptable.md",
"chars": 65,
"preview": " abc | def\n --- | ---\n bar | foo\n baz | boo\n<div>Some HTML</div>\n"
},
{
"path": "test/specs/new/html_following_table.html",
"chars": 251,
"preview": "<table>\n <thead>\n <tr>\n <th>abc</th>\n <th>def</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>bar</"
},
{
"path": "test/specs/new/html_following_table.md",
"chars": 77,
"preview": "| abc | def |\n| --- | --- |\n| bar | foo |\n| baz | boo |\n<div>Some HTML</div>\n"
},
{
"path": "test/specs/new/html_no_new_line.html",
"chars": 16,
"preview": "<img src='sdfg'>"
},
{
"path": "test/specs/new/html_no_new_line.md",
"chars": 16,
"preview": "<img src='sdfg'>"
},
{
"path": "test/specs/new/image_alt.html",
"chars": 95,
"preview": "<p><img src=\"https://example.com/404.jpg\" alt=\"" onerror="alert('XSS')"\" /></p>\n"
}
]
// ... and 211 more files (download for full content)
About this extraction
This page contains the full source code of the markedjs/marked GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 411 files (881.5 KB), approximately 285.0k tokens, and a symbol index with 353 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.