-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
highlight Rd code blocks according to their language (new take) #1724
Conversation
This relies on div with classes introduced by r-lib/roxygen2#1229 -- is that a bad idea? Should the docs state that somehow? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this approach seems much better to me, thanks! Lots of smaller comments below 😄
Noting here that the snapshot depends on the Pandoc version 😩 Locally I have Pandoc 2.11.4 and got <body>
<div class="ref-section">
<div class="sourceCode yaml">
<pre>
<code><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="at"> </span><span class="fu">url</span><span class="kw">:</span><span class="at"> https://pkgdown.r-lib.org/</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="at"> </span></span></code>
</pre>
</div>
</div>
</body> |
Conflicts: NEWS.md R/html-tweak.R tests/testthat/_snaps/html-tweak.md tests/testthat/test-html-tweak.R tests/testthat/test-template-content.R
@@ -0,0 +1,64 @@ | |||
# Syntax highlight for preformatted code blocks | |||
tweak_reference_highlighting <- function(html) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maelle I ended up basically re-writing this, but it made me fully understand why it was so complicated 😄 It's a bit easier to test now because I've separated the "finding" from the "modifying" code, and tried to document what I learned in the comments.
Fix #1690
Fix #1692
TODOs