jgm / djot.js

JavaScript implementation of djot
MIT License
141 stars 15 forks source link

Caption parsing is buggy #57

Closed matklad closed 11 months ago

matklad commented 1 year ago
| 1 | 2 |

 ^ cap1

 ^ cap2

Ast:

doc
  table
    caption
      str text="cap2"
    caption
      str text="cap1"
    caption
    row head=false
      cell head=false align="default"
        str text="1"
      cell head=false align="default"
        str text="2"

Two problems here:

matklad commented 1 year ago

One thing I've been thinking about is that perhaps, rather than additing captions to the table, we should have

interface Table extends HasAttributes {
  tag: "table";
  children: Row[];
}

interface Figure extends HasAttributes {
  tag: "figure";
  children: [Block, Caption]
}

and allow catptions on any block. I certainly would like to be able to caption my code block at times!

jgm commented 1 year ago

This is how typst is doing it, if I recall correctly. Captions on code blocks are a common request in pandoc.

jgm commented 11 months ago

I think I've fixed the bug. Perhaps the suggestion about generalizing captions could go in a separate issue so we don't lose track.