Introduction
remark-gfm is a plugin for remark that adds support for GitHub Flavored Markdown (GFM) features. This guide covers all the GFM features supported by the package and provides practical examples for each.Installation and Setup
npm install remark-gfmIntegration with Remark
import rehypeStringify from 'rehype-stringify'
import remarkGfm from 'remark-gfm'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import {read} from 'to-vfile'
import {unified} from 'unified'
const file = await unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeStringify)
.process(await read('example.md'))
console.log(String(file))Autolink Literals
GFM automatically converts URLs and email addresses to links without requiring explicit markdown link syntax.Examples
Visit our website at www.company.com or contact us at support@company.com.
Follow us on https://twitter.com/company for updates.Limitations and Best Practices:
- Autolinks must be surrounded by whitespace
- URLs with special characters might need explicit linking
- Some domains might require explicit
http://orhttps://prefix
Footnotes
Footnotes allow you to add references and additional information without cluttering the main content.Basic Syntax
Here's a statement that needs a reference[^1].
[^1]: This is the reference text.Examples
Here's a complex example[^example] with multiple footnotes[^multiple] demonstrating different use cases[^different].
[^example]: First footnote with simple text.
[^multiple]: Second footnote with multiple lines:
- Supporting point 1
- Supporting point 2
- Supporting point 3
[^different]: Third footnote with `code` and [links](https://example.com).Best Practices:
- Use meaningful reference labels
- Keep footnotes concise
- Consider using inline footnotes for brief additions
- Order footnotes logically
Strikethrough
Strikethrough text is useful for showing changes, updates, or deprecated information.Basic Syntax
~~Strikethrough text~~Examples
- Showing Changes:
- Original price:
$99.99Now: $79.99
- Task Updates:
Complete initial draftReview with team- Publish document
- Deprecated Features:
Use legacy APIUse new v2 API endpoints
Nested Formatting
You can combine strikethrough with other formatting:Bold strikethroughItalic strikethroughcode strikethrough
Tables
Tables in GFM provide flexible ways to organize and present data.Alignment Options: Left-aligned (Default)
| Header 1 | Header 2 | Header 3 |
| - | - | - |
| Row 1 | Data | Data |
| Row 2 | Data | Data || Header 1 | Header 2 | Header 3 |
|---|---|---|
| Row 1 | Data | Data |
| Row 2 | Data | Data |
Alignment Options: Right-aligned
| Header 1 | Header 2 | Header 3 |
| -: | -: | -: |
| Row 1 | Data | Data |
| Row 2 | Data | Data || Header 1 | Header 2 | Header 3 |
|---|---|---|
| Row 1 | Data | Data |
| Row 2 | Data | Data |
Alignment Options: Center-aligned
| Header 1 | Header 2 | Header 3 |
| :-: | :-: | :-: |
| Row 1 | Data | Data |
| Row 2 | Data | Data || Header 1 | Header 2 | Header 3 |
|---|---|---|
| Row 1 | Data | Data |
| Row 2 | Data | Data |
Alignment Options: Mixed Alignment
| Left | Center | Right |
| :- | :-: | -: |
| Text | Text | Text |
| Data | Data | Data || Left | Center | Right |
|---|---|---|
| Text | Text | Text |
| Data | Data | Data |
Best Practices for Tables
- Keep tables simple and readable
- Use consistent column widths
- Align numbers right
- Align text left
- Use center alignment sparingly
Tasklists
Tasklists (or checklists) are perfect for tracking progress and creating interactive to-do lists.Basic Syntax
- [ ] Unchecked item
- [x] Checked item- Unchecked item
- Checked item
Examples
Project Checklist
- Project Setup
- Initialize repository
- Set up development environment
- Configure CI/CD
- Development Phase
- Create basic structure
- Implement core features
- Write tests
- Deployment
- Prepare documentation
- Deploy to staging
- Deploy to production
Release Checklist
- Code review completed
- Tests passed
- Documentation updated
- Version bumped
- Changelog updated
- Release notes prepared
Best Practices:
- Use hierarchical structure for complex tasks
- Keep items concise
- Update regularly
- Include completion dates for tracked items
Compatibility and Browser Support
| Feature | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
| Autolinks | ✅ | ✅ | ✅ | ✅ |
| Footnotes | ✅ | ✅ | ✅ | ✅ |
| Strikethrough | ✅ | ✅ | ✅ | ✅ |
| Tables | ✅ | ✅ | ✅ | ✅ |
| Tasklists | ✅ | ✅ | ✅ | ✅ |