Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 1.78 KB

README.md

File metadata and controls

65 lines (46 loc) · 1.78 KB

Div-reuse Extension For Quarto

This is a Quarto extension applying the concept of "code reuse" to the content of a Markdown fenced div.

Installing

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.

Using

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.

Example

Here is the source code for a minimal example: example.qmd.

Outputs of example.qmd: