Have you read the Contributing Guidelines on issues?
Description
Looking through the source for the codeBlock I see that it's possible to add classes to the codeBlock.
This is useful as we'd like to add line numbering to our code blocks, but would also like the ability to selectively enable or disable it.
Ideally line numbering should be a top-level feature fo the CodeBlock, but as it is not currently we can do this with some fairly simple css:
/* Reset line numbers for each new code block */
.prism-code {
counter-reset: line-number;
}
:not(
.theme-code-block:not(.no-line-numbers) .prism-code.language-js .token-line::before,
.theme-code-block:not(.no-line-numbers) .prism-code.language-mustache .token-line::before,
.theme-code-block:not(.no-line-numbers) .prism-code.language-html .token-line::before,
.theme-code-block:not(.no-line-numbers) .prism-code.language-php .token-line::before,
.theme-code-block.force-line-numbers .prism-code .token-line::before {
counter-increment: line-number;
content: counter(line-number);
margin-right: calc(var(--ifm-pre-padding) * 1.5);
text-align: right;
min-width: 2.5rem;
display: inline-block;
opacity: .3;
position: sticky;
left: var(--ifm-pre-padding);
}
This then allows me to have a code block:
``` title="Forcibly add line numbers" className=force-line-numbers
Unidentified language with line numbers forced
```
And
```js title="Prevent line numbers from a language which has them ordinarily" className=no-line-numbers
No line numbers here
```
I'm happy to help document this if you feel it's worthwhile having.
Self-service
Have you read the Contributing Guidelines on issues?
Description
Looking through the source for the codeBlock I see that it's possible to add classes to the codeBlock.
This is useful as we'd like to add line numbering to our code blocks, but would also like the ability to selectively enable or disable it.
Ideally line numbering should be a top-level feature fo the CodeBlock, but as it is not currently we can do this with some fairly simple css:
This then allows me to have a code block:
And
I'm happy to help document this if you feel it's worthwhile having.
Self-service