Skip to content

Commit

Permalink
Fix rstudio#1471: move Pandoc's div.sourceCode CSS rules to pre.sourc…
Browse files Browse the repository at this point in the history
…eCode (rstudio#1489)
  • Loading branch information
cderv authored and yihui committed Apr 1, 2019
1 parent 3f6625f commit 4a5ff9a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
@@ -1,7 +1,7 @@
Package: rmarkdown
Type: Package
Title: Dynamic Documents for R
Version: 1.10.17
Version: 1.10.18
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "jj@rstudio.com"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
Expand All @@ -19,6 +19,7 @@ Authors@R: c(
person("Rob", "Hyndman", role = "ctb", email = "Rob.Hyndman@monash.edu"),
person("Ruben", "Arslan", role = "ctb", email = "ruben.arslan@uni-goettingen.de"),
person("Frederik", "Aust", role = "ctb", email = "frederik.aust@uni-koeln.de", comment = c(ORCID = "0000-0003-4900-788X")),
person("Christophe", "Dervieux", role = "ctb"),
person(family = "RStudio, Inc.", role = "cph"),
person(family = "jQuery Foundation", role = "cph",
comment = "jQuery library"),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -31,6 +31,8 @@ rmarkdown 1.11 (unreleased)

* Added an RStudio project template for simple R Markdown websites, so that users can create such websites from RStudio: `New Project -> New Directory -> Simple R Markdown Website` (thanks, @kevinushey, #1470).

* Fixed #1471: Pandoc's (version 2.x) syntax highlighting themes don't work well with the Bootstrap style (thanks, @gponce-ars #1471, @cderv #1489).


rmarkdown 1.10
================================================================================
Expand Down
24 changes: 22 additions & 2 deletions inst/rmd/h/default.html
Expand Up @@ -49,7 +49,7 @@

$if(highlighting-css)$
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
<style type="text/css" data-origin="pandoc">
$highlighting-css$

$if(code_folding)$
Expand All @@ -63,8 +63,28 @@
margin-right: -30px;
}
$endif$

</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
for (var j = 0; j < rules.length; j++) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' || rule.style.backgroundColor === '') continue;
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
$if(theme)$
<style type="text/css">
pre:not([class]) {
Expand Down

0 comments on commit 4a5ff9a

Please sign in to comment.