Heading Linking
- remark-heading-id:
remark-heading-idgenerates unique IDs for headings in your Markdown content without adding links. It focuses on improving the structure of your content by providing IDs that can be used for linking or styling, but it does not create visible anchor links. - remark-autolink-headings:
remark-autolink-headingsautomatically adds anchor links to headings in your Markdown content, making them easily shareable. It enhances the usability of your documents by allowing users to link directly to specific sections.
GitHub Flavored Markdown Support
- remark-parse:
remark-parseis a Markdown parser that focuses on converting Markdown content into an abstract syntax tree (AST). While it does not specifically support GitHub Flavored Markdown, it is extensible and can be combined with other plugins to add GFM features as needed. - remark-gfm:
remark-gfmprovides full support for GitHub Flavored Markdown, including features like strikethrough, task lists, and tables. It ensures that your Markdown content is rendered correctly and consistently with GitHub's Markdown engine, making it ideal for collaborative projects.
Slug Generation
- remark-slug:
remark-slugautomatically generates slugs for your Markdown headings, creating URL-friendly IDs that can be used for linking. This package is useful for ensuring that your headings have consistent and readable IDs, which can improve navigation and accessibility. - remark-heading-id:
remark-heading-idgenerates unique IDs for headings in your Markdown content, but it does not create slugs. It focuses on providing unique identifiers for each heading, which can be used for linking or styling, but does not ensure URL-friendliness.
Customization and Extensibility
- remark-parse:
remark-parseis highly extensible, allowing developers to create custom Markdown parsers and plugins. It provides a flexible architecture for building specialized parsing logic, making it suitable for projects that require tailored Markdown processing. - remark-gfm:
remark-gfmis designed to be used as a plugin within the Remark ecosystem, and while it is extensible, it is primarily focused on adding GFM features. Developers can customize its behavior, but it is not as flexible as a standalone parsing library. - remark-autolink-headings:
remark-autolink-headingsallows for some customization, such as modifying the link text and the way links are generated. However, it is primarily focused on the specific task of adding links to headings, so its extensibility is limited to that functionality.
Ease of Use: Code Examples
- remark-gfm:
import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkGfm from 'remark-gfm'; import remarkStringify from 'remark-stringify'; const markdown = `# Heading 1\n\n## Task List\n- [ ] Item 1\n- [x] Item 2\n\n| Table | Header |\n|-------|--------|\n| Row 1 | Data |`; unified() .use(remarkParse) .use(remarkGfm) .use(remarkStringify) .process(markdown) .then((file) => { console.log(String(file)); });This example demonstrates how to use
remark-gfmto parse and render GitHub Flavored Markdown, including task lists and tables. The output will correctly format these elements according to GFM specifications. - remark-slug:
import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkSlug from 'remark-slug'; import remarkStringify from 'remark-stringify'; const markdown = `# Heading 1\n\n## Heading 2`; unified() .use(remarkParse) .use(remarkSlug) .use(remarkStringify) .process(markdown) .then((file) => { console.log(String(file)); });This example demonstrates how to use
remark-slugto automatically generate slugs for your Markdown headings. The output will include the headings with their corresponding slugged IDs, which can be used for linking. - remark-heading-id:
import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkHeadingId from 'remark-heading-id'; import remarkStringify from 'remark-stringify'; const markdown = `# Heading 1\n\n## Heading 2`; unified() .use(remarkParse) .use(remarkHeadingId) .use(remarkStringify) .process(markdown) .then((file) => { console.log(String(file)); });This example shows how to use
remark-heading-idto generate unique IDs for headings in your Markdown content. The output will include the headings with their corresponding IDs, which can be used for linking or styling. - remark-autolink-headings:
import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkAutolinkHeadings from 'remark-autolink-headings'; import remarkStringify from 'remark-stringify'; const markdown = `# Heading 1\n\n## Heading 2`; unified() .use(remarkParse) .use(remarkAutolinkHeadings) .use(remarkStringify) .process(markdown) .then((file) => { console.log(String(file)); });This example shows how to use
remark-autolink-headingsto automatically add links to headings in your Markdown content. The output will include anchor links for each heading, making them easily shareable.


