The schema Coelho ships with.
It covers what an application typically needs out of the box — paragraphs, headings, lists, quotes, code blocks, images and the usual inline marks — and is meant to be copied and adapted rather than extended in place.
What the link mark emits
An href and a title, and nothing else. In particular no target and
no rel: a document is not necessarily rendered into a page where
opening a new tab makes sense, and a target="_blank" without
rel="noopener" hands the opened page a handle on the opener. Rather than
guess, the shipped renderer emits neither.
An application that wants them says so per render, and must set both:
Coelho.to_html(document,
marks: %{
link: fn mark, inner ->
Coelho.Render.tag(
"a",
[
{"href", Coelho.Render.safe_url(Coelho.Render.attr(mark, "href"))},
{"target", "_blank"},
{"rel", "noopener noreferrer"}
],
inner
)
end
}
)The href still goes through Coelho.Render.safe_url/1 there, because a
stored document is not re-validated on the way out.
Alignment
paragraph, heading and list_item carry an align attribute, one of
left, center, right or justify, rendered as a text-align style
and read back from either a style or an align attribute on import. It
is absent from the document when unset, and re-checked against the closed
list at render time.
The schema is built once and kept in :persistent_term, since it is
immutable and read on every render.
Summary
Functions
@spec build() :: Coelho.Schema.t()
Builds the default schema without consulting the cache.
@spec schema() :: Coelho.Schema.t()
Returns the default schema, building it on first use.