[xwiki-devs] [Proposal] Evaluate javascript syntax highlighting as alternative to Jython/Pygments
Lately I have been playing with a few different javascript syntax highlighting libraries. One which I think shows some promise is google-code-prettify, used for highlighting on google code (Apache license.) Advantages of javascript highlighting: + We could remove Pygments and Jython, Jython weighs in at 8.3MB making it the largest jar in the lib folder, Pygments adds another 364K. + I understand Jython/Pygments has been responsible for recent out of permgen memory errors. + Shifts work from server to client. + Adding a js syntax highlighting library to the svn repository allows us to patch it to support xwiki syntax (switch lexers when macros are detected.) + Relatively easy compared to other performance boosters. Disadvantages: - Some users do not use Javascript. - Highlighting may be slow on old computers when lots of code is displayed. - Removing Jythion from the default build will add a step to upgrading for wiki operators who are using the {{python}} macro. - Adds another js file to download which hurts page load speed until a js bundling plan is in place. If there is significant interest, I could put up a comparison page on the incubator. Caleb
On Jan 31, 2010, at 5:00 AM, Caleb James DeLisle wrote:
Lately I have been playing with a few different javascript syntax highlighting libraries. One which I think shows some promise is google-code-prettify, used for highlighting on google code (Apache license.)
Advantages of javascript highlighting: + We could remove Pygments and Jython, Jython weighs in at 8.3MB making it the largest jar in the lib folder, Pygments adds another 364K.
+ I understand Jython/Pygments has been responsible for recent out of permgen memory errors.
+ Shifts work from server to client.
+ Adding a js syntax highlighting library to the svn repository allows us to patch it to support xwiki syntax (switch lexers when macros are detected.)
+ Relatively easy compared to other performance boosters.
Disadvantages: - Some users do not use Javascript.
- Highlighting may be slow on old computers when lots of code is displayed.
- Removing Jythion from the default build will add a step to upgrading for wiki operators who are using the {{python}} macro.
- Adds another js file to download which hurts page load speed until a js bundling plan is in place.
- PDF/RTF exports don't have code highlighted Note that we've already talked several times about this (we've evaluated this option before we started work on integrating pygments) and we considered there were too many cons. That said we could have 2 macros (one server side and one client side). Thanks -Vincent
If there is significant interest, I could put up a comparison page on the incubator.
Caleb
On 01/31/2010 05:00 AM, Caleb James DeLisle wrote:
Lately I have been playing with a few different javascript syntax highlighting libraries. One which I think shows some promise is google-code-prettify, used for highlighting on google code (Apache license.)
Yes, I've looked at it a few days ago, too.
Advantages of javascript highlighting: + We could remove Pygments and Jython, Jython weighs in at 8.3MB making it the largest jar in the lib folder, Pygments adds another 364K.
Jython is not just for syntax highlighting, but as a scripting macro.
+ I understand Jython/Pygments has been responsible for recent out of permgen memory errors.
+ Shifts work from server to client.
+ Adding a js syntax highlighting library to the svn repository allows us to patch it to support xwiki syntax (switch lexers when macros are detected.)
+ Relatively easy compared to other performance boosters.
If there are problems with Jython, I'm sure they can be solved, too. The problem is that we're not giving so much importance to it, since we have other more important issues to solve. Some of the problems could be as simple as not using it the right way (bad config, bad usage patterns), while some could be reported as bugs to the jython devs, since we could be using it in a way that they haven't predicted.
Disadvantages: - Some users do not use Javascript.
- Highlighting may be slow on old computers when lots of code is displayed.
- Removing Jythion from the default build will add a step to upgrading for wiki operators who are using the {{python}} macro.
- Adds another js file to download which hurts page load speed until a js bundling plan is in place.
I agree with Vincent here, for the {{code}} macro we should use the server-side highlighting. But we could use client-side highlighting for textareas, for example a first step would be to add it to the JSX/SSX textareas.
If there is significant interest, I could put up a comparison page on the incubator.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
On Sun, Jan 31, 2010 at 05:00, Caleb James DeLisle <[email protected]> wrote:
Lately I have been playing with a few different javascript syntax highlighting libraries. One which I think shows some promise is google-code-prettify, used for highlighting on google code (Apache license.)
We did looked at JS highlight libraries before implementing code macro and it's true that some of them are impressive but we decided it was not a solution from rendering point of view. Use JS make the macro only work in a very specific environment. The current code macro is working for any kind of renderer. That said it would make sense to provide a JS based code macro on code.xwiki.org for example, should be easy to implement. Would be a good example of wiki macro.
Advantages of javascript highlighting: + We could remove Pygments and Jython, Jython weighs in at 8.3MB making it the largest jar in the lib folder, Pygments adds another 364K.
+ I understand Jython/Pygments has been responsible for recent out of permgen memory errors.
The implementation we are using is actually very young (that's the very first version of a complete rewrite of Jython) and I'm sure it will be improved in the future. For example it's officially known as way slower that the previous implementation but AFAIK the team is pretty dedicated to improve that, the first step was to provide a fully functional python implementation. Pygments is a great library which supports a lot's of syntaxes and is pretty active.
+ Shifts work from server to client.
It's not an obvious pro for me. Especially when we are talking about IE.
+ Adding a js syntax highlighting library to the svn repository allows us to patch it to support xwiki syntax (switch lexers when macros are detected.)
I'm not sure to understand what you mean here. Note that code macro does not depends on Pygments. It provides it's own highlighting system and a bridge to Pygments when no parser is provided for a given syntax. It means all syntaxes for now but it's very easy to provide parsers for any language not supported by Pygments or if you have a pure Java parser for example (anyway even add a Pygments lexer is not too difficult).
+ Relatively easy compared to other performance boosters.
Disadvantages: - Some users do not use Javascript.
- Highlighting may be slow on old computers when lots of code is displayed.
- Removing Jythion from the default build will add a step to upgrading for wiki operators who are using the {{python}} macro.
I don't think that's a real issue, it's would be easy for someone to install the python macro like the jruby one.
- Adds another js file to download which hurts page load speed until a js bundling plan is in place.
If there is significant interest, I could put up a comparison page on the incubator.
Caleb
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
participants (4)
-
Caleb James DeLisle -
Sergiu Dumitriu -
Thomas Mortagne -
Vincent Massol