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 highlight improvements #5

Closed
jzaefferer opened this issue Jul 19, 2012 · 8 comments
Closed

Syntax highlight improvements #5

jzaefferer opened this issue Jul 19, 2012 · 8 comments

Comments

@jzaefferer
Copy link
Member

  • remove the id generated by node-syntaxhighlighter, otherwise grunt-wordpress will always update a document, even though the source document didn't actually change
  • highlight code within script blocks
  • respect the data-linenum attribute: If data-linenum is not specified, line numbers shouldn't be generated. If its present, but has no value, default to 1. If present, and has a value, use that.
@thlorenz
Copy link

I ran into the same problem with pygments in my highlighter readarepo-zip.

In there I currently use sockets to have one long running python highlighter communicating with nodejs which is more efficient than firing up a process each time.

I created node-syntaxhighlighter to make things less complicated, but am still not entirely happy (pygments looks so much nicer).

Therefore I'm committed to make talking to pygments from a JavaScript process very efficient without much hassle (talking via stdin/stout).

I just created pygmentsjs and hopefully will have something useable by the end of this weekend. You should probably watch the repo in order to stay updated.

It will expose a very simple api like node-syntaxhighlighter and you could consider swapping pygmentsjs in later and/or using it as another option.

Cheers.

@jzaefferer
Copy link
Member Author

First issue got addressed by #6, the other two are still open. Clarified the last one.

@jzaefferer
Copy link
Member Author

First and last issue resolved, highlighting code within scripts should be possible now that thlorenz/node-syntaxhighlighter#2 is fixed?

@jzaefferer
Copy link
Member Author

prismjs seems to have a nice theme, already supports highlighting inline scripts, but isn't in npm yet: PrismJS/prism#12

@jzaefferer
Copy link
Member Author

@ajpiano it looks like scripts-inside-html highlighting stil doesn't work, while thlorenz/node-syntaxhighlighter#2 is supposed to be fixed. What are we missing?

@ajpiano
Copy link
Member

ajpiano commented Oct 26, 2012

I don't know why it isn't working, this is why I've been pursuing highlightjs.

@ajpiano
Copy link
Member

ajpiano commented Nov 9, 2012

I've pushed my initial work inserting highlightjs to this highlightjs-experimentation branch. Please use this in tandem with the corresponding branch on web-base-template, which provides the styles.

There are a few issues that I can mention up that need addressing

  1. We need a custom build of highlight.js that only includes xml, javascript, and css (and any other languages we need, if I'm missing any). The normal version of highlight.js has a lot of languages, and the small size of our snippets mean that highlight.js's autodetection heuristics are frequently wrong when it can try many many languages. Highlight.js by default comes with a python builder that you can use to make custom builds, but I'm not sure what the best way to bundle this into our repo is. Keeping a local, modified of the npm module and shrinkwrapping it? Making a higlight.js fork and linking to our branch in the grunt-jquery-content package.json?
  2. Line numbers - not a default feature of highlight.js, but there is a branch that is somewhat maintained. We are going to need to try that branch, or post-process the line numbers ourselves. Perhaps this and the need for a custom build necessitate a fork?
  3. It is badly screwing up on the code samples in the XML API docs (essentially not highlighting them at all) because I think they are arriving at the syntax highlight already encoded.

@jzaefferer
Copy link
Member Author

Mostly done here, though the explicit data-linenum isn't working. For example, with data-linenum="2", I get this result on qunitjs.com: screenshot

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

3 participants