Multiline code blocks and code tags (line numbering)
See original GitHub issueUpdate: Solution here
Is it possible to have showdown add <code> tags for every line in a multiline code block?
How it works now (not sure how to format example properly, sry):
```
This is a test
This is a test too
This is a test three
```
Results in:
<pre><code>This is a test
This is a test too
This is a test three</code></pre>
What I am hoping to get is:
<pre><code>This is a test</code>
<code>This is a test too</code>
<code>This is a test three</code></pre>
Reason:
I have some CSS code that allows for line numbering in code blocks
This works using a counter for <code> tags, and a reset at each <pre> tag
Since all lines are placed in a single <code> tag, it results in counting only a single line
My working CSS (resulting in only recognizing a single line):
pre {
counter-reset: line-numbering;
font-family: Menlo, Monaco, monospace;
background-color: #333;
padding: 5px;
padding-left: 15px;
color: #CCC;
border-radius: 3px;
word-break: keep-all;
white-space: pre-wrap;
}
code:before {
content: counter(line-numbering);
counter-increment: line-numbering;
padding-right: 1em;
width: 1.5em;
text-align: right;
opacity: 0.5;
}
I have tried to find a solution using google and the issue tracker, but wasn’t able to find it. Apologies if I have overlooked something obvious 😉
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (6 by maintainers)
Top Results From Across the Web
Line Numbers Prism plugins
To give all code blocks line numbers, add the line-numbers class to the <body> of the page. This is part of a general...
Read more >5.7 Line numbers for code blocks (*) | R Markdown Cookbook
You can add line numbers to either source code blocks, via the chunk option attr.source = ".numberLines" , or text output blocks, via...
Read more >Is it possible to show line numbers in code block? - support
I use the following code to show line numbers in code blocks: {.language . ... a single line number may apply to multiple...
Read more >Displaying inline and multiline blocks of code using Bootstrap
Displaying Multiline Code Blocks: Multiline code should be wrapped in <pre> tags. The resulting text will be displayed in a fixed-width font ...
Read more >Inserting Code Snippets - The Center For Learning & Teaching
The Canvas <code> tag/code format option is available in all Canvas ... for code snippets to be syntax highlighted and optionally have line...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Updated opening post, closing ticket
Thanks again for all the time you spent on my sillyness 😉
I think the technical term is ‘absolute legend’!
Not only a real-life hero but fixing my problems on the side… expect a donation coming up soon 😉