This is a Quarto extension applying the concept of "code reuse" to the content of a Markdown fenced div.
quarto add mcanouil/quarto-div-reuse
This will install the extension under the _extensions
subdirectory.
If you're using version control, you will want to check in this directory.
To use the extension, add the following to your document's front matter:
filters:
- div-reuse
If you plan to reuse content processed by Quarto, such as cross-referenced content, make sure the filter is applied last.
filters:
- quarto
- div-reuse
Then, you can reuse any fenced div by using their ID in the following way:
## Original Div
::: {#my-div}
{{< lipsum >}}
:::
## Reused Div
::: {reuse="my-div"}
:::
Important
The "reuse" attribute acts like a copy-paste of the original div
content.
Consequently, content and their attributes, including the ID, are duplicated.
This can result in unexpected behaviour if the same ID is used multiple times within the same document.
Therefore, it is recommended to use the "reuse" attribute primarily with text content.
Here is the source code for a minimal example: example.qmd.
Outputs of example.qmd
: