question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiline code blocks and code tags (line numbering)

See original GitHub issue

Update: 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:closed
  • Created 2 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ZTiKnlcommented, Feb 25, 2022

Updated opening post, closing ticket

Thanks again for all the time you spent on my sillyness 😉

1reaction
ZTiKnlcommented, Feb 23, 2022

I just finished a 24 hour shift in the ER

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 😉

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found