Support pandoc fenced divs

Please add support for pandoc fenced divs.

Use case or problem

Applying CSS to text blocks that can be nested, including being able to add fenced code blocks within the nesting. For example, an Example admonition that contains both text and nested fenced code blocks. This would also provide a syntax that is more extendable for plugins than possible with fenced code blocks.

Proposed solution

Pandoc’s fenced divs work like fenced code blocks using ::: instead of back-ticks. However, a crucial difference is that they are mainly for text / prose and can be nested.

Editor mode could display them like a fenced code block, but use an alternative background colour and not switch to a monospace font. It could then also display bold, italics, and so on like normal within the block. Any nested code blocks could then be indented and displayed like normal.

So, an example admonition with a fenced code block would look like -

::: Example

This is some text, including some in bold and italics.

print("example code block)

And some more text.

:::

Current workaround (optional)

Currently, it is possible to apply special formatting using fenced code blocks and CSS snippets. However, as far as I am aware, it is not possible to nest them. Also, it breaks displaying bold, italics, highlighting, etc in editor mode as well as switches to monospace font which isn’t as nice for long prose inside a block.

Alternatively, <div> tags can be used, but the text does not stand out in editor mode the same way a block would. Also, using fenced divs keeps a markdown style syntax rather than switching to html. Pandoc also implements bracketed spans that could be used for a more markdown style inline formatting - e.g. [John Doe]{.cite}.

9 Likes

I agree, see Support pandoc line blocks - #2 by Moonbase59.

Supporting fenced divs would also make it easier using things like pandoc-latex-admonition:

---
documentclass: book
pandoc-latex-admonition:
  - color: firebrick
    classes: [admonition, danger]
    position: inner
    linewidth: 4
    nobreak: true
  - classes: [admonition]
    nobreak: true
---

::: {.admonition .danger} :::
Nunc maximus libero urna, non pulvinar sapien volutpat sit amet. Donec sit amet leo malesuada, euismod augue ac, fermentum sapien.
:::

:wink:

4 Likes

Yes, pandoc Markdown has a lot of nice (an useful!) syntax extensions to offer, but fenced divs would be IMO one of the most useful additions to Obsidian repertoire.

2 Likes