Skip to content

Find or write mdbook plugin to have code blocks in tables #17

@Bromeon

Description

@Bromeon

Problem

Neither Markdown dialect seems to support fenced code blocks in tables.
Something like this (here HTML):

GDScript Rust
class_name MyClass
extends Node
        
#[derive(GodotClass)]
#[class(base=Node)]
struct MyClass;
In mdbook, it's possible to use raw HTML, but it's also very unreadable.
This is the source for the above. Yes, the line breaks need to be like that to avoid trailing/leading empty lines.
<table>
<thead>
  <tr>
    <th>GDScript</th>
    <th>Rust</th>
  </tr>
</thead>
<tr>
    <td>
        <pre>
class_name MyClass
extends Node
        </pre>
    </td>
    <td>
        <pre>#[derive(GodotClass)]
#[class(base=Node)]
struct MyClass;
</pre>
    </td>
  </tr>
</table>

Possible solutions

With mdbook, the tag <code class="language-rust"> can be used for syntax highlighting instead of <pre>.

We should research if there is an mdbook plugin achieving something similar, or write our own.

If we do it ourselves, it doesn't necessarily need to be generic and reusable. We could just start to support the above case and take it from there. Even something simple such as

```codetable left="gdscript" right="rust"
class_name MyClass
extends Node
---
#[derive(GodotClass)]
#[class(base=Node)]
struct MyClass;
```

could be transformed into the verbose HTML above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    toolingCI, mdBook and other infrastructure

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions