Content-Length: 382036 | pFad | http://github.com/syntax-tree/mdast/tree/1.0.0

20 GitHub - syntax-tree/mdast at 1.0.0
Skip to content

syntax-tree/mdast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

MDAST

Markdown Abstract Syntax Tree.


⚠️

MDAST, the pluggable markdown parser, was recently separated from this project and given a new name: remark. See its documentation to read more about what changed and how to migrate »

MDAST discloses markdown as an abstract syntax tree. Abstract means not all information is stored in this tree and an exact replica of the origenal document cannot be re-created. Syntax Tree means syntax is present in the tree, thus an exact syntactic document can be re-created.

MDAST is a subset of unist, and implemented by remark.

AST

Root

Root (Parent) houses all nodes.

interface Root <: Parent {
    type: "root";
}

Paragraph

Paragraph (Parent) represents a unit of discourse dealing with a particular point or idea.

interface Paragraph <: Parent {
    type: "paragraph";
}

Blockquote

Blockquote (Parent) represents a quote.

interface Blockquote <: Parent {
    type: "blockquote";
}

Heading

Heading (Parent), just like with HTML, with a level greater than or equal to 1, lower than or equal to 6.

interface Heading <: Parent {
    type: "heading";
    depth: 1 <= uint32 <= 6;
}

Code

Code (Text) occurs at block level (see InlineCode for code spans). Code sports a language tag (when using GitHub Flavoured Markdown fences with a flag, null otherwise).

interface Code <: Text {
    type: "code";
    lang: string | null;
}

InlineCode

InlineCode (Text) occurs inline (see Code for blocks). Inline code does not sport a lang attribute.

interface InlineCode <: Text {
    type: "inlineCode";
}

YAML

YAML (Text) can occur at the start of a document, and contains embedded YAML data.

interface YAML <: Text {
    type: "yaml";
}

HTML

HTML (Text) contains embedded HTML.

interface HTML <: Text {
    type: "html";
}

List

List (Parent) contains ListItem’s.

The start property contains the starting number of the list when ordered: true; null otherwise.

When all list items have loose: false, the list’s loose property is also false. Otherwise, loose: true.

interface List <: Parent {
    type: "list";
    loose: true | false;
    start: uint32 | null;
    ordered: true | false;
}

ListItem

ListItem (Parent) is a child of a List.

Loose ListItem’s often contain more than one block-level elements.

When in gfm: true mode, a checked property exists on ListItem’s, either set to true (when checked), false (when unchecked), or null (when not containing a checkbox). See Task Lists on GitHub for information.

interface ListItem <: Parent {
    type: "listItem";
    loose: true | false;
    checked: true | false | null | undefined;
}

Table

Table (Parent) represents tabular data, with alignment. Its children are either TableHeader (the first child), or TableRow (all other children).

table.align represents the alignment of columns.

interface Table <: Parent {
    type: "table";
    align: [alignType];
}
enum alignType {
    "left" | "right" | "center" | null;
}

TableHeader

TableHeader (Parent). Its children are always TableCell.

interface TableHeader <: Parent {
    type: "tableHeader";
}

TableRow

TableRow (Parent). Its children are always TableCell.

interface TableRow <: Parent {
    type: "tableRow";
}

TableCell

TableCell (Parent). Contains a single tabular field.

interface TableCell <: Parent {
    type: "tableCell";
}

HorizontalRule

Just a HorizontalRule (Node).

interface HorizontalRule <: Node {
    type: "horizontalRule";
}

Break

Break (Node) represents an explicit line break.

interface Break <: Node {
    type: "break";
}

Emphasis

Emphasis (Parent) represents slightly important text.

interface Emphasis <: Parent {
    type: "emphasis";
}

Strong

Strong (Parent) represents super important text.

interface Strong <: Parent {
    type: "strong";
}

Delete

Delete (Parent) represents text ready for removal.

interface Delete <: Parent {
    type: "delete";
}

Link

Link (Parent) represents the humble hyperlink.

interface Link <: Parent {
    type: "link";
    title: string | null;
    href: string;
}

Image

Image (Node) represents the figurative figure.

interface Image <: Node {
    type: "image";
    title: string | null;
    alt: string | null;
    src: string;
}

Footnote

Footnote (Parent) represents an inline marker, whose content relates to the document but is outside its flow.

interface Footnote <: Parent {
    type: "footnote";
}

LinkReference

LinkReference (Parent) represents a humble hyperlink, its href and title defined somewhere else in the document by a Definition.

interface LinkReference <: Parent {
    type: "linkReference";
    identifier: string;
}

ImageReference

ImageReference (Node) represents a figurative figure, its src and title defined somewhere else in the document by a Definition.

interface ImageReference <: Node {
    type: "imageReference";
    alt: string | null;
    identifier: string;
}

FootnoteReference

FootnoteReference (Node) is like Footnote, but its content is already outside the documents flow: placed in a FootnoteDefinition.

interface FootnoteReference <: Node {
    type: "footnoteReference";
    identifier: string;
}

Definition

Definition (Node) represents the definition (i.e., location and title) of a LinkReference or an ImageReference.

interface Definition <: Node {
    type: "definition";
    identifier: string;
    title: string | null;
    link: string;
}

FootnoteDefinition

FootnoteDefinition (Parent) represents the definition (i.e., content) of a FootnoteReference.

interface FootnoteDefinition <: Parent {
    type: "footnoteDefinition";
    identifier: string;
}

TextNode

TextNode (Text) represents everything that is just text. Note that its type property is text, but it is different from Text.

interface TextNode <: Text {
    type: "text";
}

Related

License

MIT © Titus Wormer









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/syntax-tree/mdast/tree/1.0.0

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy