{"id":13725962,"url":"https://github.com/npm/marky-markdown","last_synced_at":"2025-10-07T03:32:25.774Z","repository":{"id":487832,"uuid":"27984586","full_name":"npm/marky-markdown","owner":"npm","description":"npm's markdown parser","archived":true,"fork":false,"pushed_at":"2024-02-26T20:40:35.000Z","size":1641,"stargazers_count":405,"open_issues_count":66,"forks_count":71,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-01-09T05:15:43.840Z","etag":null,"topics":["registry"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@npmcorp/marky-markdown","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2014-12-14T05:36:22.000Z","updated_at":"2024-08-12T12:39:04.000Z","dependencies_parsed_at":"2024-02-04T16:20:41.526Z","dependency_job_id":"87d29cd8-1f37-4112-9ef5-404fb6b5175e","html_url":"https://github.com/npm/marky-markdown","commit_stats":{"total_commits":354,"total_committers":31,"mean_commits":"11.419354838709678","dds":0.672316384180791,"last_synced_commit":"96cd45a1e4a826a663ae50916c382420f10825ea"},"previous_names":[],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmarky-markdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmarky-markdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmarky-markdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmarky-markdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/marky-markdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235586068,"owners_count":19014028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["registry"],"created_at":"2024-08-03T01:02:43.885Z","updated_at":"2025-10-07T03:32:20.461Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# marky-markdown\n\n[![Build Status](https://travis-ci.org/npm/marky-markdown.svg?branch=master)](https://travis-ci.org/npm/marky-markdown)\n[![Code Climate](https://codeclimate.com/github/npm/marky-markdown/badges/gpa.svg)](https://codeclimate.com/github/npm/marky-markdown)\n[![Dependency Status](https://david-dm.org/npm/marky-markdown.svg)](https://david-dm.org/npm/marky-markdown)\n[![Pull Requests](https://img.shields.io/github/issues-pr/npm/marky-markdown.svg)](https://github.com/npm/marky-markdown/pulls)\n[![Issues](https://img.shields.io/github/issues/npm/marky-markdown.svg)](https://github.com/npm/marky-markdown/issues)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n\n`marky-markdown` is a markdown parser, written in NodeJS, that aims for\nparity with [GitHub-style markdown]. It is built on top of [`markdown-it`],\na [CommonMark] markdown parser. You can use marky-markdown:\n\n- [programmatically in NodeJS]\n- [in your terminal]\n- [in the browser] *does not yet support syntax highlighting\n\n`marky-markdown` is the thing that parses package READMEs on\nhttp://www.npmjs.com. If you see a markdown parsing bug there,\n[file an issue here]!\n\n[file an issue here]: https://github.com/npm/marky-markdown/issues\n[GitHub-style markdown]: https://help.github.com/articles/basic-writing-and-formatting-syntax/\n[CommonMark]: http://spec.commonmark.org/\n[`markdown-it`]: https://github.com/markdown-it/markdown-it\n[programmatically in NodeJS]: #programmatic-usage\n[in your terminal]: #command-line-usage\n[in the browser]: #in-the-browser\n\n## Node Version Support\n\nmarky-markdown strives to support all LTS, current, and maintenance\nversions of Node.js. When a version of Node.js is EOL, we will EOL\nsupport for that version for marky-markdown.\n\nFor more information on Node.js LTS and support, click [here](https://github.com/nodejs/LTS).\n\n- marky-markdown \u003c `9.0.0` supports `0.10`, `0.12`, `iojs`, `4`, `5`\n- marky-markdown \u003e= `9.0.0` supports `0.12`, `4`, `6`\n\n## Installation\n\n```sh\nnpm install marky-markdown --save\n```\n\n## Programmatic Usage\n\nmarky-markdown exports a single function. For basic use, that function\ntakes a single argument: a string to convert.\n\n```js\nvar marky = require(\"marky-markdown\")\nvar html = marky(\"# hello, I'm markdown\")\n```\n\n### Options\n\nThe exported function takes an optional options object\nas its second argument:\n\n```js\nmarky(\"some trusted string\", {sanitize: false})\n```\n\nThe default options are as follows:\n\n```js\n{\n  sanitize: true,               // remove script tags and stuff\n  nofollow: true,               // add rel=nofollow to all links\n  linkify: true,                // turn orphan URLs into hyperlinks\n  highlightSyntax: true,        // run highlights on fenced code blocks\n  prefixHeadingIds: true,       // prevent DOM id collisions\n  enableHeadingLinkIcons: true, // render icons inside generated section links\n  serveImagesWithCDN: false,    // use npm's CDN to proxy images over HTTPS\n  debug: false,                 // console.log() all the things\n  package: null,                // npm package metadata,\n  headingAnchorClass: 'anchor', // the classname used for anchors in headings.\n  headingSvgClass: ['octicon']  // the class used for svg icon in headings.\n}\n```\n\n### Low Level Parser Access\n\nIf you need lower level access to the markdown-it parser (to add your own\n[markdown-it plugins](https://www.npmjs.com/search?q=markdown-it-plugin), for\nexample), you can call the `getParser` method:\n\n```js\nvar parser = marky.getParser()\nparser.use(someMarkdownItPlugin)\nvar html = parser.render(\"# markdown string\")\n```\n\n`getParser` takes an optional `options` argument, the same format as the main\nmarky-markdown export function. If you omit it, it uses the same default options\ndescribed above.\n\nWhen you're done customizing the parser, call `parser.render(markdown)` to\nrender to HTML.\n\n## Command-line Usage\n\nYou can use marky-markdown to parse markdown files in the shell.\nThe easiest way to do this is to install globally:\n\n```\nnpm i -g marky-markdown\nmarky-markdown some.md \u003e some.html\n```\n\n## In the Browser\n\nThis module mostly works in the browser, with the exception of the `highlights` module.\n\nYou can `require('marky-markdown')` in scripts you browserify yourself,\nor just use the standalone file in [dist/marky-markdown.js].\n\nHere is an example using HTML5 to render text inside `\u003cmarky-markdown\u003e` tags.\n\n```html\n\u003cscript src=\"marky-markdown.js\"\u003e\u003c/script\u003e\n\n\u003cmarky-markdown\u003e**Here** _is_ some [Markdown](https://github.com/)\u003c/marky-markdown\u003e\n\n\u003cscript\u003e\n  for (el of document.getElementsByTagName('marky-markdown')) {\n    el.innerHTML = markyMarkdown(el.innerHTML, {highlightSyntax: false})\n  }\n\u003c/script\u003e\n```\n\nNote: Usage with [webpack](https://webpack.github.io/) requires that your\n`webpack.config.js` configure a loader (such as\n[json-loader](https://github.com/webpack/json-loader)) for .json files. Also, you need to config `process.browser` in `webpack.config.js` when you target browser:\n\n```js\n  plugins: [\n    new webpack.DefinePlugin({\n      'process.browser': true\n    })\n  ],\n```\n\n## Tests\n\n```sh\nnpm install\nnpm test\n```\n\n## What it does\n\n- Parses markdown with [markdown-it](https://github.com/markdown-it/markdown-it), a fast and [commonmark-compliant](http://commonmark.org/) parser.\n- Removes broken and malicious user input with [sanitize-html](https://www.npmjs.com/package/sanitize-html)\n- Applies syntax highlighting to [GitHub-flavored code blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/) using the [highlights](https://www.npmjs.com/package/highlights) library from [Atom](https://atom.io/).\n- Converts `:emoji:`-style [shortcuts](http://www.emoji-cheat-sheet.com/) to unicode emojis.\n- Converts headings (h1, h2, etc) into anchored hyperlinks.\n- Converts relative GitHub links to their absolute equivalents.\n- Converts relative GitHub images sources to their GitHub raw equivalents.\n- Converts insecure Gravatar URLs to HTTPS.\n- Converts list items with leading `[ ]` and `[x]` into [GitHub-style task lists](https://github.com/blog/1825-task-lists-in-all-markdown-documents)\n- Wraps embedded YouTube videos so they can be styled.\n- Parses and sanitizes `package.description` as markdown.\n- Applies CSS classes to redundant content that closely matches npm package name and description.\n\n### npm packages\n\nPass in an npm `package` object to do stuff like rewriting relative URLs\nto their absolute equivalent on GitHub, normalizing package metadata\nwith redundant readme content, etc\n\n```js\nvar package = {\n  name: \"foo\",\n  description: \"foo is a thing\",\n  repository: {\n    type: \"git\",\n    url: \"https://github.com/kung/foo\"\n  }\n}\n\nmarky(\n  \"# hello, I am the foo readme\",\n  {package: package}\n)\n```\n\n## Dependencies\n\n- [github-slugger](https://github.com/Flet/github-slugger): Generate a slug just like GitHub does for markdown headings\n- [github-url-to-object](https://github.com/zeke/github-url-to-object): Extract user, repo, and other interesting properties from GitHub URLs\n- [highlights](https://github.com/atom/highlights): Syntax highlighter\n- [highlights-tokens](https://github.com/zeke/highlights-tokens): A list of the language tokens used by the Atom.app [highlights](https://www.npmjs.com/package/highlights) syntax highlighter\n- [innertext](https://github.com/revin/innertext): Extract the `innerText` from a snippet of HTML\n- [lodash](https://github.com/lodash/lodash): A utility library delivering consistency, customization, performance, \u0026amp; extras.\n- [markdown-it](https://github.com/markdown-it/markdown-it): Markdown-it - modern pluggable markdown parser.\n- [markdown-it-emoji](https://github.com/markdown-it/markdown-it-emoji): Markdown-it-emoji extension for Markdown-it that parses markdown emoji syntax to unicode.\n- [markdown-it-expand-tabs](https://github.com/revin/markdown-it-expand-tabs): Replace leading tabs with spaces in fenced code blocks\n- [markdown-it-lazy-headers](https://github.com/Galadirith/markdown-it-lazy-headers): Lazy ATX headers plugin for markdown-it\n- [markdown-it-task-lists](https://github.com/revin/markdown-it-task-lists): Render GitHub-style [task lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)\n- [property-ttl](https://github.com/soldair/property-ttl): Save memory by nulling out a property after ttl if it has not been accessed\n- [sanitize-html](https://github.com/punkave/sanitize-html): Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis\n- [similarity](https://github.com/zeke/similarity): How similar are these two strings?\n\nExtra syntax highlighting, in addition to what comes with [highlights](https://www.npmjs.com/package/highlights):\n\n- [atom-language-diff](https://github.com/revin/atom-language-diff): Diff/patch files\n- [atom-language-nginx](https://github.com/hnagato/atom-language-nginx): [NGINX](http://nginx.org/) configuration files\n- [language-dart](https://github.com/Daegalus/atom-language-dart): [Dart](https://www.dartlang.org/) language\n- [language-erlang](https://github.com/jonathanmarvens/atom-language-erlang): [Erlang](http://www.erlang.org/) language\n- [language-glsl](https://github.com/hughsk/language-glsl): [OpenGL Shading Language](https://www.opengl.org/documentation/glsl/) files\n- [language-haxe](https://github.com/theRemix/language-haxe): [Haxe](http://haxe.org/) language\n- [language-ini](https://github.com/jacobbednarz/atom-language-ini): .ini configuration files\n- [language-rust](https://github.com/zargony/atom-language-rust): [Rust](http://www.rust-lang.org/) language\n- [language-stylus](https://github.com/matthojo/language-stylus): [Stylus](http://stylus-lang.com/) CSS preprocessor\n\n## License\n\nISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fmarky-markdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Fmarky-markdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fmarky-markdown/lists"}