Skip to content
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

Line numbering? #13

Open
pazz opened this issue Apr 12, 2023 · 4 comments
Open

Line numbering? #13

pazz opened this issue Apr 12, 2023 · 4 comments

Comments

@pazz
Copy link

pazz commented Apr 12, 2023

First off, many thanks for these goodies, they are really nice!

This is a question rather than an issue/feature request: I do not seem to be able to get visible line numbering working with your github html5 theme. Could you point out any obvious errors please?

I am working on the following markdown file, using the newest version of GitHub.md from this repo.

---
title: test
---

```{.numberLines}
SQUIRE TRELAWNEY, Dr. Livesey, and the rest of these gentlemen having
asked me to write down the whole particulars about Treasure Island, from
the beginning to the end, keeping nothing back but the bearings of the
island, and that only because there is still treasure not yet lifted, I
take up my pen in the year of grace 17__ and go back to the time when
my father kept the Admiral Benbow inn and the brown old seaman with the
sabre cut first took up his lodging under our roof.

I produce html like this:

pandoc -s --template=~/.pandoc/templates/GitHub.html5 < test.md    

The resulting html does not include line numbers when rendered in my browser.
The relevant part of the source is this.

<body>
<article class="markdown-body">
<header>
<h1 class="title">test</h1>
</header>
<div class="sourceCode" id="cb1"><pre
class="sourceCode numberSource numberLines"><code class="sourceCode"><span id="cb1-1"><a href="#cb1-1"></a>SQUIRE TRELAWNEY, Dr. Livesey, and the rest of these gentlemen having</span>
<span id="cb1-2"><a href="#cb1-2"></a>asked me to write down the whole particulars about Treasure Island, from</span>
<span id="cb1-3"><a href="#cb1-3"></a>the beginning to the end, keeping nothing back but the bearings of the</span>
<span id="cb1-4"><a href="#cb1-4"></a>island, and that only because there is still treasure not yet lifted, I</span>
<span id="cb1-5"><a href="#cb1-5"></a>take up my pen in the year of grace 17__ and go back to the time when</span>
<span id="cb1-6"><a href="#cb1-6"></a>my father kept the Admiral Benbow inn and the brown old seaman with the</span>
<span id="cb1-7"><a href="#cb1-7"></a>sabre cut first took up his lodging under our roof.</span></code></pre></div>
</article>
</body>

Can you point me to the right direction? Many thanks!

@pazz
Copy link
Author

pazz commented Apr 12, 2023

I should say I am on pandoc version 2.17.1.1 (debian testing).

When I leave out the template option above, the html body is the same but the line numbers do show (It is magic to me where the actual numbers come from but that's unrelated :)).

I also tried with --highlight-style=tango, same thing.

@pazz
Copy link
Author

pazz commented Apr 12, 2023

I wonder if this is related? It is quite old...
jgm/pandoc#4128

The line numbers seem to be there, but shifted somehow. If I disable the CSS styling (close to the pointer in the image below), they appear.
ln

Sorry for my clumsy attempts at debugging this.
Any help would be appreciated!

@tajmone
Copy link
Owner

tajmone commented Apr 12, 2023

It should be easy to determine whether it's a CSS related issue or a problem with the highlighter not producing the line numbers — in the former, inspection of HTML contents should reveal the line numbers, which might be hidden due to CSS problems, whereas in the latter the line numbers should not be present in the generated HTML.

I don't remember exactly whether line-numbers are added by Skylighting (the syntax highlighter library) or pandoc itself. But chances are that when using a syntax highlighter with auto-detection of the language, if the highlighter fails to detect a language (and thus to syntax highlight at all), it might be the case that line-numbers are not generated (since the highlighter might be bypassed), so in this respect different highlighters might work differently.

It might be the case that the CSS needs tweaking, although I thought I had covered line-numbering styles — I surely did for Highlight, which is the external highlighter that I use most with pandoc, rather than the built-in Skylighting.

Anyhow, if the problem is CSS related it should be easy to fix. If you have a solution, please create a pull request, otherwise allow me some time to find a free afternoon where I can look into it.

@pazz
Copy link
Author

pazz commented Apr 12, 2023

Sure, no rush. I am quite sure that it is a CSS thing, because the html body is exactly the same with your or the default template (where it works as expected).
It seems that the numbers themselves fall out of some counter when the CSS is rendered (see my img, two lines above the cursor). They do not appear in the html itself, no matter the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants