pressbooks / ideas

Ideas for Pressbooks.
GNU General Public License v3.0
12 stars 4 forks source link

Add export of syntax highlighted code #88

Open ryanmartinneutrino opened 6 years ago

ryanmartinneutrino commented 6 years ago

Feature Scope

Feature Description

Wordpress has numerous plugins that allow code contained within a pre tag to be syntax highlighted. These work well in pressbooks for online version of books, however, they do not work in the exports. It would be great to implement/modify a plugin that would allow syntax highlighting to show up in exported books.

Feature Use Case

Any book that includes coding examples would benefit from this.

Other Notes

dac514 commented 6 years ago

I found this library: https://github.com/scrivo/highlight.php

Highlight.PHP works like https://highlightjs.org/ but instead of rendering using JavaScript in the web browser for online version of books, Pressbooks could render code as plain HTML then apply CSS. This should make code syntax highlighting work in Epubs and PDFs.

SteelWagstaff commented 4 years ago

See https://github.com/pressbooks/ideas/issues/248

SteelWagstaff commented 4 years ago

Looks like Prince already supports Lea Verou's Prism.js library: https://prismjs.com/. See https://www.princexml.com/forum/topic/2510/prism.js-highlighter-support + https://www.princexml.com/forum/topic/2242/js-generated-syntax-highlighting-doesnt-show-up-in-pdf. Add'l reference doc for working wtih JS in Prince: https://www.princexml.com/doc/javascript/ + https://www.princexml.com/doc/prince-input/#applying-javascript-in-prince