Markdown writer (with `smart`) turns a lone em/en dash into a thematic break
bug
When the Markdown writer has `smart` enabled (the default for `-t markdown`), an
em dash is written as `---` and an en dash as `--`. If those dashes end up alone
on a line, e.g. a paragraph whose only content is an em dash, the emitted
`---` re-parses as a thematic break (`HorizontalRule`). This is a **semantic**
round-trip change (`Para` becomes `HorizontalRule`), not just a cosmetic one.
## pandoc version
```
pandoc 3.9.0.2
```
## Steps to reproduce
A paragraph whose sole content is an em dash (`—`, U+2014):
```console
$ printf '—\n' | pandoc -f markdown -t native
[ Para [ Str "\8212" ] ]
$ printf '—\n' | pandoc -f markdown -t markdown
---
$ printf '—\n' | pandoc -f markdown -t markdown | pandoc -f markdown -t native
[ HorizontalRule ]
```
Pure AST round-trip (`native → markdown → native`) shows the same loss:
```console
$ printf '[Para [Str "—"]]\n' | pandoc -f native -t markdown | pandoc -f markdown -t native
[ HorizontalRule ]
```
## Expected
Round-tripping `Para [Str "—"]` through the Markdown writer and reader should
yield `Para [Str "—"]` again (as it does for any other character). The block
structure must not change.
## Actual
The paragraph becomes a thematic break (`HorizontalRule`).
关闭于 2026-05-31 1 条评论