Skip to content

qmd writer drops trailing blank line inside a code block #173

@rundel

Description

@rundel

A CodeBlock with text that ends with \n round-trips with the trailing newline removed. The writer emits the closing fence directly after the last content character, so the re-parser sees one fewer line of content. Could be fixed either in the parser or the writer.

$ printf -- '```markdown\nfoo\n\n```\n'
```markdown
foo

```

$ printf -- '```markdown\nfoo\n\n```\n' | cargo run --bin pampa --
[ CodeBlock ( "" , ["markdown"] , [] ) "foo\n" ]

$ printf -- '```markdown\nfoo\n\n```\n' | cargo run --bin pampa -- -t qmd
```markdown
foo
```

$ printf -- '```markdown\nfoo\n\n```\n' | cargo run --bin pampa -- -t qmd | cargo run --bin pampa --
[ CodeBlock ( "" , ["markdown"] , [] ) "foo" ]

Examples from 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