Skip to content

Unique (user-configured) linenum anchors for Code Blocks #2258

Answered by facelessuser
hellt asked this question in Q&A
Discussion options

You must be logged in to vote

It would be cool to be use either random ID to avoid clashes, or let the user to define it.

Static IDs are already possible, just attach an ID to your code block:

``` {.python #myid linenums="1"}
import bar
```
<div id="myid" class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__codeline-myid-1"><span class="kn">import</span> <span class="nn">bar</span>
</span></code></pre></div></td></tr></table></div>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hellt
Comment options

Answer selected by facelessuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants