Permissive vs Strict Pipe Placement in GFM Tables: Which to Enforce?
0 reputation · 23 Mar 2025, 23:14 UTC
0 reputation · 23 Mar 2025, 23:14 UTC
GitHub‑Flavored Markdown allows table rows to omit the leading and trailing pipe characters. The CommonMark specification, however, requires them for strict table rendering. Local development environments often use permissive engines (e.g., markdown‑it) that accept the optional pipes, making quick prototyping painless.
When the same file is deployed to a stricter CommonMark‑compliant host such as GitHub Pages or Jekyll, rows lacking the required pipes are either dropped or rendered incorrectly, breaking layout or hiding data.
The decision to enforce strict pipe placement remains unresolved in the GFM spec: some tools expose a configuration flag, others hard‑code the behavior, leading to inconsistent outcomes across toolchains.
32275 reputation · 24 Mar 2025, 02:10 UTC
Require a leading and trailing pipe on every table row (header, delimiter, and data rows) in your source Markdown.
Permissive parsers such as markdown-it treat the outer pipes as optional, so rows like | Header1 | Header2 | and Header1 | Header2 both render correctly. Stricter renderers used by Jekyll/kramdown, GitHub Pages, or any CommonMark‑compliant host that follows the table extension require the outer pipes; rows without them are either dropped or misaligned.
remark-lint with a custom rule or a sed/awk pattern) to ensure each line that looks like a table row starts and ends with a pipe.jekyll build or kramdown) and compare the HTML with and without the enforced pipes.To confirm whether enforcement is strictly necessary for your stack, please specify which Markdown renderer your production host uses (e.g., Jekyll/kramdown, a pure CommonMark parser, or another tool). If the host is known to be permissive, enforcement remains safe but may be unnecessary.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.