Extension inline rules

Inline extension rules for GFM, formatting, math, spoilers, ruby, and directives.


Strikethrough

Strikethrough parses single- or double-tilde deletion spans.

~~delete~~

Output node is Delete, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "delete",
          "children": [
            {
              "type": "text",
              "value": "delete"
            }
          ]
        }
      ]
    }
  ]
}

Mark

Mark parses highlighted text delimited by ==.

==marked==

Output node is Mark, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "mark",
          "children": [
            {
              "type": "text",
              "value": "marked"
            }
          ]
        }
      ]
    }
  ]
}

Insert

Insert parses inserted text delimited by ^^.

^^inserted^^

Output node is Insert, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "insert",
          "children": [
            {
              "type": "text",
              "value": "inserted"
            }
          ]
        }
      ]
    }
  ]
}

Superscript

Superscript parses caret-delimited superscript spans.

2^10^

Output node is Superscript, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "text",
          "value": "2"
        },
        {
          "type": "superscript",
          "children": [
            {
              "type": "text",
              "value": "10"
            }
          ]
        }
      ]
    }
  ]
}

Subscript

Subscript parses tilde-delimited subscript spans.

H~2~O

Output node is Subscript, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "text",
          "value": "H"
        },
        {
          "type": "subscript",
          "children": [
            {
              "type": "text",
              "value": "2"
            }
          ]
        },
        {
          "type": "text",
          "value": "O"
        }
      ]
    }
  ]
}

Ruby

Ruby parses ruby annotation syntax.

[漢字(kanji)]

Output node is Ruby, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "ruby",
          "segments": [
            {
              "base": "漢字",
              "text": "kanji"
            }
          ]
        }
      ]
    }
  ]
}

InlineSpoiler

InlineSpoiler parses spoiler spans delimited by >! and !<.

>! secret !<

Output node is InlineSpoiler, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "inlineSpoiler",
          "children": [
            {
              "type": "text",
              "value": "secret"
            }
          ]
        }
      ]
    }
  ]
}

InlineMath

InlineMath parses inline math delimited by $.

$x + y$

Output node is InlineMath, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "inlineMath",
          "value": "x + y"
        }
      ]
    }
  ]
}

TextDirective

TextDirective parses inline directives such as :name[label]{attrs}.

:abbr[*HTML*]{title="HyperText Markup Language"}

Output node is TextDirective, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "textDirective",
          "children": [
            {
              "type": "emphasis",
              "children": [
                {
                  "type": "text",
                  "value": "HTML"
                }
              ]
            }
          ],
          "name": "abbr",
          "attributes": {
            "title": "HyperText Markup Language"
          }
        }
      ]
    }
  ]
}

Role

Role parses MyST-style inline roles.

{abbr}`HTML`

Output node is TextDirective, and its AST is:

{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        {
          "type": "textDirective",
          "children": [
            {
              "type": "text",
              "value": "HTML"
            }
          ],
          "name": "abbr"
        }
      ]
    }
  ]
}