[1] 5.5
Cal Poly - San Luis Obispo
Cal Poly - San Luis Obispo
flourish
flourish
flourish
Featuresflourish
’s Elder Sibling, flair
flourish
flourish
allows users to dynamically style text in code chunks
flair
, but now language agnostic!Install (in a project) by running in your terminal:
and add this yaml
in your qmd:
Source Code: github.com/kbodwin/flourish
flourish
Do?flourish
Do?flourish
any HTML Output with any CSS Stylesflourish
supports HTML outputs
#| flourish:
#| - target:
#| - "mean"
#| - style:
#| - "background-color: #bd8c51;"
#| - "font-weight: bold"
What Can flourish
Do?
Best use of LLMs I’ve found so far…
#| flourish:
#| - target:
#| - "1:10"
#| - "wackyyy"
#| - "mean"
#| - style:
#| - "background-color: #bd8c51;"
#| - "font-weight: bold;"
#| - "font-style: italic;"
#| - "text-transform: uppercase;"
#| - "text-decoration: line-through;"
#| - "letter-spacing: 5px;"
#| - "word-spacing: 20px;"
#| - "text-shadow: 3px 3px 5px #888888;"
#| - "writing-mode: vertical-rl;"
#| - "font-variant: small-caps;"
#| - "-webkit-text-stroke: 1px black;"
#| - "filter: blur(1px);"
#| - "filter: drop-shadow(8px 8px 10px gray);"
#| - "filter: contrast(2);"
#| - "filter: sepia(1);"
#| - "font-family: 'Brush Script MT', cursive;"
What Can flourish
Do?
Let’s get meta…
Quis flourishiet ipsos flourishes? flourish
ipso.
What Can flourish
Do?
#| flourish:
#| - target: "mean"
#| - target:
#| - "sd"
#| - mask: true
#| - style: "text-decoration: underline;"
#| - target-rx: "[0-9]*"
#| - target:
#| - "x"
#| - style: "font-weight: bold;"
#| - target:
#| - "set.seed"
#| - "rnorm"
#| - style:
#| - "font-style: italic;"
#| - "background-color: #468e5d;"
What Can flourish
Do?
flourish
Do Yet?class
so you don’t have to write CSS through flourish
<
get stored as <
, so can’t target something like <-
PRs always welcome.
flourish
Do?Quarto extensions add functionality to Quarto in a number of different ways.1
INPUT –reader–> AST –filter–> AST –writer–> OUTPUT2
Lots of things are filters–Pandoc citations, Quarto cross refs, etc.
flourish
is written almost entirely in Javascript#|
sflourish
relies on hashpipes like built-in Quarto optionsflourish
were one-shotted by LLMs; others were written in R and translated into JS by Dr. Bodwin.Let’s dissect how Flourish works with a simple example.
This will get rendered as (in one line)
<span class="fu">mean</span>
(
<span class="at">x =</span>
<span class="dv">1</span>
<span class="sc">:</span>
<span class="dv">10</span>
)
Classes attach syntax highlighting to various elements of this code.
To identify “= 1:10”, we’ll need to extract the text from within the spans, match the target, and wrap each of the pieces in a flourish div.
First thing we need to do is separate content and HTML
Element | Type |
---|---|
<span class="fu"> |
HTML |
mean | text |
</span> |
HTML |
( | text |
<span class="at"> |
HTML |
x = | text |
</span> |
HTML |
<span class="dv"> |
HTML |
1 | text |
</span> |
HTML |
<span class="sc"> |
HTML |
: | text |
</span> |
HTML |
<span class="dv"> |
HTML |
10 | text |
</span> |
HTML |
) | text |
target: "= 1:10"
Our match is from chars 7 to 13
Start Position | Element | StartMatch | EndMatch |
---|---|---|---|
1 | mean | NA | NA |
5 | ( | NA | NA |
6 | x = | 2 | 4 |
9 | 1 | 1 | |
10 | 1 | 1 | 1 |
11 | : | 1 | 1 |
12 | 10 | 1 | 2 |
14 | ) | NA | NA |
We’re using the default styling, so class
will be "flr-default"
Element | Type |
---|---|
<span class="fu"> |
html |
mean | text |
</span> |
html |
( | text |
<span class="at"> |
html |
x<span class="flr-default"> =</span> |
text |
</span> |
html |
<span class="flr-default"> </span> |
text |
<span class="dv"> |
html |
<span class="flr-default">1</span> |
text |
</span> |
html |
<span class="sc"> |
html |
<span class="flr-default">:</span> |
text |
</span> |
html |
<span class="dv"> |
html |
<span class="flr-default">10</span> |
text |
</span> |
html |
) | text |
Once we have flourished the chunk, we stitch it back together and insert it into the rendered document!
<span class="fu">mean</span>
(
<span class="at">x
<span class="flr-default">=</span>
</span>
<span class="flr-default"> </span>
<span class="dv">
<span class="flr-default">1</span>
</span>
<span class="sc">
<span class="flr-default">:</span>
</span>
<span class="dv">
<span class="flr-default">10</span>
</span>
)
Remember, this whole process happens at document load!
Final Flourishes | Aug 10 at useR!2025