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

Syntax Highlighting in Markdown #519

Closed
IngwiePhoenix opened this issue Dec 12, 2015 · 4 comments
Closed

Syntax Highlighting in Markdown #519

IngwiePhoenix opened this issue Dec 12, 2015 · 4 comments

Comments

@IngwiePhoenix
Copy link

It would be nice if we wouldn't need to drop HighlightJS into our static files, and instead can have it pre-rendered already.

HLJS takes up a big bit of data. So it'd be nice if you could allow people to preprocess syntax highlight-able blocks during compilation.

@IngwiePhoenix
Copy link
Author

Any news on the issue here?

@sliminality
Copy link

@IngwiePhoenix I still need to write tests but plan on opening a PR within a couple days. In the interim, you can implement this easily in your local Harp installation (technically Terraform, since that's what manages Harp's asset pipeline).

From Harp's package directory, checkout a new branch, install and save the highlight.js package from npm, and then modify node_modules/terraform/lib/template/processors/md.js by replacing the first line with the following:

var marked = require("marked").setOptions(
  {
    langPrefix: 'language-',
    headerPrefix: '',
    highlight: function (code) {
      return require('highlight.js').highlightAuto(code).value;
    }
  })

You'll still need to include the Highlight.js CSS file in your layout template, but this should take care of the pre-processing.

@IngwiePhoenix
Copy link
Author

Including the Highlightjs CSS is no biggie - its really small, so that works well for me.

Glad to hear you picked this up! Looking forward to the PR. :)

@kennethormandy
Copy link
Collaborator

We do have this existing PR, which would be nice to get a second opinion on. I think this would be a valuable addition to Terraform, but we never really got a chance to discuss it yet. In the meantime, Prism is also a really nice client side option, too.

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

No branches or pull requests

4 participants