Skip to content

Inline \ round-trip splits one Str into three inlines #162

@rundel

Description

@rundel

A literal backslash followed by a space in inline text parses as a single Str containing the backslash and what follows. The writer emits the backslash as \\, which on re-parse produces a separate Str "\\" plus a Space plus the next Str. Source rendering is equivalent but the AST structure differs.

$ printf -- 'a \\ b\n'
a \ b

$ printf -- 'a \\ b\n' | cargo run --bin pampa --
[ Para [Str "a", Space, Str "\\ b"] ]

$ printf -- 'a \\ b\n' | cargo run --bin pampa -- -t qmd
a \\ b

$ printf -- 'a \\ b\n' | cargo run --bin pampa -- -t qmd | cargo run --bin pampa --
[ Para [Str "a", Space, Str "\\", Space, Str "b"] ]

A \ not followed by a space (e.g. foo\bar, or trailing \ for LineBreak in a paragraph) round-trips correctly. The shape that triggers this in the wild is a trailing \ inside a pipe-table cell (cell padding inserts the space):

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