I've been adding a lot of code samples to Confluence (v3.5.6) pages lately using the Code Block macro. The problem I'm facing is that a lot of the code I'm posting is in languages that aren't listed in the syntax highlighting options (Velocity templates, DOS batch files, Expect, etc). I'd like to create a set of custom syntax highlighting options for these languages but I can't find any documentation on how it's done. Has anyone tried this?
Community moderators have prevented the ability to post new answers.
Confluence used to have a Confluence Code Formatting plugin module, whereby you can create your own format for syntax highlighting. However, in Confluence 3.5.x and onwards, the Code Macro plugin has been replaced by New Code Macro plugin, which no longer supports the Code Formatting plugin module.
If you are set for some dirty work, you can probably customise the plugin JAR itself. You will notice that the plugin actually uses the SyntaxHighlighter by Alex Gorbatchev. In particular, each code format is presented by a JS file called as brush. As noted on the brushes page, you might be able to create your own by creating a custom brush.
I have no personal experience in developing a custom brush and incorporate it in the New Code Macro plugin, but hopefully this gives you some pointers!
Also, the source code for the New Code Macro plugin is at https://studio.plugins.atlassian.com/svn/NCODE/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was surprised that Velocity wasn't in the list of languages - it's pretty fundamental to Confluence! The https://marketplace.atlassian.com/plugins/de.scandio.confluence.plugins.pocketquery has velocity syntax highlighting - and a great template editor. Any plans for Confluence to include the same? It would make editing User Macros pretty slick.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or ABNF considering its use for formats and syntax documentation; definitely the code choices are limited for a doc engine, and seems something that should be easy to customize, even in the cloud (which seems likely most will be using these days). IDEs have solved this for a long time, and seems fitting a service specifically for documentation and editing would as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can find instructions to do this and examples if the formats in code macro documentation page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use of custom brushes is broken in Confluence 5.9. Please vote for https://jira.atlassian.com/browse/CONF-40838 if this affects you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Distilling the above answers, you can't add your own custom syntax in Confluence versions 3.5 to 5.3 (I'm running v4.3) without some heavy wizardry (see above). If you want to add your own syntax modules you have to upgrade to v5.3 or later.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
History repeats itself: in Jul 2013, pluggable JS "brushes" were added to NCODE 2.1.0, see
https://ecosystem.atlassian.net/browse/NCODE-18 and
https://ecosystem.atlassian.net/browse/NCODE-19
But this is available only for Confluence 5
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.