You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,6 @@ All notable changes to this project will be documented in this file. See [Conven
6
6
7
7
### ✨ Features
8
8
9
-
*initial commit of markdown-it-anchor-sections ([21ce354]())
9
+
\*initial commit of markdown-it-anchor-sections ([21ce354](https://github.com/castastrophe/markdown-it-anchor-sections/commit/21ce354d8a66bba7741de34d8b4331c243bc6487))
10
10
11
-
A markdown-it plugin for wrapping headers + content in a section tag
12
-
with unique identifier. Compatible with IntersectionObservers.
11
+
A markdown-it plugin for wrapping markdown content in `<section>` tags automatically, grouped by header level, and hoisting or creating an anchor tag on the section; perfect for Intersection Observers, scroll-spying, or semantic styling without manual markup.
<b>Markdown headers wrapped in logical sections.</b>
3
+
<b>Markdown headers wrapped in semantic sections with anchor tags.</b>
4
4
</p>
5
5
6
6
<divalign="center">
@@ -11,39 +11,41 @@
11
11
12
12
</div>
13
13
14
-
Wrap markdown content in `<section>` tags automatically, grouped by header level. Perfect for Intersection Observers, scroll-spying, or semantic styling without manual markup.
14
+
Wrap markdown content in `<section>` tags automatically, grouped by header level, and hoisting or creating an anchor tag on the section; perfect for Intersection Observers, scroll-spying, or semantic styling without manual markup.
15
15
16
16
```md
17
17
# Introduction
18
+
18
19
Hello world.
19
20
20
21
## Details
22
+
21
23
More info here.
22
24
```
23
25
24
26
renders to:
25
27
26
28
```html
27
-
<section>
28
-
<h1>Introduction</h1>
29
-
<p>Hello world.</p>
30
-
<section>
31
-
<h2>Details</h2>
32
-
<p>More info here.</p>
33
-
</section>
29
+
<sectionid="introduction">
30
+
<h1>Introduction</h1>
31
+
<p>Hello world.</p>
32
+
<sectionid="details">
33
+
<h2>Details</h2>
34
+
<p>More info here.</p>
35
+
</section>
34
36
</section>
35
37
```
36
38
37
39
## The problem
38
40
39
-
Modern web layouts often require grouping content into logical blocks—for example, to trigger animations as sections enter the viewport, or to build sticky navigation that knows which part of the page you're reading.
41
+
Modern web layouts often require grouping content into logical blocks—for example, to trigger animations as sections enter the viewport or to build sticky navigation that knows which part of the page you're reading.
40
42
41
43
Markdown is inherently flat. While you can manually wrap blocks in `<div>` or `<section>` tags, it breaks the readability of the raw text and is prone to errors. **markdown-it-anchor-sections bridges the gap** by treating your header hierarchy as the source of truth for your document's structure.
42
44
43
45
## Features
44
46
45
-
-**Hierarchical nesting** — lower-level headers (like `h2`) are automatically nested within higher-level sections (like `h1`)
46
-
-**Attribute-aware** — works seamlessly with `markdown-it-attrs`or `markdown-it-anchor`; sections inherit the same IDs and classes as their headers
47
+
-**Hierarchical nesting** — lower-level headers (like `h3`) are automatically nested within higher-level sections (like `h2`)
48
+
-**Attribute-aware** — works seamlessly with `markdown-it-attrs` sections inherit the same IDs as their headers
47
49
-**Semantic HTML** — produces clean, valid `<section>` structures that reflect your content's outline
48
50
-**Zero configuration** — works out of the box with sensible defaults
49
51
-**Lightweight** — tiny footprint with no external dependencies
@@ -62,8 +64,8 @@ bun add markdown-it-anchor-sections
If you use [markdown-it-attrs]or [markdown-it-anchor]before this plugin, the generated `<section>` tags will inherit any attributes applied to the headers:
85
+
If you use [markdown-it-attrs] before this plugin, the generated `<section>` tags will inherit the id applied to the headers and retain any other attributes on the header.
0 commit comments