cfish Posted June 4, 2015 Posted June 4, 2015 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.
cfish Posted June 4, 2015 Author Posted June 4, 2015 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.
Smallxmac Posted June 4, 2015 Posted June 4, 2015 There is a plugin offered by the editor that adds a good bit of langues and the none option I believe
cfish Posted June 4, 2015 Author Posted June 4, 2015 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.
Management Charles Posted June 4, 2015 Management Posted June 4, 2015 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.
Kevin Carwile Posted June 4, 2015 Posted June 4, 2015 Everything is a deal breaker it seems these days. With a community full of coders, Im sure somebody can push the right button.
cfish Posted June 4, 2015 Author Posted June 4, 2015 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.
Ahmad E. Posted June 4, 2015 Posted June 4, 2015 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/
Ryan Ashbrook Posted June 4, 2015 Posted June 4, 2015 You can also upload via your Admin CP > Customization > Toolbars > Add Button
cfish Posted June 4, 2015 Author Posted June 4, 2015 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?
cfish Posted June 4, 2015 Author Posted June 4, 2015 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!
Colonel_mortis Posted June 8, 2015 Posted June 8, 2015 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.
AutoItScript Posted June 9, 2015 Posted June 9, 2015 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/
AutoItScript Posted June 9, 2015 Posted June 9, 2015 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.
cfish Posted June 16, 2015 Author Posted June 16, 2015 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.
GrooveOnBeat Posted June 17, 2015 Posted June 17, 2015 Wow wow wow! I just saw the plugins for toolbars! There are so many for CKEditor. Going to check them out.
cfish Posted June 30, 2015 Author Posted June 30, 2015 I'll see if we can get it added That would be awesome
cfish Posted August 30, 2015 Author Posted August 30, 2015 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.
Lukeroge Posted August 30, 2015 Posted August 30, 2015 Edit: Ignore this post, you'll find out why... soon.
bwx Posted September 10, 2015 Posted September 10, 2015 I'm stuck at this code highlighting too.How to add more languages to the default editor?
san3ani Posted September 30, 2016 Posted September 30, 2016 codesnippet plugin is not doing any highlighting any help?
wdport Posted November 16, 2017 Posted November 16, 2017 On 9/30/2016 at 5:05 AM, san3ani said: codesnippet plugin is not doing any highlighting any help? seems to be impossible
Recommended Posts
Archived
This topic is now archived and is closed to further replies.