leandrocp / mdex

A CommonMark-compliant fast and extensible Markdown parser and formatter for Elixir.
https://mdex-c31.pages.dev
MIT License
128 stars 10 forks source link

How to support tables? #40

Closed matt-savvy closed 3 months ago

matt-savvy commented 3 months ago

Hello,

I am trying to get some tables working. Even with the example from GitHub Flavored Markdown Spec , it is still treated as plain text.

For example, this markdown:

| foo | bar |
| --- | --- |
| baz | bim |

Renders to html as

<p>| foo | bar |
| --- | --- |
| baz | bim |</p>

Is there any configuration I need to do to enable this? Thanks!

leandrocp commented 3 months ago

Hey @matt-savvy you're looking for the table extension:

MDEx.to_html(~S"""
| foo | bar |
| --- | --- |
| baz | bim |
""",
extension: [table: true])

You can see all available options at https://docs.rs/comrak/latest/comrak/struct.Options.html

Closing this one but feel free to add more comments. Thanks!

matt-savvy commented 3 months ago

Worked like a charm, thanks!

leandrocp commented 3 months ago

Hey @matt-savvy added a few more examples in the readme https://github.com/leandrocp/mdex?tab=readme-ov-file#github-flavored-markdown-with-emojis

matt-savvy commented 3 months ago

Examples look great, I'm sure they'll help the next time someone has the same question I did.