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

How is the underlying of line numbers controlled? #2

Closed
aubertc opened this issue Dec 18, 2017 · 7 comments
Closed

How is the underlying of line numbers controlled? #2

aubertc opened this issue Dec 18, 2017 · 7 comments

Comments

@aubertc
Copy link

aubertc commented Dec 18, 2017

Hi,

Thanks for your really useful guide (I'm referring to pandoc-goodies/tree/master/skylighting-themes). I have a problem I can't seem to be able to address: in every style, the line number is underlined by default. This is done through

a.sourceLine::before {
    text-decoration: underline;
}

in the CCS code produced by the theme I'm using. I can't seem to find a way to change this behaviour. The only two parameters referring to line numbers in the theme files seem to be

    "line-number-color": "#aaaaaa",
    "line-number-background-color": null,

Any idea on how to change this behavior?

@tajmone
Copy link
Owner

tajmone commented Dec 19, 2017

Hi @aubertc . The problem is that since I've last updated the Sass/CSS file for Skylighting (pandoc v2.0.2), there have been some changes in pandoc internals, which affected both the html tags and the css:

jgm/pandoc/issues/4128

So, if you are using pandoc >= v2.0.4, the Sass/CSS files of pandoc goodies won't be matching the actual html tags and css of the new styles system.

I haven't yet updated them because I wanted to wait and see if more changes where introduced. So, for a weeks the files in this project will not be updated.

But I have updated the Sass files in a personal project that I'm using with pandoc v2.0.4, so you can reference it for the new styles system:

https://github.com/tajmone/pb-archives-test/blob/source/_assets/theme/_sass/syntax-highlighting/_skylighting-default.scss

... this Sass file should be always updated to the last pandoc stable release; and in any case it always mentions the version of pandoc it was designed to work with when last edited.

In the comments I also mention the changes introduced by pandoc:

NOTE: pandoc 2.0.4 introduced some changes in the source code highlight tags:
	  -- source lines now use <a> tag instead of <div> tag:
	  	 before: <div class="sourceLine">
	  	 now:	 <a class="sourceLine">

... this change in the use of html tags (<a> tag instead of <div>) is probably what is breaking your CSS!

You'll find other useful comments in that source file.

@tajmone
Copy link
Owner

tajmone commented Dec 19, 2017

If I remember correctly, line numbers underlining was introduced with pandoc v2.0.4. I haven't had a chance to look in to Haskell source to see how this works in built-in/JSON files, but (as mentioned above), I've handled it only via CSS/Sass files so far.

The actual Haskell source that handles parsing JSON styles is found here:

https://github.com/jgm/skylighting/blob/master/src/Skylighting/Types.hs#L342

I don't see any reference to line numbers decoration attributes, so my guess is that you'll need to override this with some custom CSS and that it can't be changed via JSON style files.

The above link is to skylighting source, which adhers to the KDE styles format, but I'm not sure if pandoc adds some extra options on top of that which are not part of the KDE standard.

If you think that JSON styles should allow to control the linenumbers decoration attribute, without resorting to custom CSS, it might be worth opening a pandoc issue and requesting this feature.

I personally preferr to use custom CSS to control how pandoc highlights code blocks, especially since I like to use different color themes for each language, so that in long documents each code block can be spotted easily from it's colors. Currently, styling through JSON files affect all code blocks, and can't be specified on a per-language basis — it would be nice to be able to load multiple style files, specifying which language each one should be associated to.

@tajmone
Copy link
Owner

tajmone commented Dec 19, 2017

I've updated the extracted CSS stylesheet files to those used by pandoc v2.0.5:

https://github.com/tajmone/pandoc-goodies/tree/master/skylighting-css/built-in-styles

And added warnings for all the obsolete Sass/CSS files in this project (pending updates).

@tajmone
Copy link
Owner

tajmone commented Dec 19, 2017

Updated documentation and boilerplate theme in Skylighting JSON Themes to reflect changes of pandoc v2.0.5:

https://github.com/tajmone/pandoc-goodies/tree/master/skylighting-themes

@aubertc
Copy link
Author

aubertc commented Dec 19, 2017

Thanks a lot for this useful and documented answer!

I haven't yet updated them because I wanted to wait and see if more changes where introduced. So, for a weeks the files in this project will not be updated.

Great, I'll keep an eye on that.

@tajmone
Copy link
Owner

tajmone commented Jul 5, 2019

@aubertc ,

I've recently updated all pandoc JSON and CSS themes.

I'm closing this issue now. Feel free to reopen it if you have any further questions.

@tajmone tajmone closed this as completed Jul 5, 2019
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