The prettify-library used has the ability to highlight a lot of languages correct, but then you need to specify it with a lang-TYPE class on the block, or as TYPE as the second parameter to prettyPrintOne.
Not sure if it is possible to get the list of TYPEs available, but not all of them are needed, as there are a lot of aliases.
Would be nice if the prettifier got updated too, and some of the plugins for it got added too.
Basically the lib should auto-detect the correct language.
I think this is a (complete?) list of all available types. (AFAIK we do not use any plugins yet) Do you really think a language selection is necessary?
Which plugins would you like to be added?
And as I see here are these language plugins…
Also related to https://github.com/PrivateBin/PrivateBin/issues/189 BTW.
Well, the code that does the auto-detect only selects between default-markup (if the code starts with a <) and default-code (everything else). See https://github.com/google/code-prettify/blob/master/src/prettify.js#L1346
From the plugins in that list... I would possibly paste code in at least: CSS, Erlang, Haskell, Lisp/Scheme, Lua, SQL and LaTeX, and possibly MATLAB, R and TCL...
So why not all of them if not just not start to use https://highlightjs.org/ instead as #189 suggest... it seems to do much more and actually do real autodetection. Seems it should be pretty easy to just change.
Yeah, if we go the way if including plugins I would sat we have an option for the admin to bundle or not to bundle these files. Maybe a PrivateBin instance is mostly used for non-code or the admin wants the site to load fastly without that much JavaScript files or so.
I think it would actually be better to just replace the whole highlight-engine with highlight.js, and and may bundle a few variants of the language-sets... it was pretty easy to replace prettify with highlight.js when i tried last night. only a few lines in privatebin.js and replacing some lines in the templates. Though, i tried with the full language-set, and that is actually a bit slow as the js-file is nearly 500k then, the default set of 23 or so languages was only a fraction of that.
Okay, that sounds good, so PRs are very welcome. If diff/patch is also highlighted then you can also mark it as "fixes https://github.com/PrivateBin/PrivateBin/issues/189".
Seems it does, but what it does not do is line-numbering... but that could probably be added by another js lib...
Yes, that's okay.
Most helpful comment
Seems it does, but what it does not do is line-numbering... but that could probably be added by another js lib...