tiny.syn.highlightLine
Defined in scan.line.
Marks up one line of a document and updates state with what the line leaves open.
Source
Source: lib/syn/src/scan/line.zig:64
zig
/// Marks up one line of a document and updates `state` with what the line leaves open. A caller/// walking a document line by line passes the same `State` to every call, so comments and strings/// that run over more than one line are marked correctly. The call replaces the storage's spans/// with this line's spans, each an offset into `text`. The call keeps no spans and returns/// `.discarded` when the line is longer than the text limit. That line is still scanned in full, so/// `state` comes out the same as it would with room to spare. A comment or string that `state`/// carries from a different language is dropped, and the line is scanned fresh. A comment or string/// that `state` carries from this language runs up to its closing delimiter as one comment or/// string span, and the rest of the line is scanned as usual. A line with no closing delimiter/// becomes one span, and the comment or string stays open. The storage must be activated before the/// call, and the call allocates nothing. The call keeps no reference to `text`.pub fn highlightLine( language: Language, text: []const u8, state: *State, spans: *SpanStorage,) syn.SpanMaterialization { const materialization = prepare(spans, text.len); state.rebind(language); if (!highlightContinuing(language, text, state, spans)) { state.retain(language, highlightFlat(language, text, spans)); } return materialization;}Source: lib/syn/src/root.zig:59
zig
pub const highlightLine = scan.highlightLine;Also reachable as
Complete caller list
11 direct callers.
tiny.syn.scan.line.highlight[function] atlib/syn/src/scan/line.zig:44lib.syn.src.scan.test.test_activated_syntax_highlighting_performs_no_backing_allocation[function] — test source atlib/syn/src/scan/test.zig:400in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_foreign_continuation_equals_a_fresh_target-language_scan[function] — test source atlib/syn/src/scan/test.zig:256in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_rust_lifetime_and_block_opener_produce_one_coherent_transition[function] — test source atlib/syn/src/scan/test.zig:284in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_syn_line_state_carries_a_new_block_opened_after_a_continuation_closes[function] — test source atlib/syn/src/scan/test.zig:165in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_syn_line_state_carries_generic_block_comments[function] — test source atlib/syn/src/scan/test.zig:146in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_syn_line_state_carries_markup_comments_and_toml_strings[function] — test source atlib/syn/src/scan/test.zig:203in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_syn_line_state_carries_python_triple_strings[function] — test source atlib/syn/src/scan/test.zig:180in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_syntax_highlighting_discards_max_plus_one_text_bytes_after_exact_state_scanning[function] — test source atlib/syn/src/scan/test.zig:306in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_syntax_span_storage_reuses_one_region_across_languages_and_lines[function] — test source atlib/syn/src/scan/test.zig:372in nearest public ownerlib.syn.src.scan.testlib.syn.src.scan.test.test_toml_escaped_triple_delimiter_retains_the_scanner_transition[function] — test source atlib/syn/src/scan/test.zig:231in nearest public ownerlib.syn.src.scan.test
Audit
| Definitions | 1 |
|---|---|
| Public names | 3 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |