Expand description
Advanced building blocks for custom syntax-highlighted renderers.
Most users should use Code(). This module exposes the
lower-level source, span, segment, and theme helpers used by companion
components such as dioxus-code-editor.
use dioxus_code::Language;
use dioxus_code::advanced::{HighlightSpan, HighlightedSource};
static SPANS: &[HighlightSpan] = &[HighlightSpan::new(0..2, "k")];
let src = HighlightedSource::from_static_parts("fn main() {}", Language::Rust, SPANS);
assert_eq!(src.spans().len(), 1);Re-exports§
pub use CodeThemeStyles_completions::Component::CodeThemeStyles;
Structs§
- Buffer
runtime - A live
(text, grammar)pair you can edit, reparse, and snapshot. - Code
Theme Styles Props - Properties for the
CodeThemeStylescomponent. - Highlight
Segment - A borrowed render segment with an optional highlight tag.
- Highlight
Span - A highlight span attached to a byte range of source text.
- Highlighted
Source - A highlighted source string with metadata and token spans.
- Source
Edit runtime - A byte-range edit description used to drive incremental highlighting.
- Token
Span Props - Props for
TokenSpan.
Enums§
- Highlight
Error - A typed error produced while preparing runtime syntax highlighting.
- Highlight
Query Error Kind - The category of a tree-sitter highlights query compilation error.
Functions§
- Code
Theme Styles - Inject the shared syntax theme stylesheet and selected theme stylesheet.
- Token
Span - Render one highlighted token as
<span class="a-{tag}">{text}</span>.