wyreframe 0.7.4 → 0.7.6
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/package.json
CHANGED
|
@@ -153,17 +153,30 @@ function traceBox(grid, topLeft) {
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
let nextRow = topLeft.row + 1 | 0;
|
|
156
|
+
let prevRow = topLeft.row - 1 | 0;
|
|
157
|
+
let isMiddleDivider;
|
|
158
|
+
if (prevRow >= 0) {
|
|
159
|
+
let prevLeftPos = Types.Position.make(prevRow, topLeft.col);
|
|
160
|
+
let prevRightPos = Types.Position.make(prevRow, topRightOpt.col);
|
|
161
|
+
let leftChar = Grid.get(grid, prevLeftPos);
|
|
162
|
+
let rightChar = Grid.get(grid, prevRightPos);
|
|
163
|
+
isMiddleDivider = leftChar === "VLine" && typeof leftChar !== "object" ? rightChar === "VLine" && typeof rightChar !== "object" : false;
|
|
164
|
+
} else {
|
|
165
|
+
isMiddleDivider = false;
|
|
166
|
+
}
|
|
156
167
|
let isValidTopEdge;
|
|
157
|
-
if (nextRow
|
|
168
|
+
if (isMiddleDivider || nextRow >= grid.height) {
|
|
169
|
+
isValidTopEdge = false;
|
|
170
|
+
} else {
|
|
158
171
|
let nextLeftPos = Types.Position.make(nextRow, topLeft.col);
|
|
159
172
|
let nextRightPos = Types.Position.make(nextRow, topRightOpt.col);
|
|
160
|
-
let leftChar = Grid.get(grid, nextLeftPos);
|
|
161
|
-
let rightChar = Grid.get(grid, nextRightPos);
|
|
162
|
-
if (leftChar !== undefined && typeof leftChar !== "object") {
|
|
163
|
-
switch (leftChar) {
|
|
173
|
+
let leftChar$1 = Grid.get(grid, nextLeftPos);
|
|
174
|
+
let rightChar$1 = Grid.get(grid, nextRightPos);
|
|
175
|
+
if (leftChar$1 !== undefined && typeof leftChar$1 !== "object") {
|
|
176
|
+
switch (leftChar$1) {
|
|
164
177
|
case "Corner" :
|
|
165
|
-
if (rightChar !== undefined && typeof rightChar !== "object") {
|
|
166
|
-
switch (rightChar) {
|
|
178
|
+
if (rightChar$1 !== undefined && typeof rightChar$1 !== "object") {
|
|
179
|
+
switch (rightChar$1) {
|
|
167
180
|
case "Corner" :
|
|
168
181
|
isValidTopEdge = false;
|
|
169
182
|
break;
|
|
@@ -175,8 +188,8 @@ function traceBox(grid, topLeft) {
|
|
|
175
188
|
}
|
|
176
189
|
break;
|
|
177
190
|
case "VLine" :
|
|
178
|
-
if (rightChar !== undefined && typeof rightChar !== "object") {
|
|
179
|
-
switch (rightChar) {
|
|
191
|
+
if (rightChar$1 !== undefined && typeof rightChar$1 !== "object") {
|
|
192
|
+
switch (rightChar$1) {
|
|
180
193
|
default:
|
|
181
194
|
isValidTopEdge = true;
|
|
182
195
|
}
|
|
@@ -190,8 +203,6 @@ function traceBox(grid, topLeft) {
|
|
|
190
203
|
} else {
|
|
191
204
|
isValidTopEdge = true;
|
|
192
205
|
}
|
|
193
|
-
} else {
|
|
194
|
-
isValidTopEdge = false;
|
|
195
206
|
}
|
|
196
207
|
if (!isValidTopEdge) {
|
|
197
208
|
return {
|
|
@@ -237,8 +237,38 @@ let traceBox = (grid: Grid.t, topLeft: Position.t): traceResult => {
|
|
|
237
237
|
// in the next row at the left and right columns, NOT Corner characters (+).
|
|
238
238
|
// If the next row has corners at both positions, this is likely the
|
|
239
239
|
// bottom edge of one box immediately followed by the top edge of another.
|
|
240
|
+
//
|
|
241
|
+
// Issue #20 fix: Also check if this corner is a MIDDLE divider of a table.
|
|
242
|
+
// A middle divider has VLine characters in the PREVIOUS row at both corners.
|
|
243
|
+
// Example table structure:
|
|
244
|
+
// +-----------+-----------+ <- Row 3: Top edge (valid)
|
|
245
|
+
// | Header1 | Header2 | <- Row 4: Content row
|
|
246
|
+
// +-----------+-----------+ <- Row 5: Middle divider (INVALID as top edge)
|
|
247
|
+
// | Cell 1 | Cell 2 | <- Row 6: Content row
|
|
248
|
+
// +-----------+-----------+ <- Row 7: Bottom edge
|
|
249
|
+
// Row 5 has VLines in both previous (row 4) AND next (row 6) rows,
|
|
250
|
+
// so it's a middle divider, not a valid top edge.
|
|
240
251
|
let nextRow = topLeft.row + 1
|
|
241
|
-
let
|
|
252
|
+
let prevRow = topLeft.row - 1
|
|
253
|
+
|
|
254
|
+
// Check if previous row has VLines at both corners (indicates middle divider)
|
|
255
|
+
let isMiddleDivider = if prevRow >= 0 {
|
|
256
|
+
let prevLeftPos = Position.make(prevRow, topLeft.col)
|
|
257
|
+
let prevRightPos = Position.make(prevRow, topRight.col)
|
|
258
|
+
let leftChar = Grid.get(grid, prevLeftPos)
|
|
259
|
+
let rightChar = Grid.get(grid, prevRightPos)
|
|
260
|
+
// If previous row has VLine at BOTH positions, this is a middle divider
|
|
261
|
+
switch (leftChar, rightChar) {
|
|
262
|
+
| (Some(VLine), Some(VLine)) => true // Previous row has content = middle divider
|
|
263
|
+
| _ => false
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
false // No previous row = could be valid top edge
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
let isValidTopEdge = if isMiddleDivider {
|
|
270
|
+
false // Middle dividers are not valid top edges
|
|
271
|
+
} else if nextRow < grid.height {
|
|
242
272
|
let nextLeftPos = Position.make(nextRow, topLeft.col)
|
|
243
273
|
let nextRightPos = Position.make(nextRow, topRight.col)
|
|
244
274
|
let leftChar = Grid.get(grid, nextLeftPos)
|
|
@@ -642,6 +642,17 @@ function parseContentLine(line, lineIndex, contentStartRow, box, registry) {
|
|
|
642
642
|
if (trimmed === "") {
|
|
643
643
|
let row = contentStartRow + lineIndex | 0;
|
|
644
644
|
let baseCol = box.bounds.left + 1 | 0;
|
|
645
|
+
let rowWithinChildBox = box.children.some(child => {
|
|
646
|
+
let b = child.bounds;
|
|
647
|
+
if (row >= b.top) {
|
|
648
|
+
return row <= b.bottom;
|
|
649
|
+
} else {
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
if (rowWithinChildBox) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
645
656
|
let position = Types.Position.make(row, baseCol);
|
|
646
657
|
return {
|
|
647
658
|
TAG: "Spacer",
|
|
@@ -1083,11 +1083,25 @@ let parseContentLine = (
|
|
|
1083
1083
|
let trimmed = line->String.trim
|
|
1084
1084
|
|
|
1085
1085
|
// Issue #16: Preserve empty lines as Spacer elements for vertical spacing
|
|
1086
|
+
// Issue #19: But don't create Spacers for rows that are within child box bounds
|
|
1086
1087
|
if trimmed === "" {
|
|
1087
1088
|
let row = contentStartRow + lineIndex
|
|
1088
1089
|
let baseCol = box.bounds.left + 1
|
|
1089
|
-
|
|
1090
|
-
|
|
1090
|
+
|
|
1091
|
+
// Check if this row is within any child box's vertical bounds
|
|
1092
|
+
// If so, skip creating a Spacer (Issue #19: incorrect spacer count)
|
|
1093
|
+
let rowWithinChildBox = box.children->Array.some(child => {
|
|
1094
|
+
let b = child.bounds
|
|
1095
|
+
row >= b.top && row <= b.bottom
|
|
1096
|
+
})
|
|
1097
|
+
|
|
1098
|
+
if rowWithinChildBox {
|
|
1099
|
+
// Skip spacer for rows occupied by child boxes
|
|
1100
|
+
None
|
|
1101
|
+
} else {
|
|
1102
|
+
let position = Position.make(row, baseCol)
|
|
1103
|
+
Some(Spacer({position: position}))
|
|
1104
|
+
}
|
|
1091
1105
|
} else if isNoiseText(trimmed) {
|
|
1092
1106
|
// Filter out border/noise text - don't create any element
|
|
1093
1107
|
None
|