Documenter.jl: SVG in table?

Created on 2 Jul 2021  路  7Comments  路  Source: JuliaDocs/Documenter.jl

I'm trying to put SVG images in tables, generating the Markdown from Julia code. I thought it might work, judging from the Markdown preview in Juno:

Screenshot 2021-07-02 at 09 47 36

but after generating the documents (include("docs/make.jl")) it reverts:

Screenshot 2021-07-02 at 09 51 13

Is there a way of putting SVG images into table cells?

Question

All 7 comments

It's kind of a combination of two issues:

  1. The Markdown parser does not support HTML. A workaround normally is to use at-raw blocks, but...
  2. at-blocks only get executed on the top-level of the document, so you can't put an at-raw in a table

Fixing (2) is the easier option -- I don't have any objections to executing at-repl/example/raw blocks in e.g. admonitions and tables. I think there is a duplicate issue for this, but I didn't find it right away.

Ah, OK, thanks.

I'm trying to generate color swatches programmatically (improving on this) but I'm struggling to find a way to do it better, using an HTML table and plain text. Any suggestions?

You can always generate the HTML too, and use @raw html blocks.

Oh, so if I generate this programmatically:


        ```@raw html
        <table>
        <thead>
        <tr>
        <th align="left">image in a table</th>
        </tr>
        </thead>
        <tbody><tr>
        <td align="left"><svg height="5em" width="5em" style="display: block; margin: 0 auto;"><circle fill="red" stroke-width=".1em" stroke="black" r="2em" cy="2.5em" cx="2.5em"></circle></svg></td>
        </tr>
        </tbody>
        </table>
        ```

it should work. Cool.

If it is generated anyway, you can also have a custom type with a text/html show method and put it in an at-eval block (something like the SVG example, with the definition of SVGCircle here).

Cool. I've got something working now - looks quite promising.

Considering how big the resulting .md files are, I think doing it dynamically might be better. I think you more or less just need to turn write_all_schemes_in_category into a show method. In any case, you probably don't want to commit the generated .md files?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thofma picture thofma  路  5Comments

mforets picture mforets  路  3Comments

cadojo picture cadojo  路  3Comments

galenlynch picture galenlynch  路  6Comments

lindnemi picture lindnemi  路  3Comments