Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown: parse fenced_code_attributes extension #445

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edwintorok
Copy link

Pandoc supports this extension: https://pandoc.org/MANUAL.html#extension-fenced_code_attributes


And this:

Recognize them in the lexer. Try to limit the complexity of the regular expression by splitting off parsing of attributes into a separate 'parse' (otherwise we hit automata size limits in ocamllex).

According to
https://quarto.org/docs/authoring/markdown-basics.html#ordering-of-attributes the ordering has to be:

  • #identifiers
  • .classes
  • key-value attributes

For now on output we always normalize to this form (which isn't ideal, but could be improved later):

I initially tried to fully parse the attributes, but I've exceeded the maximum size of the ocamllex automaton, so I kept it simple in this PR (and do some minimal parsing in OCaml later, note that key-value pairs aren't split correctly, but when joined backed together they retain the original value).

Pandoc supports this extension: https://pandoc.org/MANUAL.html#extension-fenced_code_attributes
``` {#identifier .language attr="value"}

```

And this:
``` language {#identifier attr="value"}
```

Recognize them in the lexer. Try to limit the complexity of the regular
expression by splitting off parsing of attributes into a separate 'parse'
(otherwise we hit automata size limits in `ocamllex`).

According to
https://quarto.org/docs/authoring/markdown-basics.html#ordering-of-attributes
the ordering has to be:
* #identifiers
* .classes
* key-value attributes

Signed-off-by: Edwin Török <[email protected]>
@edwintorok
Copy link
Author

(this PR might need some wider testing to check it doesn't break backwards compatibility, is there a larger corpus you'd normally test changes like this on? e.g. the realworldocaml book, anything else?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant