in the following src block example:
#+begin_src python -r -n :results output :exports both
print("Hello")
print("I need line number for these code")
print("But I don't need line number when I copy code")
#+end_src
the corresponding exported html result looks like:
when I select, copy these code and paste to IDE to run it, I have to delete all line number. I want to ommit the line number when I copy them.
I try to use CSS to solve these problem:
pre {
margin-top: 5px;
margin-bottom: 20px;
border: #66c 1px solid;
padding: 0.5em;
white-space: pre;
/* background: #bce;
background: transparent url("images/bg.jpg") repeat fixed; */
background: #FFF;
color: black;
text-align: left;
counter-reset: line;
}
if I remove -n paramenter in src block, then
pre .linenr::before {
content: counter(line);
counter-increment: line;
padding-right: 1em;
color: #999;
border-right: 1px solid #ddd;
margin-right: 1em;
display: inline-block;
}
now, the exported html look like:
Can anyone please help me solve this problem?
2
Answers
I roughly solved part of the problem using the following CSS.
To disable lines numbering in the exported source block, remove the
-n
switch from the#+begin_src
line.The
-n
switch does exactly what you’re trying to avoid: numbers the lines of the source block. For more information on this, see (info "(org) Literal Examples").As of today, it states: