Skip to content

issue better error message on encountering old-style code chunk options #152

Open

Description

@rundel

Chunks with old style options are mangled

An executable code block {r eval=FALSE} is re-written as {.{r} eval="FALSE"}.

$ printf -- '```{r eval=FALSE}\nx = 1\n```\n' | cargo run --bin pampa -- -t qmd
Warning: [Q-2-8] Code block options in header
. . .
```{.{r} eval="FALSE"}
x = 1
```

$ printf -- '```{r eval=FALSE}\nx = 1\n```\n' | cargo run --bin pampa --     
Warning: [Q-2-8] Code block options in header
. . .
[ CodeBlock ( "" , ["{r}"] , [("eval", "FALSE")] ) "x = 1" ]%    

Table caption attributes are not written

$ printf '%s\n' '| A | B |' '|---|---|' '| 1 | 2 |' '' ': ABCD {tbl-colwidths="[30,70]"}'
| A | B |
|---|---|
| 1 | 2 |

: ABCD {tbl-colwidths="[30,70]"}

$ printf '%s\n' '| A | B |' '|---|---|' '| 1 | 2 |' '' ': ABCD {tbl-colwidths="[30,70]"}' | cargo run --bin pampa -- -t qmd
| A   | B   |
| --- | --- |
| 1   | 2   |

: ABCD

$ printf '%s\n' '| A | B |' '|---|---|' '| 1 | 2 |' '' ': ABCD {tbl-colwidths="[30,70]"}' | cargo run --bin pampa --
[ Table ( "" , [] , [("tbl-colwidths", "[30,70]")] ) (Caption Nothing [ Plain [Str "ABCD"] ]) [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)] (TableHead ( "" , [] , [] ) [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "A"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "B"]] ] ]) [TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "1"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "2"]] ] ]] (TableFoot ( "" , [] , [] ) [] ) ]%   

Activity

  1. cscheid commented on May 3, 2026

    @cscheid
    Member

    An executable code block {r eval=FALSE} is re-written as {.{r} eval="FALSE"}.

    I'm sorry to report to you that this is no longer going to be valid syntax going forward. We plan to have helpers for people to convert, but I think we should actually be flagging that as a syntax error instead of a warning, because that round-tripping looks terrible.

    table attributes

    Hm. This looks like a bug. I'll ask Claude for a diagnosis and we'll take the fix design from there.

  2. cscheid commented on May 3, 2026

    @cscheid
    Member

    Bugfix for table round-trip incoming on #154. I'm not sure what to do with the other one yet.

  3. cscheid commented on May 3, 2026

    @cscheid
    Member

    Keeping this open for the first half of the issue, but the table roundtrip should work now on main. Thanks for the report!

  4. rundel commented on May 4, 2026

    @rundel
    ContributorAuthor

    Sounds good, removal of the chunk options makes sense in the longer term and I had already noticed that labels included in the {} resulted in an error (slightly more sad to see those going as I prefer the conciseness over #| label: but simplifying the parser is the greater good).

    Maybe part of this fix would be to make the error thrown for those clearer? Not sure it needs to be label specific

    printf '```{r test}\n1+1\n```\n' | cargo run --bin pampa -- -t qmd
    Error: Parse error
       ╭─[ <stdin>:1:6 ]
       │
     1 │ ```{r test}
       │      ──┬──  
       │        ╰──── unexpected character or token here
    ───╯
    ```
    
  5. cscheid commented on May 4, 2026

    @cscheid
    Member

    Yes, I think we might be able to do much better in that error using our tree-sitter LALR table error message system. Thanks for the idea, I'll come back to this in a few days or weeks.

  6. added
    bugSomething isn't working
    readers-writersParsing issues, round-trip discrepancies, writer bugs
    error-messagesissues about failures in error reporting
    enhancementNew feature or request
    and removed
    bugSomething isn't working
    on May 12, 2026
  7. changed the title [-]Minor qmd writer issues[/-] [+]issue better error message on encountering old-style code chunk options[/+] on May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesterror-messagesissues about failures in error reportingreaders-writersParsing issues, round-trip discrepancies, writer bugs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions