https://github.com/mcanouil/quarto-div-reuse
The power of "code/content reuse" for seamless and efficient content creation.
https://github.com/mcanouil/quarto-div-reuse
code-reuse div-reuse filter lua quarto quarto-extension quarto-filter stable
Last synced: 3 months ago
JSON representation
The power of "code/content reuse" for seamless and efficient content creation.
- Host: GitHub
- URL: https://github.com/mcanouil/quarto-div-reuse
- Owner: mcanouil
- License: mit
- Created: 2025-02-03T22:45:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-16T21:12:48.000Z (3 months ago)
- Last Synced: 2026-02-17T02:58:47.523Z (3 months ago)
- Topics: code-reuse, div-reuse, filter, lua, quarto, quarto-extension, quarto-filter, stable
- Language: Lua
- Homepage: https://m.canouil.dev/quarto-div-reuse/
- Size: 56.6 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
README
# Div-reuse Extension For Quarto
This is a Quarto extension applying the concept of "code reuse" to the content of a Markdown fenced div.
## Installation
```bash
quarto add mcanouil/quarto-div-reuse@1.2.0
```
This will install the extension under the `_extensions` subdirectory.
If you're using version control, you will want to check in this directory.
## Usage
To activate the filter, add the following to your YAML front matter:
- Old (<1.8.21):
```yml
filters:
- quarto
- div-reuse
```
- New (>=1.8.21):
```yml
filters:
- path: div-reuse
at: post-quarto
```
Then, you can reuse any fenced div by using their ID in the following way:
```markdown
## 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](example.qmd).
Output of `example.qmd`:
- [HTML](https://m.canouil.dev/quarto-div-reuse/)
- [Typst/PDF](https://m.canouil.dev/quarto-div-reuse/div-reuse-typst.pdf)
- [LaTeX/PDF](https://m.canouil.dev/quarto-div-reuse/div-reuse-latex.pdf)
- [Word/Docx](https://m.canouil.dev/quarto-div-reuse/div-reuse-openxml.docx)
- [Reveal.js](https://m.canouil.dev/quarto-div-reuse/div-reuse-revealjs.html)
- [Beamer/PDF](https://m.canouil.dev/quarto-div-reuse/div-reuse-beamer.pdf)
- [PowerPoint/Pptx](https://m.canouil.dev/quarto-div-reuse/div-reuse-pptx.pptx)