Skip to content

Commit

Permalink
Add line numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Aug 25, 2023
1 parent 848d121 commit a18c575
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 6 deletions.
41 changes: 41 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,47 @@ pre[class*="language-"] {
white-space: normal;
}

pre[class*="language-"].line-numbers {
position: relative;
padding-left: 3.8em;
counter-reset: linenumber;
}


pre[class*="language-"].line-numbers > code {
position: relative;
white-space: inherit;
}

.line-numbers .line-numbers-rows {
position: absolute;
pointer-events: none;
font-size: 100%;
left: -3em;
width: 2em; /* works for line-numbers below 1000 lines */
letter-spacing: -1px;
border-right: 1px solid;
border-right-color: var(--prism-text, #999);
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;

}

span.line-numbers-rows{
display: inline;
counter-increment: linenumber;
}

span.line-numbers-rows:before {
content: counter(linenumber);
color: var(--prism-text, #999);
display: inline;
padding-right: 0.8em;
text-align: right;
}

.token.comment,
.token.block-comment,
.token.prolog,
Expand Down
7 changes: 7 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

<!-- PDF extension point -->
<feature extension="dita.xsl.xslfo" value="xsl/xslfo.xsl" type="file"/>

<!-- HTML5 extension points -->
<feature extension="dita.xsl.html5" value="xsl/line-numbers.xsl" type="file"/>
<!-- XHTML extension points -->
<feature extension="dita.xsl.xhtml" value="xsl/line-numbers.xsl" type="file"/>


<!-- Uses the default preprocess.pre and post extension points -->
<feature extension="depend.preprocess.pre" value="prismjs.init"/>
<feature extension="depend.preprocess.post" value="prismjs"/>
Expand Down
Loading

0 comments on commit a18c575

Please sign in to comment.