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

Fix unneeded highlight CSS, fix disable_highlight, clean up highlight template #135

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lfkeitel
Copy link

Description

Use default values of "github" for theme and 9.12.0 for version. Allow highlights to be disabled globally or per page.

Motivation and Context

Closes #131.

How Has This Been Tested?

Tested manually.

Hugo Version: 0.37.1

Browser(s): Chrome

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

@rabbitfang
Copy link

There is an extra call to hljs.initHighlightingOnLoad near the bottom of footer.html that should be removed because it will fail with disable_highlight.

@lfkeitel
Copy link
Author

I didn't see that. I'll make the change and update the PR.

<script src="{{ $highCDN }}/highlight.js/{{ $highVer }}/highlight.min.js"></script>
{{ if (and (not .Site.Params.disable_highlight) (not .Params.disable_highlight)) }}
{{ $highVersion := .Site.Params.highlightjsVersion | default "9.12.0" }}
{{ $highCDN := .Site.Params.highlightjsVersion | default "//cdn.bootcss.com" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be highlightjsCDN.

{{ if (and (not .Site.Params.disable_highlight) (not .Params.disable_highlight)) }}
{{ $highTheme := .Site.Params.highlightjsTheme | default "github" }}
{{ $highVersion := .Site.Params.highlightjsVersion | default "9.12.0" }}
{{ $highCDN := .Site.Params.highlightjsVersion | default "//cdn.bootcss.com" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be highlightjsCDN.

@hjiawei
Copy link
Contributor

hjiawei commented May 3, 2018

One more thing I noticed is that bootcss CDN doesn't work for me anymore. I have to use cloudflare instead.

@lfkeitel
Copy link
Author

lfkeitel commented May 3, 2018

Fixed. Although I realized shortly after making this originally, hugo has builtin syntax highlighting. So is this really necessary?

@hjiawei
Copy link
Contributor

hjiawei commented May 3, 2018

@lfkeitel Good point. I don't know that. Does the built-in syntax highlight support source code in my posts (md files)? If so, I agree we'd better use the built-in one.

@lfkeitel
Copy link
Author

lfkeitel commented May 3, 2018

@hjiawei yea: https://gohugo.io/content-management/syntax-highlighting/. It uses shortcodes to mark code sections. You can even highlight specific lines for emphasis. You can set a theme and use inline styles or a separate style sheet that hugo can generate for you. It's very powerful. Most importantly, it removes any runtime Javascript for the highlighting since it's all pre-processed.

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

Successfully merging this pull request may close these issues.

Disabling hightlight.js
3 participants