github / markup

Determines which markup library to use to render a content file (e.g. README) on GitHub
MIT License
5.85k stars 3.4k forks source link

Rouge #1266

Closed ghost closed 5 years ago

ghost commented 5 years ago

github.com utilizes Rouge for syntax highlighting. This is good, but it even uses Rouge with markups that lack Rouge support. For example if you make a file readme.org:

#+BEGIN_SRC ruby
puts 'hello world'
#+END_SRC

github.com will correctly render the file with highlighting. What is confusing is that the Org-Ruby Gem currently only supports Coderay or Pygments.rb:

https://github.com/wallyqs/org-ruby#current-status

So how is github.com using Org-Ruby with Rouge?

wallyqs commented 5 years ago

iirc the trick was that there are some special css tags that when added to the generated html output, then github will pick them up and apply the syntax highlighting pass on them.

ghost commented 5 years ago

@wallyqs is it possible for an individual to do this with a local installation?

wallyqs commented 5 years ago

I'm not sure tbh how it is done these days...

kivikakk commented 5 years ago

GitHub uses Rouge for syntax highlighting in GitHub Pages, but we use our own highlighter on github.com. In either case, we post-process the HTML output from this gem -- see https://github.com/github/markup/blob/master/README.md and note item 3.

@wallyqs You recall correctly! We search for pre tags with a lang attribute, which determines the language to highlight as.

ghost commented 5 years ago

@kivikakk where is repo for "our own highlighter"? is it this?

https://github.com/jch/html-pipeline

kivikakk commented 5 years ago

@cup No -- our highlighter, PrettyLights, is closed source. This is regrettable because it's a nice piece of software, but unfortunately licensing issues that are completely out of our hands prevent us from open-sourcing it. (We've tried to address this with our upstream a number of times to no avail.)