
CodeBlock+ is a Confluence Cloud macro for code. Each block can have a title, line numbers that start wherever your excerpt starts, highlighted lines, a collapse toggle, a copy button and a wrap toggle. Syntax highlighting covers 35 languages and runs in the reader's browser, so the code never leaves Atlassian.
<img src="screenshots/view-demo.png" alt="A Python block titled retry.py with lines 6 to 8 highlighted" width="760">
The title bar shows the title (or the language when there's no title), the language and the line count. Click the title to collapse or expand the code. Copy puts the code on the clipboard exactly as it was saved, without line numbers. Wrap switches long lines between wrapping and side scrolling for that reader only.
Selecting code with the mouse doesn't pick up the line numbers. Colours follow Confluence's light and dark themes.
Insert CodeBlock+ from the macro menu and the editor opens. Paste your code, then set what you need.
deploy.sh, src/app.ts or Dockerfile, the language is picked for you. You can change it, and once you do, the title stops changing it.3, 7-9 (7 - 9 works too). These are the numbers readers see.A live preview sits under the form. Mistakes are named next to the field (for example In "8-5" the second number is smaller than the first.) and Save stays off until they're fixed.
Exports get the block as Confluence's own code block, with the title in bold above it and the language set where Confluence knows it. Exports always show the whole code, even when the block starts collapsed. Line numbers and highlighted lines don't carry over, because Confluence's export format has no place for them.
Every block stores plain settings next to its code, with a version number. Reading them never fails and never drops code.
"true" or "42", are understood.The code is only ever inserted as text. highlight.js output goes through a strict parser that accepts nothing but its own <span class> tags and the entities for five characters, and checks that the text matches your code character for character. Anything else falls back to plain text. The page is built with DOM calls, not HTML strings.
If code contains invisible text-direction characters (the "Trojan Source" trick, CVE-2021-42574), the block says how many there are, so readers aren't misled about what the code does.
| Limit | Value |
|---|---|
| Code per block | 50,000 characters and 3,000 lines (the editor won't save more) |
| Title | 150 characters, one line |
| Highlighted lines | 50 numbers or ranges, 200 characters |
| First line number and highlighted lines | 1 to 1,000,000 |
A block that somehow holds more than 50,000 characters (say, edited through the API) still shows all of it, just without colours.
Some code is shown without colours to keep the page responsive, with a note saying so. The check is an estimate based on the code and its language, not a timer. It applies in these cases.
_ $ . - < > in all four, plus * & : in C and C++ and " \ in INI.List<int> x run for about 1,600 characters without a ;, ( or =.<a> that open where JSX can start have no closing tag, or a far-off one, adding up across the code.{ or ( are left open.Plain lists in YAML or Markdown don't trigger it, and neither does [, so coloured shell output (\033[) and regexes keep their colours. A single 50,000-character word used to take up to 13 seconds to colour. We fuzzed the check with Node on a Mac (npm run fuzz-cost and the scan scripts in scripts/), about 350,000 cases across all 35 languages at up to 50,000 characters. The slowest code that still got colours took about 200 ms. That's what we measured on the shapes we tried, not a promise for every input. Among the app's own dependencies, about 1% of JavaScript and 2% of TypeScript files lost their colours, all with lines over 3,000 characters. No YAML, JSON, Markdown or CSS file did.
Bash, C, C++, C#, CSS, Diff, Dockerfile, Go, GraphQL, Groovy, HTML / XML, INI / TOML, Java, JavaScript, JSON, Kotlin, Lua, Makefile, Markdown, Nginx, Objective-C, Perl, PHP, PowerShell, Python, R, Ruby, Rust, Scala, SCSS, Shell session, SQL, Swift, TypeScript and YAML, plus Plain text. The language isn't guessed from the code itself. We tried highlight.js auto-detection and it labelled a short Python script as CSS.
CodeBlock+ asks for no Confluence scopes and declares no outside hosts. The code lives in the macro's own settings on the page, like any other macro. The app has no database and stores nothing else. Two small Forge functions run on Atlassian. One builds the export. The other is an old status check that the current version doesn't call. See PRIVACY.md.
Use the support link on the Marketplace listing. Please include the page URL and, if you can, the block's language and length.
Zovo builds and maintains this app. If it saves you time, you can support the work on GitHub Sponsors. Sponsorship is optional, and the tool works the same without it.
Zovo is made by theluckystrike on GitHub.
CodeBlock+ is MIT licensed. The browser bundles include highlight.js (BSD-3-Clause) and @forge/bridge, which brings in iframe-resizer (MIT), lodash (MIT), tslib (0BSD), @forge/i18n and @forge/egress. Their notices are in THIRD_PARTY_NOTICES.md and ship next to each bundle.
If this app saves you time, you can support the work on GitHub Sponsors. Monthly tiers start at $5, and one-time tiers start at $15. Sponsorship is optional, and the tool works the same without it.