@uniweb/semantic-parser 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/processors/groups.js +5 -3
package/AGENTS.md
CHANGED
|
@@ -167,7 +167,7 @@ Key patterns:
|
|
|
167
167
|
- **Pretitle Pattern**: Any heading followed by a more important heading (e.g., H3→H1, H2→H1, H6→H5, etc.)
|
|
168
168
|
- **Banner Pattern**: Image (with banner role or followed by heading) at start of first group
|
|
169
169
|
- **Divider Mode**: Presence of any `horizontalRule` switches entire document to divider-based grouping
|
|
170
|
-
- **Heading Groups**: Consecutive headings
|
|
170
|
+
- **Heading Groups**: Consecutive headings are consumed together only when each is exactly one level deeper (H1→H2 yes, H1→H3 no — skipped levels start a new group)
|
|
171
171
|
- **Main Content**: First group is main if it's the only group OR has lower heading level than second group
|
|
172
172
|
- **Body Headings**: Headings after the title and subtitle slots are collected in `body.headings` in document order
|
|
173
173
|
|
package/README.md
CHANGED
|
@@ -153,6 +153,8 @@ Groups are created based on heading patterns. A new group starts when:
|
|
|
153
153
|
- Multiple H1s appear (no main content created)
|
|
154
154
|
- The heading level indicates a new section
|
|
155
155
|
|
|
156
|
+
**Heading group formation:** Consecutive headings are consumed as a single semantic unit only when each subsequent heading is _exactly one level deeper_ than the previous (e.g., H1→H2→H3). Skipping levels (H1→H3) breaks the group — the deeper heading starts a new group instead of becoming a subtitle. This reflects natural document structure: a large level gap signals items, not a title-subtitle pair.
|
|
157
|
+
|
|
156
158
|
**Pretitle Detection:** Any heading followed by a more important heading is automatically detected as a pretitle:
|
|
157
159
|
- H3 before H1 → pretitle ✅
|
|
158
160
|
- H2 before H1 → pretitle ✅
|
package/package.json
CHANGED
package/src/processors/groups.js
CHANGED
|
@@ -183,9 +183,11 @@ function readHeadingGroup(sequence, startIdx) {
|
|
|
183
183
|
break;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
// Case 1:
|
|
187
|
-
//
|
|
188
|
-
|
|
186
|
+
// Case 1: Adjacent Deeper (Standard Subtitle/Deep Header)
|
|
187
|
+
// Only group headings that are exactly one level apart.
|
|
188
|
+
// e.g. H1 -> H2 groups, but H1 -> H3 does not (skipped level
|
|
189
|
+
// signals a structural tier change, not a title-subtitle pair).
|
|
190
|
+
if (element.level - previousElement.level === 1) {
|
|
189
191
|
hasGoneDeeper = true;
|
|
190
192
|
elements.push(element);
|
|
191
193
|
continue;
|