blogatto/config/post/code
This module exposes the configuration for syntax highlighting of code blocks in blog posts.
Types
The configuration for syntax highlighting of code blocks in markdown files.
pub opaque type SyntaxHighlightingConfig(msg)
Values
pub fn add_language(
config: SyntaxHighlightingConfig(msg),
grammar_fn: fn() -> grammar.Grammar,
language_names: List(String),
) -> SyntaxHighlightingConfig(msg)
Adds a new language to the syntax highlighting configuration.
pub fn attribute(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn builtin(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn comment(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn constant(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn custom(
config: SyntaxHighlightingConfig(msg),
element: fn(String, String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn default() -> SyntaxHighlightingConfig(msg)
Returns the default configuration for syntax highlighting of code blocks in blog posts.
pub fn function(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn highlight(
config: SyntaxHighlightingConfig(msg),
language: String,
source: String,
) -> Result(List(element.Element(msg)), Nil)
Highlights source code for the given language, returning highlighted Lustre elements. Returns Error(Nil) if the language is not in the configured languages dictionary.
The language argument is the code fence info string, which may carry more
than the language name. CommonMark treats everything up to the first space as
the language, and authors commonly append a title or filename after a :
(e.g. cpp:main.ino). The full info string is matched first so explicitly
registered language names keep working, then the leading token is tried as a
fallback so these decorated fences still resolve to a grammar.
pub fn keyword(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn module(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn number(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn operator(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn property(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn punctuation(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn regex(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn selector(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn smalto_config(
config: SyntaxHighlightingConfig(msg),
smalto_lustre_config: lustre.Config(msg),
) -> SyntaxHighlightingConfig(msg)
Sets the smalto_lustre configuration for syntax highlighting. This allows you to customize how different token types are rendered.
pub fn string(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn tag(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn type_(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)
pub fn variable(
config: SyntaxHighlightingConfig(msg),
element: fn(String) -> element.Element(msg),
) -> SyntaxHighlightingConfig(msg)