Skip to content

module

html

Turning CMS HTML into Markdown (which templates render safely with markdown(source: …)) or plain text.

Structs

  • SliderStyle

    How a site's sliders in content look and move, as its theme has them (weft migrate learns it from a post with one). What's not known has a neutral default.

Functions

block_markdown

pub fn block_markdown(html: &str) -> Option<String>

One element's HTML as a Weft part in a Markdown component block, when it's a block html_to_markdown makes one of.

decode_entities

pub fn decode_entities(s: &str) -> String

Decode the common HTML entities (named, decimal and hex).

html_to_markdown

pub fn html_to_markdown(html: &str) -> String

HTML → Markdown: headings, paragraphs, emphasis, links, images, lists, quotes, code and line breaks. Scripts, styles and unknown tags are dropped (their text is kept, except for scripts and styles).

The block editor's blocks become Weft parts, as Markdown component blocks (see wp_block), and so do tables and details.

html_to_text

pub fn html_to_text(html: &str) -> String

HTML → plain text (for excerpts and titles).

is_slider

pub fn is_slider(class: &str) -> bool

A slider script's own class, on the element holding its slides.

set_slider_style

pub fn set_slider_style(style: impl FnOnce() -> SliderStyle)

The site's slider style, for content converted from now on (the first call counts).

slider_classes

pub fn slider_classes(html: &str) -> Option<Vec<String>>

The classes of the first slider in some HTML, if it has one.