Code

Unmaintained Code 2.2.0

No permission to download
Compatible XF 2.x versions
  1. 2.0
  2. 2.1
  3. 2.2
Additional requirements
For 2.1+ versions:
• XenForo 2.1
• PHP 7 +
License
GPLv3
Visible branding
No
182661


Description

This addon makes code bbcode and code editor way more functional by adding copy, expand, collapse buttons, resizer bar, code line numbers and ability to highlight lines.

This is an open source addon. Visit GitHub repository for source code.

All my addons are free...

But if you want to
  • Be informed of all news about developing new addons
  • Suggest and vote for new addons
  • Try beta versions
  • Receive 24-hour early access to new addons
Then you can support me on my Patreon!
185114
___

Features

182662


Custom title and lines highlighting

You can now specify a custom code block header title. For example, users can provide a filename for code blocks instead of writing it in the text or putting the whole code block inside a spoiler with filename title.

Moreover, you can even highlight certain lines!

Custom title and lines to be highlighted can be set via "Insert code" dialog:

197063


You can also set the title and lines to highlight directly in text editor by adding title="..." and highlight="..." parameters in code bbcode.

Example: [code lang="php" title="My Custom Title"]<? .... ?>[/code] will produce this codeblock:

182669


Hovering custom title will show the code language:

182670


Example of highlighting: [code lang="php" highlight="2, 5-8"]a log of code...[/code]

197064


Expand/Collapse buttons

Expand button smoothly increasing the height of code block until all the code is showing. It is visible only when code block height is LESS than the actual code size.

Collapse button smoothly decreasing the height of code block to it's default height which you can set in style properties. It is visible only when code block height is LARGER than default code block height.

182671


Both expand and collapse buttons are visible when code block height is within min and max limits and invisible on code blocks that are smaller than default code block height.

The default height of code block can be set in style properties ("Code" section below "Messages"):

182677


Copy button

Copy button simply copy the code right into your clipboard:

182673


Line numbers

All code blocks have line numbers (up to 1000 lines). Line numbers can be turned off via style properties:

182674


Resizer

Every code block which code height is larger than the default height has a resizer bar. It allows users to vertically resize code block:

182675


Common languages

I always thought there is something wrong about "Common languages". Why can't we set which languages are "common" to our specific forum? Weird...

With Code addon you can now set common languages right after "Allowed code languages" option in "Messages" option-group:

182678


Hurray!

182681


Default language

You can also set a default language code for "Insert code" dialog via "Default code language" option after common languages in "Messages" option-group:

182689


Custom code block CSS class

There is an option to add a custom CSS class for code block. Just specify class="..." BB code attribute for that. Now you can style code blocks with this class. Here is an example:

197065

___

Installation
  1. Download the addon
  2. Upload contents of upload folder to your forum root
  3. In admin control panel go to "Addons" section and install Code
Unistallation

WARNING: after unistalling all code blocks with custom titles/highlighting/class will not be rendered as code blocks!
  1. Uninstall the addon from ACP
  2. Go to forum root folder and remove js/CMTV/Code folder.
That's it!

All my addons are free...

But if you want to
  • Be informed of all news about developing new addons
  • Suggest and vote for new addons
  • Try beta versions
  • Receive 24-hour early access to new addons
Then you can support me on my Patreon!
185115
Author
CMTV
Downloads
323
Views
8,512
First release
Last update

Ratings

4.50 star(s) 8 ratings

More resources from CMTV

Latest updates

  1. Update 2.2.0

    Features An option to set a default code language for all code block on the forum without...
  2. Hotfix 2.1.2

    Fixes a problem with upgrading. If any other errors happen, try to fully remove the addon. Than...
  3. Bug fixes 2.1.1

    Fixed bugs Fixed an ACP error when XF sends an email notification about new post in the thread...

Latest reviews

Bad support since weeks... Some people gets some error or dysfunction but no help provided from @CMTV.
Very helpful to have the copy to clipboard feature and to have the expanding feature. It makes using the "code" bbcode preferable than to use the "list" bbcode for example. Thank you.
Excellent addon :)
I really appreciate free addons like this, it helps a lot.
Keep up the good work!!!
Works perfectly! Great for communities that post a lot of coding examples. Support is great, helps you with all your issues.
Fantastic add-on! Now my forum's codes are very simple to manage and copy/paste for my users!

Congratulations to developer ;)
I was able to add in a lua and VB language packs and had it all working almost instantly! (... instantly after I striped out all of the "visual-basic" references in the .min.js and rename them to "vb", and then use vb everywhere.) Great add on, I really appreciate it!

Follow instructions here for additional languages: https://xenforo.com/community/resources/additional-language-for-code-bbcode.5985/
This mod is great, it does line numbers and copy button and dark/light theme and expand all in one mod. You had to use 3 mods before to get 75% of this functionality.
Love it, I always have to share code and the default viewer misses exactly what this addon does. Must have if you share code in your community.
Top Bottom