Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted June 4, 20159 yr When adding code blocks to a post, the only options are HTML, CSS, JS and PHP. But what about all the other code languages out there. Obviously it's not possible to cater for every language but can we please at least have a "plain" code option that doesn't attempt any highlighting. At least that way other code languages can be added, even if not highlighted. At the moment, the only option is to use one of the available options which results in odd and incorrect highlighting.
June 4, 20159 yr Author Having done some more research, it seems that there is a "None" option in IPB3.4 but this has been dropped in IPB4. Why on Earth did that happen? This could well be a deal-breaker for me. I'm currently planning a move from vB for a forum with a large proportion of coders using coding languages other than those available in IPB4.
June 4, 20159 yr There is a plugin offered by the editor that adds a good bit of langues and the none option I believe
June 4, 20159 yr Author There is a plugin offered by the editor that adds a good bit of langues and the none option I believeI've no doubt I could spend a couple of weeks working on a bespoke solution to the problem but it seems nonsensical to remove a feature that made the product much more inclusive. Effectively, IPB4 cannot be used by any community of coders that require anything other than HTML, CSS, JS and PHP.
June 4, 20159 yr Management Calm down before you go all lol He is referring to something like: http://ckeditor.com/addon/codesnippet Which you can just drop in if your community needs such features. There are tons of editor plugins available.
June 4, 20159 yr Everything is a deal breaker it seems these days. With a community full of coders, Im sure somebody can push the right button.
June 4, 20159 yr Author Calm down before you go all lol He is referring to something like: http://ckeditor.com/addon/codesnippet Which you can just drop in if your community needs such features. There are tons of editor plugins available. OK, point taken But, when you say "drop in", what exactly do you mean? If you could give a brief pointer on this, I'll check it out. Thanks.
June 4, 20159 yr OK, point taken But, when you say "drop in", what exactly do you mean? If you could give a brief pointer on this, I'll check it out. Thanks. Upload to /applications/core/interface/ckeditor/ckeditor/plugins/
June 4, 20159 yr Author OK, I installed Code Snippet, Widget and Line Utilities (dependencies) using the Admin CP. All went well but having done that, I see no difference in the editor or in the code options drop-down. Do I need to edit some config file or initialise it in some way?
June 4, 20159 yr Author Ah! OK, you have to install everything in reverse order otherwise nothing works (the install error message is not clear). 1. Add button: Line Utilities 2. Add button: Widget 3. Add button: Code Snippet It almost works If I add some LISP code and select any option, it just gets posted as plain text and not a code block, presumably because the language is not recognised. So, all I need to do now is spend a few weeks learning how to write a javascript syntax highlighter for LISP. Oh joy!
June 8, 20159 yr Ah! OK, you have to install everything in reverse order otherwise nothing works (the install error message is not clear). 1. Add button: Line Utilities 2. Add button: Widget 3. Add button: Code Snippet It almost works If I add some LISP code and select any option, it just gets posted as plain text and not a code block, presumably because the language is not recognised. So, all I need to do now is spend a few weeks learning how to write a javascript syntax highlighter for LISP. Oh joy! According to https://github.com/google/code-prettify, lisp (and a whole load of other languages) are supported by plugins. The lisp plugin is https://github.com/google/code-prettify/blob/master/src/lang-lisp.js - just include that file with the rest of your JS. Note: I haven't actually tested it, so I'm not 100% sure that it works in IPS4. However, when injected into this page, it doesn't throw any errors, so it looks like it should work. Just tested - it does work Though I've found a bug with the built in code tags - by default, no language-specific class is applied to the code, so the prettyprinter has to autodetect the language. It also means that when you edit the code, the syntax highlighter in the editor defaults to HTML. If I edit the code that's posted to the server (by intercepting the POST request) and add the relevant class, it works fine. Inside the editor before it's sent to the server, it has the data-pbcklang attribute, but still no lang-* class. The data-pbcklang attribute is posted to the server, but presumably stripped out by your html sanitiser.
June 9, 20159 yr According to https://github.com/google/code-prettify, lisp (and a whole load of other languages) are supported by plugins. The lisp plugin is https://github.com/google/code-prettify/blob/master/src/lang-lisp.js - just include that file with the rest of your JS. Note: I haven't actually tested it, so I'm not 100% sure that it works in IPS4. However, when injected into this page, it doesn't throw any errors, so it looks like it should work. Just tested - it does work Though I've found a bug with the built in code tags - by default, no language-specific class is applied to the code, so the prettyprinter has to autodetect the language. It also means that when you edit the code, the syntax highlighter in the editor defaults to HTML. If I edit the code that's posted to the server (by intercepting the POST request) and add the relevant class, it works fine. Inside the editor before it's sent to the server, it has the data-pbcklang attribute, but still no lang-* class. The data-pbcklang attribute is posted to the server, but presumably stripped out by your html yeah, quite a few bugs in this area. I've had to do a lot of mods to make plain/other languages work. I've reported a lot some pending, some denied, some ignored This is the one that you mentioned above I think http://community.invisionpower.com/4bugtrack/rc7a-pbckcode-not-using-correct-prettyprint-classes-r4925/
June 9, 20159 yr Adding new plugins is a bit of a chore as well. The other syntax highlighter plugins need configuration in config.js which gets wiped out on upgrade. There are also some conflicts with hard coded IPS configs which can only be overridden by manually editing JavaScript within the db (ui.editor). For example, the built in plugin pbckcode can be configured to add other languages usually by editing config.js. Unfortunately IPS have already hard coded that particular option so editing config.js doesn't work. Like I said, a lot of mods required to fine tune this stuff. I've uploaded a plugin that works around the bug mentioned in the previous post, but I still edit the db manually to add a plain text option and another language.
June 16, 20159 yr Author This just seems way too difficult for something that ought to be in there by default. I cannot understand why a non-highlighted code option isn't included as an option. This one addition would mean code blocks can be added to posts for any language (sans highlighting). As it stands, I can't move to IPS and as I said above, this is a deal-breaker , which is really sad because in every other respect, IPS is ideal.
June 17, 20159 yr Wow wow wow! I just saw the plugins for toolbars! There are so many for CKEditor. Going to check them out.
August 30, 20159 yr Author I realise development efforts are primarily directed towards stability at the moment but is there any update on this? I'd love to move my forum to IPB but can't do so until the "None" code option has been restored to 4.0.
September 10, 20159 yr I'm stuck at this code highlighting too.How to add more languages to the default editor?
November 16, 20177 yr On 9/30/2016 at 5:05 AM, san3ani said: codesnippet plugin is not doing any highlighting any help? seems to be impossible
Archived
This topic is now archived and is closed to further replies.