@uniweb/semantic-parser 1.3.0 → 1.3.1
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/README.md +2 -2
- package/package.json +1 -1
- package/src/processors/groups.js +14 -9
package/README.md
CHANGED
|
@@ -162,7 +162,7 @@ When a group begins with headings, the parser reads one **headline stack** with
|
|
|
162
162
|
2. **One step smaller** — the next line of the headline: the subtitle first, then further subtitle lines (`subtitle` is a string for one line, an array for several — a three-line header like name / role / affiliation fits in one headline).
|
|
163
163
|
3. **Two or more steps smaller, or a step back up** — the stack ends; the rest of the run starts a new group (an item), read the same way.
|
|
164
164
|
|
|
165
|
-
Before the title, `#>` label lines (headings carrying `role: "pretitle"`) and smaller
|
|
165
|
+
Before the title, `#>` label lines (headings carrying `role: "pretitle"`) and every smaller heading stacked above the most important one — in whatever order — join the `pretitle`. A label line anywhere names the block it sits in; a label with no following heading labels an untitled block.
|
|
166
166
|
|
|
167
167
|
### Main content vs items
|
|
168
168
|
|
|
@@ -180,7 +180,7 @@ This is the mechanism that creates repeating content groups (cards, features, FA
|
|
|
180
180
|
Two spellings fill the `pretitle` slot:
|
|
181
181
|
|
|
182
182
|
- **A `#>` label line** — a heading with `role: "pretitle"`. It names the block that starts next, at any depth, with no level arithmetic; the hash count is carried for round-tripping and means nothing.
|
|
183
|
-
- **Position** — headings
|
|
183
|
+
- **Position** — smaller headings stacked above the most important heading of a run (H3 before H1, H6 before H5, …), in any order. `#### / ### / # Title` and `## / ### / # Title` both yield a two-line pretitle.
|
|
184
184
|
|
|
185
185
|
### Banner image
|
|
186
186
|
|
package/package.json
CHANGED
package/src/processors/groups.js
CHANGED
|
@@ -232,15 +232,20 @@ function readStack(sequence, startIdx, options = {}) {
|
|
|
232
232
|
i++;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
235
|
+
// Positional pretitle: the title is the FIRST occurrence of the run's most
|
|
236
|
+
// important level; every smaller heading stacked above it joins the
|
|
237
|
+
// pretitle, in whatever order they were written (#### / ### / # and
|
|
238
|
+
// ## / ### / # both give a two-line pretitle). An ascending-only walk
|
|
239
|
+
// read a descending stack as a bodiless headline followed by a bigger
|
|
240
|
+
// heading, which demoted the real title into the items.
|
|
241
|
+
let best = i;
|
|
242
|
+
for (let k = i; k < sequence.length; k++) {
|
|
243
|
+
const el = sequence[k];
|
|
244
|
+
if (el.type !== "heading") break;
|
|
245
|
+
if (isLabel(el)) continue;
|
|
246
|
+
if (el.level < sequence[best].level || isLabel(sequence[best])) best = k;
|
|
247
|
+
}
|
|
248
|
+
while (i < best) {
|
|
244
249
|
pre.push(sequence[i]);
|
|
245
250
|
i++;
|
|
246
251
|
}
|