I am writing documentation using R Markdown
. After "knitting", the resulting markdown source might look like this:
The variables `x` and `p` are related as follows:
```r
x <- 1
c(x = x, p = pnorm(x))
```
```out
x p
1.0000000 0.8413447
```
... which when converted using pandoc (with syntax highlighting disabled), results in:
The variables <code>x</code> and <code>p</code> are related as follows:
<pre class="r"><code>x <- 1
c(x = x, p = pnorm(x))</code></pre>
<pre class="out"><code> x p
1.0000000 0.8413447</code></pre>
The problem is that the <code>
tag is used, unclassed, in both the body text and the pre-formatted sections. In my case, I would like to write a CSS file that styles the code and output chunks (the R code with class r
and the output with class out
) with different colors, and also displays in-text code in a different color than other body text.
I can define colors for the r
and out
classes; but if I also define a color for the code
tag (which I think is very helpful for readability of the text), it overrides those colors in the code and output chunks. If the <code>
tags weren't in the <pre>
sections (they seem unnecessary), I'd be fine.
Is there a way to get pandoc to omit the <code>
tags in the pre-formatted sections? (Or alternatively, to add my classes to the <code>
tags instead of <pre>
?) I don't want to use syntax highlighting; just the context highlighting I have described.
答案 0 :(得分:0)
好的,呃...在进一步阅读CSS选择器之后,我可以指定code
继承某些类的颜色。所以在我的.css
文件中,我现在有:
code { color: #400000; }
.r {color: #800000; }
.r code { color: inherit; }
.out { color: #008000; }
.out code { color: inherit; }
...现在我可以为这些情况获得3种不同的字体颜色。