jgm / djot.js

JavaScript implementation of djot
MIT License
151 stars 16 forks source link

Multiple classes together are not parsed as attributes #98

Open calebeby opened 1 week ago

calebeby commented 1 week ago
{.foo}
hi

produces

doc
  para class="foo"
    str text="hi"

as expected. But if I add a second class:

{.foo.bar}
hi

It produces text instead of classes:

doc
  para
    str text="{.foo.bar}"
    soft_break
    str text="hi"

It looks like the documentation says multiple classes should be allowed in this way.

calebeby commented 1 week ago

I was looking through the tests and I saw that there are tests for multiple classes written like this: {.foo .bar}. That seems to work! The haskell implementation supports {.foo.bar} but the JS one does not. Is that syntax intended to be supported? If not, can we update the documentation to give an example of multiple classes? I had assumed they would be combined like .foo.bar since that is how you would specify multiple classes together in CSS selectors.

jgm commented 1 week ago

The intent was to require a space, but this is something to think about. Note that pandoc -f markdown treats {.foo.bar} as a single class foo.bar, djot.js fails to parse this as an attribute at all, and pandoc -f djot treats it as two classes.

Similar questions could be raised about things like .foo#baz and key=val#baz.

calebeby commented 1 week ago

I think requiring a space is fine since that is how you separate other attributes!