redrabbit / git.limo

A Git source code management tool powered by Elixir with easy installation & high extensibility.
https://git.limo
MIT License
497 stars 42 forks source link

Fix syntax highlighting incoherences #48

Closed redrabbit closed 5 years ago

redrabbit commented 5 years ago

Instead of using <table> for rendering highlighted code (we do so because we display a <td> column for each line). We should use a different layout allowing highlight.js to parse entire blocks.

redrabbit commented 5 years ago

Commit 9185553 helped quite a lot here.

The docs state that you can pass a variable to keep track of the parsing state 🤓.

There are still some differences when parsing the entire code (not chunked by lines). Will investigate if there is a possible fix.

Code parsed line by line within <table>:

Bildschirmfoto 2019-08-09 um 23 16 47

Code parsed entirely in a <pre> block:

Bildschirmfoto 2019-08-09 um 23 17 54

You can see that geef_diff_tree is highlighted correctly in the second screenshot.

redrabbit commented 5 years ago

Commit 0518014 fixes the issue explained in the last comment. Page loading feels somehow slower.

A benefit of this workaround is that we can detect the language of the entire block instead of trying to guess line by line.

Concatenating all line, parsing them and reflecting the result for each row in the <table> is also a bit cumbersome. Current implementation is not perfect and some brings other issues...

Syntax highlighting before 0518014:

Bildschirmfoto 2019-08-10 um 00 33 32

Syntax highlighting after 0518014:

Bildschirmfoto 2019-08-10 um 00 31 47