How is GFM different from CommonMark?
· 3 min read
GitHub Flavored Markdown (GFM) is a strict superset of the CommonMark specification. This means that GFM includes all the features of CommonMark and adds several of its own, making it a more feature-rich dialect of Markdown.
The key differences between GFM and CommonMark lie in the extra features GFM provides to support the collaborative nature of a platform like GitHub.
Key Differences
Feature | CommonMark | GFM |
---|---|---|
Tables | Not supported by default. | Supported. Uses pipe ` |
Task Lists | Not supported. | Supported. Creates interactive checkboxes in lists. |
Strikethrough | Not supported. | Supported. Uses two tildes ~~ to cross out text. |
Autolinks | Requires angle brackets <...> for URLs. | Enhanced. Automatically links URLs and email addresses without brackets. |
Mentions | Not supported. | Supported. Automatically links @username to a user's profile. |
References | Not supported. | Supported. Links #issue-number and commit_sha to issues and commits. |
Disallowed HTML | Allows a wider range of raw HTML. | Stricter. Sanitizes or disallows certain HTML tags for security. |
Why GFM is More Useful on GitHub
GFM's additions are specifically designed to enhance communication and collaboration within a software development context. For example:
- Task lists are essential for managing to-do items directly within issues or pull requests.
- Mentions and references (
#123
orgit-sha
) create a powerful web of links that connect discussions, code, and commits, making project history easy to navigate. - Tables and strikethrough provide simple ways to organize information and communicate changes clearly.
While a document written in CommonMark will render correctly on GitHub, it cannot take advantage of these platform-specific features.