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 to enable highlight.js for syntax highlighting of code blocks #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yihui
Copy link
Owner

@yihui yihui commented Jun 21, 2017

Add CSS to <head> in head_custom.html (I'm using the github theme here), and JavaScript to foot_custom.html. highlight.min.js supports common languages here: https://highlightjs.org/download/ As an example, I added r.min.js to support R. To add support for any other languages, find their filenames on https://cdnjs.com/libraries/highlight.js.

hljs.configure({languages: []}); means highlight.js should not automatically detect languages in <pre>. I set this option because I found the automatic detection was often more annoying than useful, e.g. your R code chunk output could be syntax highlighted, which really should not be.

Preview: https://deploy-preview-5--hugo-xmin.netlify.com/

@yihui yihui added the feature label Jun 22, 2017
@yihui yihui changed the title How to support highlight.js How to enable highlight.js for syntax highlighting of code blocks Jun 22, 2017
@yihui yihui force-pushed the feature/highlight.js branch 2 times, most recently from 8f67c83 to 1d7df7d Compare July 3, 2017 18:18
@yihui yihui force-pushed the feature/highlight.js branch 3 times, most recently from a9e043a to cbc827a Compare July 13, 2017 07:08
@yihui yihui force-pushed the feature/highlight.js branch from cbc827a to 258cdb6 Compare August 14, 2017 20:28
@yihui yihui force-pushed the feature/highlight.js branch from 258cdb6 to 057e1d8 Compare August 29, 2017 03:02
@yihui yihui force-pushed the feature/highlight.js branch from 057e1d8 to 4a094f3 Compare October 8, 2017 14:24
@yihui yihui force-pushed the feature/highlight.js branch from 4a094f3 to 6b86ec0 Compare October 27, 2017 03:17
@dracodoc
Copy link

dracodoc commented Mar 20, 2018

I want to add some examples of using different styles. Here are some styles hosted in cdn. And here are some demos.

I just replaced the line in layout/partials/head_custom.html to a different css and it worked.

@yihui yihui force-pushed the feature/highlight.js branch from 6b86ec0 to 9ca5ce8 Compare March 21, 2018 15:39
@yihui yihui force-pushed the feature/highlight.js branch from 9ca5ce8 to 17ff9dc Compare August 30, 2018 15:02
@yihui yihui force-pushed the feature/highlight.js branch from 17ff9dc to f71cd19 Compare October 1, 2018 14:33
@yihui yihui force-pushed the feature/highlight.js branch from f71cd19 to f408c9c Compare March 20, 2019 02:59
@yihui yihui force-pushed the feature/highlight.js branch from f408c9c to 4384fab Compare April 18, 2019 19:01
@yihui yihui force-pushed the feature/highlight.js branch from 4384fab to c7d1f49 Compare March 17, 2020 03:07
@yihui yihui force-pushed the feature/highlight.js branch from c7d1f49 to fe1d630 Compare July 24, 2020 19:48
@yihui yihui force-pushed the feature/highlight.js branch 2 times, most recently from d2ad7e1 to 1fef437 Compare October 11, 2020 20:55
@yihui yihui force-pushed the feature/highlight.js branch 2 times, most recently from 5121eca to 1410032 Compare June 15, 2022 03:56
@yihui yihui force-pushed the feature/highlight.js branch from 1410032 to c842f45 Compare February 5, 2024 14:58
@yihui yihui force-pushed the feature/highlight.js branch from c842f45 to 97c1b05 Compare March 4, 2024 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants