#[non_exhaustive]pub enum NodeType {
Show 28 variants
Blockquote,
Code,
Comment,
Document,
Em,
Error,
Fence,
Hardbreak,
Heading,
Hr,
Image,
Inline,
Item,
Link,
List,
Node,
Paragraph,
S,
Softbreak,
Strong,
Table,
Tag,
Tbody,
Td,
Text,
Th,
Thead,
Tr,
}Expand description
What kind of node this is.
Upstream’s NodeType is a union of string literals in types.ts, and the
spellings here are those strings exactly, because a schema is looked up by
them: a host writing nodes: { fence: ... } is naming this enum.
#[non_exhaustive] because Markdoc gained node types across its 0.5.x line.
Matching exhaustively on it in a host would turn each new one into a
breaking release of this crate.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Blockquote
> quoted.
Code
Inline code, `x`.
Comment
An HTML comment, when comments are enabled.
Document
The root of a parsed document.
Em
*emphasis*.
Error
A tag whose internals did not parse. Carries the failure in
Node::errors.
Fence
A fenced code block.
Hardbreak
A line break written as two trailing spaces or a backslash.
Heading
# heading.
Hr
A thematic break.
Image
.
Inline
The inline content of a block.
Not a Markdoc construct: it is the seam markdown-it puts between a block
and its inline children, and this port keeps it because the annotation
rules depend on it. An annotation is applied to the node that owns the
inline run, so # Title {% #id %} sets id on the heading rather than
on the text beside it, and an annotation with no inline run above it is
the no-inline-annotations error.
Item
A list item.
Link
[text](href).
List
An ordered or unordered list.
Node
The default, and what a host-constructed node is unless it says otherwise.
Paragraph
A paragraph.
S
~~strikethrough~~.
Softbreak
A newline inside a block.
Strong
**strong**.
Table
A table.
Tag
A Markdoc tag. The tag name is in Node::tag.
Tbody
A table body.
Td
A table body cell.
Text
A run of literal text. Its content is the content attribute, which may
hold a Value::Variable rather than a string.
Th
A table header cell.
Thead
A table header.
Tr
A table row.
Implementations§
Source§impl NodeType
impl NodeType
Sourcepub const ALL: [NodeType; 28]
pub const ALL: [NodeType; 28]
Every node type, in the order as_str lists them.
For a host that reads node names from text and wants to say what it
expected: the “expected one of” in its error is this list, joined. One
list here rather than a copy per host, because a copy is a second list
to keep in step with the enum. A variant added to the enum fails
as_str to compile until it gains an arm, and this sits beside it; the
test pins that every entry round-trips through as_str and
from_name and that none repeats, not that none
is missing, so add to both.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
Upstream’s spelling, which is the key a schema is registered under.
Sourcepub fn from_name(name: &str) -> Option<NodeType>
pub fn from_name(name: &str) -> Option<NodeType>
The node type upstream spells name, or None.
The inverse of NodeType::as_str. A host keys its nodes schema map
by these strings – upstream’s config is a JavaScript object literal, and
anything read from a file or a manifest arrives as text – so the mapping
has to run in both directions. Returning Option rather than defaulting
to NodeType::Node is the point: a misspelled key is a schema that
silently never applies, which is the hardest kind of schema bug to see.
Trait Implementations§
impl Copy for NodeType
impl Eq for NodeType
Source§impl Ord for NodeType
impl Ord for NodeType
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for NodeType
impl PartialOrd for NodeType
impl StructuralPartialEq for NodeType
Auto Trait Implementations§
impl Freeze for NodeType
impl RefUnwindSafe for NodeType
impl Send for NodeType
impl Sync for NodeType
impl Unpin for NodeType
impl UnsafeUnpin for NodeType
impl UnwindSafe for NodeType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.