packages

nabi_syntax

On this page

Tokenizer and HTML highlighter for Nabi and NABION: keywords, types, strings (f-string holes as code, nested; raw strings), chars, numbers, comments, attributes and macros. r#name is an identifier, never a keyword. The classes follow grammars/classes.nabion, the table the TextMate grammars in grammars/ are tested against.

Structs

TokenSource

pub struct Token

A slice of the source. Concatenating the text of all tokens gives the source back.

Enums

KindSource

pub enum Kind

What a token is. Text is everything else (identifiers, raw identifiers, labels, operators, punctuation, whitespace).

Functions

tokensSource

pub fn tokens(src: str) -> List<Token>

Tokens of Nabi source.

tokens_nabionSource

pub fn tokens_nabion(src: str) -> List<Token>

Tokens of NABION source: as Nabi, but only true / false / none are keywords and a name before : is a field.

highlight_nabiSource

pub fn highlight_nabi(src: str) -> str

Nabi source as HTML: tokens as <span class=".."> (see Kind::class), & / < / > escaped. Goes inside <pre><code>.

highlight_nabionSource

pub fn highlight_nabion(src: str) -> str

NABION source as HTML, as highlight_nabi.

to_htmlSource

pub fn to_html(toks: List<Token>) -> str

Tokens as HTML, as highlight_nabi.