Div Reuse

Write a block once, place it wherever it belongs.

What the div-reuse extension is for, how to enable it, and the smallest pair of a source div and a reuse that copies it.

Code has functions, so a block of logic is written once and called from wherever it is needed. Prose has copy and paste, and the second copy starts drifting the moment the first is edited.

div-reuse applies the first idea to the second problem. Give a fenced div an identifier, and any other div can pull its content in by name, optionally shifting its headings, taking only part of it, renaming its identifiers, or filling in variables.

Installation

quarto add mcanouil/quarto-div-reuse@1.4.3

This will install the extension under the _extensions subdirectory. If you are using version control, you will want to check in this directory.

Or install it from your editor with Quarto Wizard:

Quick start

Enable the filter:

filters:
  - div-reuse

Then name a source and reuse it:

::: {#house-style}
Commit early, commit often, and write the message for the reader.
:::

::: {reuse="house-style"}
:::

The source:

Commit early, commit often, and write the message for the reader.

And the reuse, which produces the same content again:

Commit early, commit often, and write the message for the reader.

See the Reference for every attribute, and the Examples for each transform rendered.

Where it works

Every output format. The filter rewrites the document before any writer runs, so reused content behaves exactly like content you typed twice.

Back to top