Skip to content

Indented (4-space) code blocks are parsed as paragraphs, and re-emitted unindented #184

@rundel

Description

@rundel

CommonMark indented code blocks (lines starting with four spaces) are not recognized by pampa's parser. The indented content is parsed as a series of Para blocks (with the indentation stripped), so lines like - A and - B become Para [Str "-", Space, Str "A"] and Para [Str "-", Space, Str "B"]. The writer then emits each paragraph at column 0, producing - A\n\n- B, which the reader on the round trip recognises as a real BulletList.

$ printf 'Before.\n\n    categories:\n      - A\n      - B\n\nAfter.\n'
Before.

    categories:
      - A
      - B

After.

$ printf 'Before.\n\n    categories:\n      - A\n      - B\n\nAfter.\n' | cargo run --bin pampa --
[ Para [Str "Before."], Para [Str "categories:"], Para [Str "-", Space, Str "A"], Para [Str "-", Space, Str "B"], Para [Str "After."] ]

$ printf 'Before.\n\n    categories:\n      - A\n      - B\n\nAfter.\n' | cargo run --bin pampa -- -t qmd
Before.

categories:

- A

- B

After.

$ printf 'Before.\n\n    categories:\n      - A\n      - B\n\nAfter.\n' | cargo run --bin pampa -- -t qmd | cargo run --bin pampa --
[ Para [Str "Before."], Para [Str "categories:"], BulletList [[Para [Str "A"]], [Para [Str "B"]]], Para [Str "After."] ]

From quarto-web:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingerror-messagesissues about failures in error reporting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions