Fragment Templates
how to enable and use fragment templates to dynamically render Markdown links and code blocks
September 22, 2025
Samantha Monty
Chair for Human-Computer Interaction, University of Würzburg

Fragment Templates

  • Fragment templates use the Pandoc template syntax and processor to transform Markdown link and code block elements

Experimental

Fragment templates are hidden behind a flag and need to be explicitly enabled

needed configurations :

experiments:
  fragment-templates: true

Template Search Pathes

In order of preference

  1. Document base directory
  2. Project’s dir /templates folder
  3. Resource pack’s support/templates folder

  1. arg1: arg0
  2. arg2: arg1
  3. arg3: arg2
  4. url: url
  5. title: title
  6. id: theid
  7. class1: class1
  8. class2: class2
  9. args: arg0 arg1 arg2
  10. classes: class1 class2
  11. attribs: attr1="attr1" attr2="attr2"
  12. code:

Source code

Macro all-params-

<ol>
<li>arg1: <strong>${arg1}</strong></li>
<li>arg2: <strong>${arg2}</strong></li>
<li>arg3: <strong>${arg3}</strong></li>
<li>url: <strong>${url}</strong></li>
<li>title: <strong>${title}</strong></li>
<li>id: <strong>${id}</strong></li>
<li>class1: <strong>${class1}</strong></li>
<li>class2: <strong>${class2}</strong></li>
<li>args: <strong>${args}</strong></li>
<li>classes: <strong>${classes}</strong></li>
<li>attribs: <strong>${attribs}</strong></li>
<li>code: 
  <pre><code><strong>${code}</strong></code></pre>
</li>
</ol>

  1. arg1:
  2. arg2:
  3. arg3:
  4. url:
  5. title:
  6. id: theid
  7. class1: all-params-
  8. class2: class1
  9. args:
  10. classes: all-params- class1 class2
  11. attribs: attr1="attr1" attr2="attr2"
  12. code:
    The Code.
    Probably many lines.

Souce code

Codeblock Templates

``` {#theid .all-params- .class1 .class2 attr1="attr1" attr2="attr2"}
The Code.
Probably many lines.
```

Live Coding Macro

Source code

``` {.live-code- language="python"}
print(42)
```

Result

print(42)
python
Captions are swell!

Live Coding Prelude

Prelude

import static java.lang.System.out;
##CODE##

Live Code

out.println(42);
java

Grid Test

canvas

grid

finegrid

Source code

# Grid Test {.columns}

## `canvas` {.left}

[§canvas](500px)

## `grid` {.center}

[§grid](500px)

## `finegrid` {.right}

[§finegrid](500px)

Meta Data in Fragment Template

Meta Data in Fragment Templates

key value
resource-pack
experiments.fragment-templates true
index.progress true
chart.defaults.font.size 20