THE GITHTML FIELD GUIDE
Escape Markdown punctuation without damaging examples
Escape punctuation only where Markdown is interpreting it as formatting you do not intend. Use inline code for short literal tokens and fenced blocks for complete examples. Avoid escaping the entire document: the right fix depends on whether the character appears in prose, a link, a table, or a code example.
Locate the parser context before adding backslashes
Asterisks around a product name, brackets in a placeholder, and a leading number followed by a period can all be intentional text. The same character can also be structural syntax. Find the smallest example that reproduces the unwanted formatting and identify its context. Is it ordinary prose, the beginning of a line, a table cell, or already inside code? Do not copy an escape technique from one context into every other context. Start with a scratch sentence and the target renderer. This prevents a simple literal-character problem from becoming a document full of distracting backslashes and broken links.
Choose the representation that fits the reader's task
Use a targeted backslash escape when the punctuation is part of ordinary prose. Use inline code when the reader needs the exact token, such as a filename or pattern. Use a fenced block when preserving a complete source example matters. The sample shows the same asterisked word as prose and as a literal token. Avoid typographic substitutions that only resemble the original characters: a reader copying a regular expression or command needs the real syntax. If a placeholder uses angle brackets, explain whether those brackets are literal or must be replaced, rather than relying on appearance to communicate that distinction.
The literal label is \*preview\*.
The exact token is `*preview*`.Check what survives rendering and copying
Preview the corrected paragraph and copy the relevant text into a plain-text buffer. Confirm both that unintended emphasis is gone and that the intended characters remain. Then run the project's formatter and repeat the comparison. Watch for a fix that works in GitHub but changes under an exporter with different extensions enabled. Keep escapes local and documented when they are surprising. A reviewer should understand why a backslash exists without having to reverse engineer the whole page. If several paragraphs need complex escaping, reconsider the presentation: a dedicated example with an explanatory caption may communicate the same information more clearly.
- Reduce the failure to one sentence and identify whether the punctuation is prose or a literal token.
- Use the smallest targeted escape and verify the copied result, not just the preview.
- Recheck after formatting and conversion, especially when another parser consumes the same source.
- Keep a before-and-after fixture for unusual syntax so future cleanup does not remove an intentional escape.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.