Page MenuHomePhabricator

Allow custom pygments styles
Open, WishlistPublic

Description

Internally we use a github based style which people like because it looks good and because github. pygmentize also has bunch of other built in styles which you can list with pygmentize -L styles. Some of them are minor variations while others would clash badly (dark background).

I looked into adding this to PhutilPygmentsSyntaxHighlighter but ran into trouble since the CSS style definitions look like they are tied into the rest of remarkup-land. For comparison cgit just dumps a big old <style> block http://git.zx2c4.com/cgit/tree/filters/syntax-highlighting.py?id=v0.10.2 Was not sure how to structure it here since passing along CSS isn't part of the contract for PhutilSyntaxHighlighterEngine.

Event Timeline

cburroughs raised the priority of this task from to Wishlist.
cburroughs updated the task description. (Show Details)
cburroughs added projects: Diffusion, libphutil.
cburroughs added a subscriber: cburroughs.

I think the best approach for this is to just have several stylesheets and namespace all the rules in each one with .style-x, .style-y, etc., then put class="style-x" on the containing <div /> or whatever the element is. That would let you show several styles on the same page, too (for instance, to show examples of the available styles), which is more difficult if we dump a <style> tag to the document.

We also can't use the pygmentize styles directly since we have more symbol types I think, but the process would basically be: dump a sheet; namespace all the classes; add the extension junk; hook it up.

epriestley renamed this task from Allow custom pygyments styles to Allow custom pygments styles.Apr 19 2016, 2:05 PM