Skip to content

markdown-base

The fallback plugin that handles paragraphs, line breaks, escaping, and horizontal rules. Anything not matched by a higher-priority plugin is handled here.

Details

PropertyValue
Namemarkdown-base
Priority300
TypeBlock + Inline
FactorymarkdownBase()

What It Handles

Paragraphs

Consecutive non-empty lines are wrapped in <p> elements. Blank lines separate paragraphs.

markdown
First paragraph.

Second paragraph.

Renders as:

html
<p>First paragraph.</p>
<p>Second paragraph.</p>

Line Breaks

Two trailing spaces or a backslash before a newline produce a <br>:

markdown
Line one
Line two

Line three\
Line four

Escaping

A backslash before any ASCII punctuation character renders the character literally:

markdown
\*not bold\*
\# not a heading
\[not a link\]

Supported escape characters: \, `, *, _, {, }, [, ], (, ), #, +, -, ., !, |, ~

Horizontal Rules

Three or more hyphens, asterisks, or underscores (with optional spaces) on a line by themselves:

markdown
---
***
___
- - -

All render as <hr>.

Blank Line Handling

Blank lines separate block-level elements. Multiple consecutive blank lines are treated as a single separator.

API

ts
import { markdownBase } from '@generative-dom/plugins';

const plugin = markdownBase();

No configuration options. This plugin always acts as the fallback.

Edge Cases

  • A line with only spaces is treated as a blank line
  • Trailing spaces at the end of a paragraph (fewer than two) are not significant
  • Escaped characters inside other syntax (e.g., \* inside a heading) are handled by this plugin's inline matcher
  • Horizontal rules require the line to contain only the rule characters and optional spaces -- any other content makes it a paragraph
  • A line of --- after a paragraph without a blank line could be ambiguous with setext headings; Generative DOM treats it as a horizontal rule since setext headings are not supported

Rendering

InputOutput Element
Paragraph text<p>
Line break<br>
Horizontal rule<hr>
Escaped characterText node