Skip to content

Commit

Permalink
Revert some changes to fix math in articles
Browse files Browse the repository at this point in the history
  • Loading branch information
jayhesselberth committed Jan 3, 2025
1 parent 8854300 commit 7da6b33
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 1 addition & 6 deletions R/markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,7 @@ convert_markdown_to_html <- function(pkg, in_path, out_path, ...) {
"--indented-code-classes=R",
"--section-divs",
"--wrap=none",
ifelse(
# katex is handled separately
config_math_rendering(pkg) == "katex",
"",
paste0("--", config_math_rendering(pkg))
),
paste0("--", config_math_rendering(pkg)),
...
))
)
Expand Down
14 changes: 14 additions & 0 deletions inst/BS5/assets/katex-auto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://github.com/jgm/pandoc/blob/29fa97ab96b8e2d62d48326e1b949a71dc41f47a/src/Text/Pandoc/Writers/HTML.hs#L332-L345
document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains("display"),
throwOnError: false,
macros: macros,
fleqn: false
});
}}});
1 change: 1 addition & 0 deletions inst/BS5/templates/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
<script src="{{#site}}{{root}}{{/site}}katex-auto.js"></script>
{{/uses_katex}}

{{#lightswitch}}<script src="{{#site}}{{root}}{{/site}}lightswitch.js"></script>{{/lightswitch}}
Expand Down

0 comments on commit 7da6b33

Please sign in to comment.