Skip to main content

preprocess_custom_syntax

Function preprocess_custom_syntax 

Source
pub fn preprocess_custom_syntax(source: &str, format: ContentFormat) -> String
Expand description

Pre-process Diaryx’s custom syntax (highlights, spoilers, HTML embeds) into raw HTML before the body is parsed. Skips fenced code blocks and inline code.

Runs for Markdown and Djot, which share backticks for both code spellings, so the same scanner keeps its hands off code in either. It is deliberately the same syntax in both: someone who switches a vault’s content_format should not find that ==highlight== stopped working. Djot’s native {=highlight=} still works too — twig parses it — it just renders a plain <mark> without Diaryx’s colour classes.

HTML bodies are returned untouched. == and || are literal text there, and a body that is already HTML has no need of an escape hatch into it.