Closed hadley closed 2 years ago
We also have something related in Quarto which uses downlit: https://github.com/quarto-dev/quarto-cli/discussions/1165
Chunk to highlight
strwrap(
"Volcano plot - Response Size and Significance of Differential
Expression among all miRNA at Baseline", width = 80
)
We get a single <span>
for the whole multiline
chunk_content <-
c(
"strwrap(\n \"Volcano plot - Response Size and Significance of Differential\n Expression among all miRNA at Baseline\", width = 80\n)"
)
res <- downlit::highlight(chunk_content, downlit::classes_pandoc())
xfun::raw_string(res)
#> <span class='fu'><a href='https://rdrr.io/r/base/strwrap.html'>strwrap</a></span><span class='op'>(</span>
#> <span class='st'>"Volcano plot - Response Size and Significance of Differential
#> Expression among all miRNA at Baseline"</span>, width <span class='op'>=</span> <span class='fl'>80</span>
#> <span class='op'>)</span>
Created on 2022-06-17 by the reprex package (v2.0.1)
Output is like
Related to https://github.com/r-lib/downlit/issues/133 as Pandoc correctly adds a <span>
per line, but it is lost in the translation when applying downlit_html_path()
Yeah, I'm pretty sure the problem is multi-line strings.
Minimal reprex with rmd:
---
output:
html_document:
highlight_downlit: true
---
```{r, results = FALSE}
paste("Line 1
Line 2
Line 3"
)
which generates:
```html
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste</a></span><span class="op">(</span><span class="st">"Line 1
Line 2
Line 3"</span>
<span class="op">)</span></code></pre></div>
And the messed appearance arises because pre > code.sourceCode > span
is given display: inline-block;
.
Minimal reprex just using downlit:
cat(downlit::highlight('paste("Line 1
Line 2
Line 3"
)'))
#> <span class='nf'><a href='https://rdrr.io/r/base/paste.html'>paste</a></span><span class='o'>(</span><span class='s'>"Line 1
#> Line 2
#> Line 3"</span>
#> <span class='o'>)</span>
Created on 2022-06-21 by the reprex package (v2.0.1)
looks like
Because, I think, the multi-line string is put in a single span.