Skip to content

Writer does not emit \' for apostrophes that the reader would otherwise reject as quote opens #201

@rundel

Description

@rundel

The reader rejects a bare ' between a letter and a space as an unmatched smart-quote open (Q-2-10) and instructs the user to escape it as \'. The reader correctly accepts the escaped form and produces an apostrophe in the AST. The writer, however, drops the escape: given a Pandoc AST containing the apostrophe, it emits ' rather than \', so its output fails to re-parse through the reader.

$ printf -- "reveal.js\\' jump-to-slide.\n" | cargo run --bin pampa -- 2>&1
[ Para [Str "reveal.js’", Space, Str "jump-to-slide."] ]

$ printf -- "reveal.js\\' jump-to-slide.\n" | cargo run --bin pampa -- -t qmd 2>&1
reveal.js' jump-to-slide.

$ printf -- "reveal.js\\' jump-to-slide.\n" | cargo run --bin pampa -- -t qmd 2>/dev/null | cargo run --bin pampa -- 2>&1
Error: [Q-2-10] Closed Quote Without Matching Open Quote
   ╭─[ <stdin>:1:11 ]
   │
 1 │ reveal.js' jump-to-slide.
   │          ┬┬
   │          ╰─── This is the opening quote. If you need an apostrophe, escape it with a backslash.
   │           │
   │           ╰── A space is causing a quote mark to be interpreted as a quotation close.
───╯

The writer needs to escape ' back to \' whenever the surrounding context (letter on the left, whitespace on the right) would cause the reader to misclassify it as a quote open.

In the wild (quarto-web):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions