Skip to content

Switch to Highlight.js - #149

Closed
killercup wants to merge 3 commits into
nevir:masterfrom
killercup:patch-highlightjs
Closed

Switch to Highlight.js#149
killercup wants to merge 3 commits into
nevir:masterfrom
killercup:patch-highlightjs

Conversation

@killercup

Copy link
Copy Markdown
Contributor

As discussed in #134.

I chose to switch to highlight.js because I dislike the python dependency and how slow the invocation of child processes is. To render groc's own documentation, groc with pygments takes 9.5s on my machine, whereas groc with highlight only needs 3s (medium of 5 tests).

This pull request also includes my crude attempt at converting the original stylesheet to a highlight-compatible format (in SCSS) and adds the highlightJS key to some language definitions where the name highlight uses differs from pygment's.

In general, I'm only changing the highlightCode method in utils.coffee. If you want to keep pygments available, I suggest you change highlightCode to call specific methods depending on an option, e.g. highlightCodeHighlightJS and highlightCodePygments.

I've replaced highlightCode with highlightCodeUsingHighlighJS and highlightCodeUsingPygments. You can set your highlighter preference using the 'highlighter' CLI option or .groc.json property.

Stay tuned for my next PR to switch to marked.js.

This was referenced Dec 21, 2013
@sjorek

sjorek commented Dec 21, 2013

Copy link
Copy Markdown
Contributor

Just to mention: the figures from “pygments takes 9.5s ” are the result of forking one process per source-file in groc. 😏

@killercup

Copy link
Copy Markdown
Contributor Author

@sjorek of course, thats why I wanted a solution that didn't have to fork anything at all. :)

I hope @kmdavis likes this PR!

@killercup killercup mentioned this pull request Dec 21, 2013
Just add `"highlighter": "pygments"` to your `.groc.json` or use the
`--highlighter=pygments` flag.
@killercup

Copy link
Copy Markdown
Contributor Author

Voilá, groc --highlighter=pygments is all yours.

I would like to refactor the highlighting stylesheets next, but it's not really important and also a whole other issue. Ideally, I'd like to try to create one for all highlighters, just by using SASS variables. (It would also be nice if there was more than one design and if one could compile the SASS sources using libsass.)

@kmdavis

kmdavis commented Dec 21, 2013

Copy link
Copy Markdown
Collaborator

love the cli option. also like not depending on python 😄

@killercup

Copy link
Copy Markdown
Contributor Author

Any news when this will be merged? I'd really like to tell npm to use groc, not git://github.com/killercup/groc#da6ff644c1596ff97ee3315f9461cc3c6ea43444 ;)

@ctumolosus

Copy link
Copy Markdown

+1

@killercup

Copy link
Copy Markdown
Contributor Author

For all those who are waiting on this PR:

Over the last week or so I've been writing an alternative implementation of groc. The main differences are that it

  • uses streams to process a glob of files (which makes is quite easy to read)
  • uses marked and highlight.js (which makes it quite fast)
  • uses a different style based on Solarized with a responsive layout and a sidebar with file tree and headline toc (that I initially wrote for groc though)

It's quite stable right now but probably hasn't been tested enough. You can find the project at https://github.com/killercup/grock.

I want to thank the groc authors very much -- some of the "hard parts" (splitting code and comments, list doc tags and languages) are borrowed code groc. Without those it wouldn't have been possible to implement any of this functionality this quickly.

@longlho

longlho commented Apr 24, 2014

Copy link
Copy Markdown

+1 for this

@despairblue

Copy link
Copy Markdown

👍

1 similar comment
@jessefulton

Copy link
Copy Markdown

+1

@nevir

nevir commented Sep 12, 2014

Copy link
Copy Markdown
Owner

Months late, but thanks for this - merged :)

@nevir nevir closed this Sep 12, 2014
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.

8 participants