jmd-format 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/parser.js +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmd-format",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "JMD (JSON Markdown) — structured data format for LLM-driven infrastructure. JavaScript reference implementation.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/parser.js CHANGED
@@ -155,11 +155,15 @@ export function createParser() {
155
155
 
156
156
  function onThematicBreak() {
157
157
  blankPending = false
158
- // A thematic break is consumed by the innermost enclosing array whose
159
- // most-recent item is a dict containing nested structures this is
160
- // the only context where jmd-format emits the break, and the parser
161
- // mirrors that rule (spec §8.6). Inner scopes are closed; if no array
162
- // on the stack qualifies, the line is tolerated as decoration.
158
+ // A thematic break closes any sub-scope opened by the most-recent
159
+ // item, then signals the next item of the enclosing array (spec §8.6).
160
+ // We search outward for the innermost array whose last item opened a
161
+ // sub-structure and close down to it. If none qualifies, the break is
162
+ // a no-op and that is correct, not lossy: a flat item opens no
163
+ // sub-scope, so the enclosing array is still current and the next
164
+ // `- ` item continues it. This is why a `---` after a flat item in a
165
+ // mixed array (canonical per the v0.3.4 §8.6 clarification) parses
166
+ // without dropping the following item.
163
167
  let targetIdx = -1
164
168
  for (let i = stack.length - 1; i >= 0; i--) {
165
169
  const s = stack[i]