Formatters
BBCode Scoped Formatter
Options and examples for Lumis BBCode scoped output with highlight-scope tags.
Scope-based BBCode tags for forum posts and BBCode-based platforms.
Options
| Runtime | Options |
|---|---|
| Rust | language, highlight_lines, rainbow_brackets |
| Elixir | language, highlight_lines, rainbow_brackets |
| JavaScript | language, highlightLines, rainbowBrackets |
| Java | withLang(), withFormatter(Formatter.BBCODE) |
| CLI | --highlight-lines, --rainbow-brackets |
A highlighted line is wrapped in [highlighted]...[/highlighted]. See
Line Highlighting.
Example
import {highlight} from '@lumis-sh/lumis'
import {bbcodeScoped} from '@lumis-sh/lumis/formatters'
import javascript from '@lumis-sh/lumis/langs/javascript'
const output = await highlight(
'const x = "[url=x]"',
bbcodeScoped({language: javascript})
)
console.log(output)
Output format
A tag is the scope name from the syntax tree and the language it was matched in, with the dots replaced by hyphens:
[keyword-function-rust]fn[/keyword-function-rust] [function-rust]main[/function-rust]bbcodeScoped() / :bbcode_scoped / bbcode-scoped emit highlight scope names as tags. They do not try to generate standard forum-style BBCode such as [b], [color], or [code].
When to use it
- Forum posts and BBCode-based platforms
- Custom rendering pipelines that consume scope-tagged text
- Lightweight markup without HTML overhead