Skip to content

Commit 52313bc

Browse files
authored
docs: FAQ entry for Markdown engines (#454)
1 parent 302e6dd commit 52313bc

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ Here's a few pointers to get you started:
137137

138138
## Frequently Asked Questions
139139

140+
### Why does mdformat backslash escape special syntax specific to MkDocs / Hugo / Obsidian / GitHub / some other Markdown engine?
141+
142+
Mdformat is a CommonMark formatter.
143+
It doesn't have out-of-the-box support for syntax other than what is defined in [the CommonMark specification](https://spec.commonmark.org/current/).
144+
145+
The custom syntax that these Markdown engines introduce typically reinvents the meaning of
146+
angle brackets, square brackets, parentheses, hash characters — characters that have a special meaning in CommonMark.
147+
Mdformat often resorts to backslash escaping these characters to ensure the formatting changes it makes never alters a rendered document.
148+
149+
Additionally some engines, namely MkDocs, [do not support](https://github.com/mkdocs/mkdocs/issues/1835) CommonMark to begin, so incompatibilities are unavoidable.
150+
151+
Luckily mdformat is extensible by plugins.
152+
For many Markdown engines you'll find support by searching
153+
[the plugin docs](https://mdformat.readthedocs.io/en/stable/users/plugins.html)
154+
or [mdformat GitHub topic](https://github.com/topics/mdformat).
155+
156+
You may also want to consider a documentation engine that adheres to CommonMark as its base syntax e.g. [mdBook](https://rust-lang.github.io/mdBook/) or [Sphinx with Markdown](https://www.sphinx-doc.org/en/master/usage/markdown.html).
157+
140158
### Why not use [Prettier](https://github.com/prettier/prettier) instead?
141159

142160
Mdformat is pure Python code!
@@ -157,10 +175,10 @@ according to the author themselves,
157175
is [inferior to markdown-it](https://github.com/remarkjs/remark/issues/75#issuecomment-143532326) used by mdformat.
158176
`remark-parse` v9.x is advertised as CommonMark compliant
159177
and presumably would fix many of the issues,
160-
but is not used by Prettier (v2.4.0) yet.
178+
but is not used by Prettier (v3.3.3) yet.
161179

162-
Prettier (v2.4.0), being able to format many languages other than Markdown,
163-
is a large package with 65 direct dependencies
180+
Prettier (v3.3.3), being able to format many languages other than Markdown,
181+
is a large package with 73 direct dependencies
164182
(mdformat only has one in Python 3.11+).
165183
This can be a disadvantage in many environments,
166184
one example being size optimized Docker images.

docs/contributors/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@ If using Poetry or Flit for packaging, the entry point configuration in `pyproje
125125

126126
## Making your plugin discoverable
127127

128-
In case you host your plugin on GitHub, make sure to add it under the "mdformat" topic so it shows up on https://github.com/topics/mdformat.
128+
In case you host your plugin on GitHub, make sure to add it under the "mdformat" topic so it shows up on <https://github.com/topics/mdformat>.

docs/users/plugins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ formatted = mdformat.text(unformatted, codeformatters={"python"})
2323
assert formatted == '```python\n"""black converts quotes"""\n```\n'
2424
````
2525

26-
### Existing plugins (see https://github.com/topics/mdformat for more!)
26+
### Existing plugins (more on [GitHub](https://github.com/topics/mdformat))
2727

2828
<table>
2929
<tr>
@@ -90,7 +90,7 @@ unformatted = "content...\n"
9090
formatted = mdformat.text(unformatted, extensions={"tables"})
9191
```
9292

93-
### Existing plugins (see https://github.com/topics/mdformat for more!)
93+
### Existing plugins (more on [GitHub](https://github.com/topics/mdformat))
9494

9595
<table>
9696
<tr>
@@ -154,7 +154,7 @@ formatted = mdformat.text(unformatted, extensions={"tables"})
154154

155155
Other plugins that don't fit the above categories.
156156

157-
### Existing plugins
157+
### Existing plugins (more on [GitHub](https://github.com/topics/mdformat))
158158

159159
<table>
160160
<tr>

0 commit comments

Comments
 (0)