-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Syntax highlighting issues #606
Comments
Hexo uses highlight.js for syntax highlighting. Maybe you can try other library. |
Thanks! I've fiddled a bit around with highlight.js, and it actually renders the code samples correctly. However, if I do not specify the language (cs) explicitly, it results in the exact same problems that I'm seeing in my blog. I can see that highlight.js's auto language detection detects the language as being "lasso", with "cs" being a close contender. After testing a bit I found the mistake. My mistake. As per Github gfm I was specifying C# as "csharp" in the code blocks, whereas highlight.js only treats them as C# if I specify the language as "cs". If I specify "csharp" then highlight.js will attempt to autodetect, as since that ended up detecting the language as lasso in several cases, I had wrong highlighting :) |
I'm seeing some funky results with syntax highlighting.
gfm
is enabled (full _config.yml).For example, the second code block on this rendered page:
http://improve.dk/redirecting-old-permalinks-on-statically-generated-blogs/
The syntax highlighter doesn't seem to understand that @ initiates a multi-line string, where as the Github equivalent does:
https://github.com/improvedk/improve.dk/blob/master/source/_posts/redirecting-old-permalinks-on-statically-generated-blogs/redirecting-old-permalinks-on-statically-generated-blogs.md
Both of those samples are using csharp highlighting.
Another sample can be seen here:
http://improve.dk/orcamdf-rawdatabase-a-swiss-army-knife-for-mdf-files/
The top two code samples are both using csharp highlighting, yet are rendered completely differently. The raw markdown can be seen here:
https://raw.githubusercontent.com/improvedk/improve.dk/master/source/_posts/orcamdf-rawdatabase-a-swiss-army-knife-for-mdf-files/orcamdf-rawdatabase-a-swiss-army-knife-for-mdf-files.md
In some cases it simply fails to render any highlighting at all (first two code samples, both using csharp):
http://improve.dk/debugging-in-production-part-2-latent-race-condition-bugs/
Source:
https://raw.githubusercontent.com/improvedk/improve.dk/master/source/_posts/debugging-in-production-part-2-latent-race-condition-bugs/debugging-in-production-part-2-latent-race-condition-bugs.md
I have many more samples like these, and some are non-C#. I don't think the problem lies in Hexo, but probably the library being used. What would the process be in testing the cause, and possibly updating the syntax highlighting library?
The text was updated successfully, but these errors were encountered: