Wrap output with custom HTML
- JavaScript
- Rust
- Elixir
const html = await highlight(
'const x = 1',
htmlInline({
language: javascript,
theme: dracula,
header: {openTag: '<figure><figcaption>index.js</figcaption>', closeTag: '</figure>'},
})
)
use lumis::{highlight, HtmlInlineBuilder, formatters::html::HtmlElement, languages::Language, themes};
let html = highlight(
"fn main() {}",
HtmlInlineBuilder::new()
.language(Language::Rust)
.theme(Some(themes::get("dracula").unwrap()))
.header(Some(HtmlElement {
open_tag: "<figure><figcaption>main.rs</figcaption>".to_string(),
close_tag: "</figure>".to_string(),
}))
.build()
.unwrap(),
);
Lumis.highlight!(
"const x = 1",
formatter: {:html_inline,
language: "javascript",
theme: "dracula",
header: %{open_tag: "<figure><figcaption>index.js</figcaption>", close_tag: "</figure>"}
}
)
See Build a code block header with copy button for a fuller pattern.