{"_id":"@elog/mdast-util-to-markdown","name":"@elog/mdast-util-to-markdown","dist-tags":{"latest":"0.6.6"},"versions":{"0.6.6":{"name":"@elog/mdast-util-to-markdown","version":"0.6.6","description":"mdast utility to serialize markdown","license":"MIT","keywords":["unist","mdast","mdast-util","util","utility","markdown","markup","serialize","stringify","compile","syntax","tree","ast"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/mdast-util-to-markdown.git"},"bugs":{"url":"https://github.com/syntax-tree/mdast-util-to-markdown/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"types":"types","dependencies":{"@types/unist":"^2.0.0","longest-streak":"^2.0.0","mdast-util-to-string":"^2.0.0","parse-entities":"^2.0.0","repeat-string":"^1.0.0","zwitch":"^1.0.0"},"devDependencies":{"browserify":"^17.0.0","dtslint":"^4.0.0","mdast-util-from-markdown":"^0.8.0","nyc":"^15.0.0","prettier":"^2.0.0","remark-cli":"^9.0.0","remark-preset-wooorm":"^8.0.0","tape":"^5.0.0","tinyify":"^3.0.0","unist-util-remove-position":"^3.0.0","xo":"^0.37.0"},"scripts":{"format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","build":"browserify . -s mdastUtilToMarkdown -p tinyify > mdast-util-to-markdown.min.js","test-api":"node test","test-coverage":"nyc --reporter lcov tape test.js","test-types":"dtslint types","test":"npm run format && npm run build && npm run test-coverage && npm run test-types"},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"esnext":false,"rules":{"complexity":"off","unicorn/prefer-includes":"off"},"ignores":["types/"]},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"ca4b5059cb33bd4ccd8115bddd645a11f294017c","homepage":"https://github.com/syntax-tree/mdast-util-to-markdown#readme","_id":"@elog/mdast-util-to-markdown@0.6.6","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-ema7Cqp1nXZZD28xcuGHH/EPdgtSG1U+c3ZzmglggqMM5nMIRbLP9Qj7yIu0nPO+AP1k468eByMwNwzt+T1NmQ==","shasum":"3626fd1a74e8e0e5ba3b71dda471969c40b6b8e4","tarball":"https://registry.npmjs.org/@elog/mdast-util-to-markdown/-/mdast-util-to-markdown-0.6.6.tgz","fileCount":47,"unpackedSize":51210,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHxsXU0MnYrh8stDjpdVrCCKnaRu7+FJSWOBj83iIQxlAiAGKBSVdvZP9faxiqIwnazbNfi5P9UxEHChj9IzDT4V2A=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkRRwyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrImw/9H1RgGPdClzc9YAb6lqzKP+GxMOWKeNeanjywXIH7Emz2Eq4P\r\notgoLtnT9RqKX/GSgVU0m07KF3hw7EL1aEouZAiT37exO05X231whqSbUlZl\r\n7b4RwlT/rqDSzX9cMp07l096nMk6IqcWsltXF0S07ALrNEPn4zT7bwQFnt48\r\nbU6NaJr/RDkMfVivaUjVIrr/U2KISXwz1gj3JkKgdEOUwL18IEs8mocxJV+E\r\nDuMchwY33LRAwIX6WYYZccCXsez41g4P3CUeHAVsd1Cq+3rkff23tiL7yFZg\r\n565yOO24P/UG5fcN4hHeYRsoQkMLPQ+LQnTRfcPDT7TbYJ0D+m1qPowGZ+yR\r\n9foIWg14uNReWb75FGKEjtMx0ZzPGZ3IpVvvGKaE9k2ybr+MwIlGjpmChizO\r\nTINV3E4uA0FpCoKu+P5tEC/YHdc1aIo6GgKYPASBSa27qLobhtj4Q73qtytF\r\nUbev6CfDPSBAI8nFjchGtR6LjPH+jgABykGFeVTpj+o4K3jLW+qgIjxJGBmB\r\nSQosK5AHEmzOc+LW1dKSe0GtwBQeL3S2UslGgnwVBL9ZDSSR3x7gT4SkgLGF\r\nGnnUK6wHgB8dGmO6LM/uIbICPqjjz6AwCHprcipbrbz+xN0DeRHLahyBsu+o\r\nGFQ8HPqSzHBZw+I1gl/JDqaU/IttLNMDRG0=\r\n=YRRc\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"letttgaco","email":"angrycat2333@gmail.com"},"directories":{},"maintainers":[{"name":"letttgaco","email":"angrycat2333@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mdast-util-to-markdown_0.6.6_1682250802143_0.5752547045374552"},"_hasShrinkwrap":false}},"time":{"created":"2023-04-23T11:53:22.076Z","0.6.6":"2023-04-23T11:53:22.328Z","modified":"2023-04-23T11:53:22.524Z"},"maintainers":[{"name":"letttgaco","email":"angrycat2333@gmail.com"}],"description":"mdast utility to serialize markdown","homepage":"https://github.com/syntax-tree/mdast-util-to-markdown#readme","keywords":["unist","mdast","mdast-util","util","utility","markdown","markup","serialize","stringify","compile","syntax","tree","ast"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/mdast-util-to-markdown.git"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"bugs":{"url":"https://github.com/syntax-tree/mdast-util-to-markdown/issues"},"license":"MIT","readme":"# mdast-util-to-markdown\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[mdast][]** utility to parse markdown.\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install mdast-util-to-markdown\n```\n\n## Use\n\nSay we have the following script, `example.js`:\n\n```js\nvar toMarkdown = require('mdast-util-to-markdown')\n\nvar tree = {\n  type: 'root',\n  children: [\n    {\n      type: 'blockquote',\n      children: [\n        {type: 'thematicBreak'},\n        {\n          type: 'paragraph',\n          children: [\n            {type: 'text', value: '- a\\nb !'},\n            {\n              type: 'link',\n              url: 'example.com',\n              children: [{type: 'text', value: 'd'}]\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}\n\nconsole.log(toMarkdown(tree))\n```\n\nNow, running `node example` yields (note the properly escaped characters which\nwould otherwise turn into a list and image respectively):\n\n```markdown\n> ***\n>\n> \\- a\n> b \\![d](example.com)\n```\n\n## API\n\n### `toMarkdown(tree[, options])`\n\nSerialize **[mdast][]** to markdown.\n\n##### Formatting options\n\n###### `options.bullet`\n\nMarker to use to for bullets of items in unordered lists (`'*'`, `'+'`, or `'-'`,\ndefault: `'*'`).\n\n###### `options.closeAtx`\n\nWhether to add the same number of number signs (`#`) at the end of an ATX\nheading as the opening sequence (`boolean`, default: `false`).\n\n###### `options.emphasis`\n\nMarker to use to serialize emphasis (`'*'` or `'_'`, default: `'*'`).\n\n###### `options.fence`\n\nMarker to use to serialize fenced code (``'`'`` or `'~'`, default: ``'`'``).\n\n###### `options.fences`\n\nWhether to use fenced code always (`boolean`, default: `false`).\nThe default is to fenced code if there is a language defined, if the code is\nempty, or if it starts or ends in empty lines.\n\n###### `options.incrementListMarker`\n\nWhether to increment the value of bullets of items in ordered lists (`boolean`,\ndefault: `true`).\n\n###### `options.listItemIndent`\n\nWhether to indent the content of list items with the size of the bullet plus one\nspace (when `'one'`) or a tab stop (`'tab'`), or depending on the item and its\nparent list (`'mixed'`, uses `'one'` if the item and list are tight and `'tab'`\notherwise) (`'one'`, `'tab'`, or `'mixed'`, default: `'tab'`).\n\n###### `options.quote`\n\nMarker to use to serialize titles (`'\"'` or `\"'\"`, default: `'\"'`).\n\n###### `options.resourceLink`\n\nWhether to use reference links always (`boolean`, default: `false`).\nThe default is to use autolinks (`<https://example.com>`) when possible.\n\n###### `options.rule`\n\nMarker to use for thematic breaks (`'*'`, `'-'`, or `'_'`, default: `'*'`).\n\n###### `options.ruleRepetition`\n\nNumber of markers to use for thematic breaks (`number`, default:\n`3`, min: `3`).\n\n###### `options.ruleSpaces`\n\nWhether to add spaces between markers in thematic breaks (`boolean`, default:\n`false`).\n\n###### `options.setext`\n\nWhether to use setext headings when possible (`boolean`, default: `false`).\nSetext headings are not possible for headings with a rank more than 2 or when\nthey’re empty.\n\n###### `options.strong`\n\nMarker to use to serialize strong (`'*'` or `'_'`, default: `'*'`).\n\n###### `options.tightDefinitions`\n\nWhether to join definitions w/o a blank line (`boolean`, default: `false`).\nShortcut for a join function like so:\n\n```js\nfunction (left, right) {\n  if (left.type === 'definition' && right.type === 'definition') {\n    return 0\n  }\n}\n```\n\n###### `options.handlers`\n\nObject mapping node types to custom handlers.\nUseful for syntax extensions.\nTake a look at [`lib/handle`][handlers] for examples.\n\n###### `options.join`\n\nList of functions used to determine what to place between two flow nodes.\nOften, they are joined by one blank line.\nIn certain cases, it’s nicer to have them next to each other.\nOr, they can’t occur together.\nThese functions receive two adjacent nodes and their parent and can return\n`number` or `boolean`, referring to how many blank lines to use between them.\nA return value of `true` is as passing `1`.\nA return value of `false` means the nodes cannot be joined by a blank line, such\nas two adjacent block quotes or indented code after a list, in which case a\ncomment will be injected to break them up:\n\n```markdown\n> Quote 1\n\n<!---->\n\n> Quote 2\n```\n\n###### `options.unsafe`\n\nList of patterns to escape.\nUseful for syntax extensions.\nTake a look at [`lib/unsafe.js`][unsafe] for examples.\n\n##### Extension options\n\n###### `options.extensions`\n\nList of extensions (`Array.<ToMarkdownExtension>`).\nEach `ToMarkdownExtension` is an object with the same interface as `options`\nhere.\n\n##### Returns\n\n`string` — Serialized markdown.\n\n## List of extensions\n\n*   [`syntax-tree/mdast-util-directive`](https://github.com/syntax-tree/mdast-util-directive)\n    — serialize directives\n*   [`syntax-tree/mdast-util-footnote`](https://github.com/syntax-tree/mdast-util-footnote)\n    — serialize footnotes\n*   [`syntax-tree/mdast-util-frontmatter`](https://github.com/syntax-tree/mdast-util-frontmatter)\n    — serialize frontmatter (YAML, TOML, more)\n*   [`syntax-tree/mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm)\n    — serialize GFM\n*   [`syntax-tree/mdast-util-gfm-autolink-literal`](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal)\n    — serialize GFM autolink literals\n*   [`syntax-tree/mdast-util-gfm-strikethrough`](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)\n    — serialize GFM strikethrough\n*   [`syntax-tree/mdast-util-gfm-table`](https://github.com/syntax-tree/mdast-util-gfm-table)\n    — serialize GFM tables\n*   [`syntax-tree/mdast-util-gfm-task-list-item`](https://github.com/syntax-tree/mdast-util-gfm-task-list-item)\n    — serialize GFM task list items\n*   [`syntax-tree/mdast-util-math`](https://github.com/syntax-tree/mdast-util-math)\n    — serialize math\n*   [`syntax-tree/mdast-util-mdx`](https://github.com/syntax-tree/mdast-util-mdx)\n    — serialize MDX or MDX.js\n*   [`syntax-tree/mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression)\n    — serialize MDX or MDX.js expressions\n*   [`syntax-tree/mdast-util-mdx-jsx`](https://github.com/syntax-tree/mdast-util-mdx-jsx)\n    — serialize MDX or MDX.js JSX\n*   [`syntax-tree/mdast-util-mdxjs-esm`](https://github.com/syntax-tree/mdast-util-mdxjs-esm)\n    — serialize MDX.js ESM\n\n## Security\n\n`mdast-util-to-markdown` will do its best to serialize markdown to match the\nsyntax tree, but there are several cases where that is impossible.\nIt’ll do its best, but complete roundtripping is impossible given that any value\ncould be injected into the tree.\n\nAs Markdown is sometimes used for HTML, and improper use of HTML can open you up\nto a [cross-site scripting (XSS)][xss] attack, use of `mdast-util-to-markdown`\nand parsing it again later could potentially be unsafe.\nWhen parsing markdown afterwards and then going to HTML, use something like\n[`hast-util-sanitize`][sanitize] to make the tree safe.\n\n## Related\n\n*   [`micromark/micromark`](https://github.com/micromark/micromark)\n    — the smallest commonmark-compliant markdown parser that exists\n*   [`remarkjs/remark`](https://github.com/remarkjs/remark)\n    — markdown processor powered by plugins\n*   [`syntax-tree/mdast-util-from-markdown`](https://github.com/syntax-tree/mdast-util-from-markdown)\n    — parse markdown to mdast\n\n## Contribute\n\nSee [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get\nstarted.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/syntax-tree/mdast-util-to-markdown/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/mdast-util-to-markdown/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-to-markdown.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/mdast-util-to-markdown\n\n[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-to-markdown.svg\n\n[downloads]: https://www.npmjs.com/package/mdast-util-to-markdown\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-to-markdown.svg\n\n[size]: https://bundlephobia.com/result?p=mdast-util-to-markdown\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md\n\n[mdast]: https://github.com/syntax-tree/mdast\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[sanitize]: https://github.com/syntax-tree/hast-util-sanitize\n\n[handlers]: lib/handle\n\n[unsafe]: lib/unsafe.js\n","readmeFilename":"README.md"}