Div Reuse
Write a block once, place it wherever it belongs.
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.3This 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-reuseThen 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.
Links
- Reference for the full attribute list.
- Examples for every transform rendered.
- Changelog for what each release changed.
- Source and issues on GitHub.