Changing part of css for specific code chunk

I define the appearance of my code chunks in the css of my blogdown theme.

code {
  font-family: monocode, monospace;
  -webkit-font-smoothings: antialiased;
  -moz-osx-font-smoothing: grayscale;
   font-size: 90%;
   max-height: 300px;
   overflow-y: auto;
   background-color: inherit;
}

The max-height attribute is basically fine for most of the time, but in a few instances I would like to increase it. Is there a way to change the attribute directly in the chunk options in the blogdown/rmd document?

I saw this related post on Stackoverflow. But as far as I understand it, this would require to define a new css class.

Many thanks!

You can apply css with a chunk in a document, but it would apply on the all document

The solution with the new class it the way to go if you want to have fine control of the text style. With css, that is the best way to apply a rule to an element
You could target a div or a span to apply the class.

For code chunk or chunk output specifically, you can use one the class.* option.

Why applying a new class would not work for you ?

At last, I believe you can use html style attribute to customise an element. This would work using Pandoc bracketed_spans feature.

---
output: html_document
---

Something [red]{style='color:red;'}

As you are using with blogdown, you need to be sure that Pandoc is used to convert to html when using a Pandoc feature (i.e using a Rmd doc only converted to HTML)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.