I’m writing an online book (bs4_book) with the bookdown package in RMarkdown. Inside the markdown there are Python chunks with simple operations like importing libraries and arithmetic calculations. I’ve been looking for a way to make the lines inside the Python chunks numbered by changing parameters inside the style.css
file. Although I succeeded, this method also numbers the output of the cells, and I personally don’t like it.
I know there must be a way to define it inside the .css
file, but I don’t know the language.
Here’s my style.css
file:
p.caption {
color: #777;
margin-top: 10px;
}
p code {
white-space: inherit;
}
pre {
word-break: normal;
word-wrap: normal;
}
pre code {
white-space: inherit;
}
pre.sourceCode {
counter-reset: line;
line-height: 0.8;
}
pre.sourceCode > code > span:before {
content: counter(line);
display: inline-block;
border-right: 1px solid #ddd;
padding-right: 0.5em;
margin-right: 0.5em;
color: #888;
}
I´ve tried this with no succed:
pre.sourceCode > code > span {
display: block;
counter-increment: line;
}
pre.output, pre.verbatim {
counter-reset: none !important;
padding-left: 0 !important;
list-style-type: none !important;
border: none !important;
}
pre.output > code > span:before, pre.verbatim > code > span:before {
content: none !important;
}
Alén Miranda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.