Page 1 of 1

The state of code highlighting in s9y

Posted: Fri Mar 18, 2016 7:59 pm
by yellowled
I just took a look at plugins that provide syntax highlighting in s9y. If you're not familiar with it, there are currently three plugins available:
  • serendipity_event_geshi – a markup plugin which requires author to write extra, BB-Code-like markup for code highlighing; it seems to work quite well, but apparently uses quite a bit of server ressources(?) (not sure about that)
  • serendipity_event_dpsyntaxhighlighter – I assume this is supposed to work without extra markup or even classes, but I can't tell since I couldn't get it to work; more importantly, the JS plugin it uses has seen its last (official) release in July 2010; the author seems to be still working on it, however
  • serendipity_event_prettify – which was broken, but I think I managed to fix that; the JS plugin it uses also is still actively maintained, but they don't seem to do versioning(?)
First thing that is noticable is that we have three plugins for one purpose, which is not very s9y-like. Yes, Geshi is a bit different in that it's more like Markdown or Textile than like the other two, but still. It's odd. Also, there's two plugins that use 3rd-party assets that don't seem to have been maintained in a “good” way. (Also, I think the s9y plugins could be done better in terms of emitting CSS/JS and handling configuration, but that's a different question.)

Can anyone tell if dp and prettify could be combined or does that not make sense? Also, while we're at it, could we add prism to the plugin? It's a very modern, lightweight syntax highlighter, actively maintained. Or should I just try to create a fourth plugin for prism? (I really don't want to and am not sure I could.)

Don't get me wrong, this is not super-important or anything, I just think that it doesn't “look good” to not have a nice, working, current syntax highlighting plugin given that we have quite a large user base in the technical area.

YL

Re: The state of code highlighting in s9y

Posted: Sat Mar 19, 2016 9:25 am
by Timbalu
You may also just use the CKEditor Plugin. It has a build-in codesnippet plugin (enabled by option) for the toolbar, which highlights your code with the famous highlight.js package. You will need to drop your code parts to this button form though to get it back prepared for the highlighter in the entryform. Very easy, very nice!

Re: The state of code highlighting in s9y

Posted: Sat Mar 19, 2016 12:18 pm
by yellowled
Timbalu wrote:You may also just use the CKEditor Plugin.
Yeah, and if you want to make it really easy, you could embed GitHub gists. I know.

I assume most people that have code snippets in their blogs don't use the WYSIWYG editor, though. All three plugins (as well as prism, which I use via my blog theme) require specific classes to be added to the <pre> or <code> elements. I think most people who are aware of that write HTML or Markdown theses days (then again, what do I know?).

I still think this could/should be consolidated, but I guess it's not super important.

YL

Re: The state of code highlighting in s9y

Posted: Mon Mar 21, 2016 3:13 am
by Don Chambers
Are you guys talking about code on the frontend, backend, or both?

Re: The state of code highlighting in s9y

Posted: Mon Mar 21, 2016 8:18 am
by yellowled
Frontend.

YL

Re: The state of code highlighting in s9y

Posted: Mon Mar 21, 2016 8:57 am
by Timbalu
CKEditor plugin: both. :)

Re: The state of code highlighting in s9y

Posted: Mon Mar 21, 2016 9:14 am
by Lux
yellowled wrote:Can anyone tell if dp and prettify could be combined or does that not make sense? Also, while we're at it, could we add prism to the plugin? It's a very modern, lightweight syntax highlighter, actively maintained. Or should I just try to create a fourth plugin for prism? (I really don't want to and am not sure I could.)
I am OK with any change as long as I do not have to change old articles manually.

In other words: We should have a migration path for old articles.

Cheers

Dirk