Cherry.Content.Components (cherry v0.4.1)

Copy Markdown View Source

Content components: a small, framework-level set of directives that work in any theme, so content never accumulates theme-specific markup (DESIGN.md — that is precisely why Jekyll theme swaps break).

The syntax is the remark-directive convention modern authors already know from Docusaurus and VitePress:

::figure{src="images/pipeline.svg" alt="The pipeline" caption="Nine stages."}

::video{youtube="dQw4w9WgXcQ" title="The demo"}

:::tip{title="Heads up"}
Any **markdown** works in here.
:::

Leaf directives (::name{…}) sit on their own line; containers (:::name{…}:::) wrap markdown. The five containers are the GitHub alert types — note, tip, important, warning, caution — rendered onto the same .markdown-alert-* classes both official themes already style, with an optional custom title.

Rendering happens before markdown (the emitted HTML is block-level and blank-line separated, so the markdown between container fences renders normally). Bad usage never breaks a build: an unknown name or a missing required attribute leaves the line verbatim in the output and becomes a component diagnostic in cherry check, which names the file, the directive, and what is wrong.

Summary

Functions

Diagnostics for every directive-shaped line the renderer refused: unknown component names, missing required attributes, attributes the component does not take, and an unclosed container fence.

Expands every well-formed directive in a markdown body to HTML.

Functions

diagnose(body, file)

@spec diagnose(String.t(), Path.t()) :: [Cherry.Check.Diagnostic.t()]

Diagnostics for every directive-shaped line the renderer refused: unknown component names, missing required attributes, attributes the component does not take, and an unclosed container fence.

render(body, base_path \\ "/")

@spec render(String.t(), String.t()) :: String.t()

Expands every well-formed directive in a markdown body to HTML.

Root-absolute src/poster paths pick up the site's base_path (/images/a.svg/repo/images/a.svg on project pages) — one thing components can do for authors that raw markdown cannot. Malformed or unknown directives are left byte-for-byte alone — diagnose/2 is where they get named.