Skip to content

markdown-list

Handles ordered and unordered lists, including nested lists and inline formatting within list items.

Details

PropertyValue
Namemarkdown-list
Priority100
TypeBlock
FactorymarkdownList()

What It Handles

Unordered Lists

Lines starting with -, *, or + followed by a space:

markdown
- Item one
- Item two
- Item three

Renders as:

html
<ul>
  <li>Item one</li>
  <li>Item two</li>
  <li>Item three</li>
</ul>

Ordered Lists

Lines starting with a number followed by . or ) and a space:

markdown
1. First item
2. Second item
3. Third item

Renders as:

html
<ol>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ol>

Nested Lists

Indentation (2 or 4 spaces, or 1 tab) creates nested lists:

markdown
- Outer item
  - Inner item
    - Deep item
- Another outer item

Renders as nested <ul> or <ol> elements.

Mixed Lists

Ordered and unordered lists can be nested within each other:

markdown
1. First
   - Sub-bullet A
   - Sub-bullet B
2. Second

Inline Formatting

List items support inline formatting:

markdown
- This is **bold** in a list
- This has `inline code`
- A [link](https://example.com) in a list

Loose vs. Tight Lists

Blank lines between items create a "loose" list where items are wrapped in <p>:

markdown
- Item one

- Item two

- Item three

Renders as:

html
<ul>
  <li><p>Item one</p></li>
  <li><p>Item two</p></li>
  <li><p>Item three</p></li>
</ul>

Without blank lines (tight list), items contain inline content directly.

API

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

const plugin = markdownList();

No configuration options.

Edge Cases

  • The starting number of an ordered list is respected: 3. Item starts the list at 3
  • Any number works as a list marker: 1., 99., 0. are all valid
  • A list item can span multiple lines if continuation lines are indented
  • Empty list items (- with nothing after) are valid
  • Lists adjacent to other block elements (headings, code blocks) need a blank line separator
  • Very deep nesting (10+ levels) works but may require careful indentation

Rendering

InputOutput Elements
- item<ul><li>
1. item<ol><li>
Nested itemsNested <ul> / <ol> within <li>
Loose items<li><p>