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. Every stretch the document’s own parser calls code — or raw HTML — is copied through untouched, so a fence showing ==highlight== stays a fence showing ==highlight==.

Runs for Markdown and Djot. 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.