Class: RedQuilt::Renderer::Mdast

Inherits:
Object
  • Object
show all
Defined in:
lib/red_quilt/renderer/mdast.rb

Overview

Builds an MDAST-compatible Hash from the document arena.

MDAST (github.com/syntax-tree/mdast) is the unified.js AST format for Markdown; emitting it lets external tooling (linters, editor plugins) consume red_quilt output without bespoke adapters.

Constant Summary collapse

MDAST_TYPE_NAMES =
{
  document: "root",
  paragraph: "paragraph",
  heading: "heading",
  thematic_break: "thematicBreak",
  blockquote: "blockquote",
  list: "list",
  list_item: "listItem",
  code_block: "code",
  html_block: "html",
  table: "table",
  table_row: "tableRow",
  table_cell: "tableCell",
  text: "text",
  softbreak: "break",
  hardbreak: "break",
  emphasis: "emphasis",
  strong: "strong",
  code_span: "inlineCode",
  link: "link",
  image: "image",
  html_inline: "html",
  strikethrough: "delete",
  footnote_reference: "footnoteReference",
  footnote_definition: "footnoteDefinition",
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ Mdast

Returns a new instance of Mdast.



38
39
40
41
# File 'lib/red_quilt/renderer/mdast.rb', line 38

def initialize(document)
  @document = document
  @arena = document.arena
end

Instance Method Details

#renderObject



43
44
45
# File 'lib/red_quilt/renderer/mdast.rb', line 43

def render
  node(@document.root_id)
end