wyreframe 0.7.5 → 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)
|