Wraith.Markdown (Wraith v0.1.0)

View Source

Post bodies are Markdown (GFM: tables, strikethrough, task lists, footnotes, autolinks) rendered by mdex and sanitised — raw HTML an author pastes in is kept but scripts, handlers and the like are dropped.

Widgets are embedded as shortcodes on a line of their own:

{{widget poll question="Tabs or spaces?" options="Tabs|Spaces"}}
{{widget counter}}
{{widget countdown to=2027-01-01 id=launch}}

segments/1 splits a body into {:html, html} and {:widget, slug, props, instance} parts; the post page renders the HTML raw and each widget live. id= names the instance so the same state can be shared across posts; without it the instance is <post id>:<n>.

Summary

Functions

The URLs of a body's {{embed …}} lines, in order.

The free part of a body: everything above <!--members-only--> (Ghost's public preview), or nil when there is no marker.

Estimated minutes to read.

Split a post body into HTML and widget segments; scope seeds unnamed instance ids.

The body without the paywall marker (what a reader with access sees).

Plain text for excerpts and feeds.

The headings (h2/h3) of a body as [%{id, level, text}] — the table of contents.

The shortcodes in a body: [{slug, props}] — for the editor's sidebar and the agent.

Types

segment()

@type segment() :: {:html, String.t()} | {:widget, String.t(), map(), String.t()}

Functions

embed_urls(markdown)

@spec embed_urls(String.t()) :: [String.t()]

The URLs of a body's {{embed …}} lines, in order.

public_preview(markdown)

The free part of a body: everything above <!--members-only--> (Ghost's public preview), or nil when there is no marker.

reading_minutes(markdown)

Estimated minutes to read.

segments(markdown, scope \\ "page")

@spec segments(String.t(), String.t()) :: [segment()]

Split a post body into HTML and widget segments; scope seeds unnamed instance ids.

strip_paywall(markdown)

The body without the paywall marker (what a reader with access sees).

to_html(markdown)

@spec to_html(String.t()) :: String.t()

to_text(markdown)

Plain text for excerpts and feeds.

toc(markdown)

@spec toc(String.t()) :: [map()]

The headings (h2/h3) of a body as [%{id, level, text}] — the table of contents.

widgets_in(markdown)

The shortcodes in a body: [{slug, props}] — for the editor's sidebar and the agent.