-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: function to add line numbers to block #220
base: main
Are you sure you want to change the base?
Conversation
…calling addLineNumbers
@@ -1,4 +1,4 @@ | |||
import std / [strutils, tables, sugar, os, strformat, sequtils] | |||
import std / [strutils, tables, sugar, sequtils] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are unused imports.
@@ -17,7 +17,7 @@ template nbCodeBlock(name:string) = | |||
nbToc.output.add "1. <a href=\"#" & anchorName & "\">" & name & "</a>\n" | |||
|
|||
nbText: """ | |||
> This nimib document provides a brief description and example for | |||
> This nimib document provides a brief description and example for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, the diff contains a lot of line changes because of some automatic tool in my Vim editor to remove whitespaces at the end of lines.
src/nimib/renders.nim
Outdated
# result = """ <div> | ||
# <code>""" & lineNumbers.join("") & """</code> | ||
# <code>""" & code & """</code> | ||
# </div> | ||
# """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should wrap the code in a table or a div container so that we can copy-paste code without the numbers.
Why not use something like https://github.com/wcoder/highlightjs-line-numbers.js? Though I'm not sure about the impact on nimitheme... Using it with this stylesheet works for me: td.hljs-ln-numbers {
text-align: center;
color: #ccc;
vertical-align: top;
padding-right: 5px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
td.hljs-ln-code {
padding-left: 1em;
}
/* Fix for water.css*/
table.hljs-ln {
width: initial;
margin-bottom: 0;
}
table.hljs-ln tbody tr:nth-child(2n) {
background-color: unset;
} |
This PR is not finished yet. Attempt to fix #101.
to do:
I am not satisfied with this generated HTML but at least it renders the numbers correctly.