Appearance
markdown-heading
Handles ATX-style headings from h1 through h6.
Details
| Property | Value |
|---|---|
| Name | markdown-heading |
| Priority | 100 |
| Type | Block |
| Factory | markdownHeading() |
What It Handles
ATX Headings
Lines starting with one to six # characters followed by a space:
markdown
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6Renders as <h1> through <h6>.
Closing Hashes
Optional trailing # characters are stripped:
markdown
# Heading 1 #
## Heading 2 ##
### Heading 3 ###########All render identically to their non-closing-hash versions.
Inline Formatting in Headings
Heading content supports inline formatting:
markdown
# This is **bold** heading
## Heading with `code` and *italic*The heading plugin produces a block token with the heading text as content. The core's inline parser then processes the content using the markdown-inline plugin.
API
ts
import { markdownHeading } from '@generative-dom/plugins';
const plugin = markdownHeading();No configuration options.
Edge Cases
#without a space after it is not a heading -- it is treated as a paragraph bymarkdown-base#######(seven or more hashes) is not a heading- A heading line can be preceded by up to three spaces of indentation
- Empty headings (
#) are valid and render as an empty heading element - Headings do not support setext style (underline with
===or---) -- Generative DOM only supports ATX style
Rendering
| Input | Output Element |
|---|---|
# text | <h1> |
## text | <h2> |
### text | <h3> |
#### text | <h4> |
##### text | <h5> |
###### text | <h6> |
Heading content is rendered as child text/inline nodes within the heading element.