jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
190 stars 61 forks source link

Is highlight formatting apart from use of styles unsupported? #70

Closed d5ous closed 5 years ago

d5ous commented 5 years ago

With input file headings.md having contents:

# Level 1

A paragraph.

## Level 2

A paragraph.

And command line:

skylighting -f html -s markdown headings.md

I expected the headings to be colored with a style corresponding to dsFunction and bold, based on what's contained in markdown.xml:

<itemData name="h1" defStyleNum="dsFunction" bold="true"/>
<itemData name="h2" defStyleNum="dsFunction" bold="true"/>

Instead, only the function style seems to be applied, for example:

code span.fu { color: #644a9b; } /* Function */
...
<a class="sourceLine" id="5" title="5"><span class="fu">## Level 2</span></a>

The above was produced by an install of skylighting performed via stack today (v 0.7.7), and is consistent with what I'm observing in pandoc. It appears to be systematic for bold=, italic=, etc.

Assuming that the above behavior is deliberate (and that I haven't simply misunderstood/misconfigured something), it might be worth a mention in the readme.

jgm commented 5 years ago

Yes, it's deliberate. The library just assigns classes corresponding to the tokens, and leaves all styling to the styles.

That's a decision that could be revisited, but we'd have to make the Token type more complex and I am not sure it's worth it.

d5ous commented 5 years ago

To record a sense of what a refactor would buy: there seem to be about 400 syntax items affected across a broad range of file types in the syntax highlighting set that ships. The whole (presumably importable) set in KDE syntax-highlighting has more like 900 instances. How many of those really matter undoubtedly depends on who you ask, but "not much in most cases to the majority of people" seems like a fair expectation.

The number of items that create direct cognitive dissonance (like strong that isn't bolded) is much lower, found in the expected cases, and spread over perhaps half a dozen files that could be addressed individually.