@json-to-office/jto-ops 7.0.1 → 7.1.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/dist/index.js CHANGED
@@ -2283,10 +2283,26 @@ function linedOrder(words2, lines = []) {
2283
2283
  };
2284
2284
  }
2285
2285
  function rotatedWords(words2, lines) {
2286
+ const upright = words2.filter(
2287
+ (w) => w.text.trim() !== "" && w.xMax - w.xMin >= w.yMax - w.yMin
2288
+ );
2289
+ const standsInALine = (w) => {
2290
+ const height = w.yMax - w.yMin;
2291
+ return upright.some((other) => {
2292
+ if (other === w) return false;
2293
+ const overlap = Math.min(w.yMax, other.yMax) - Math.max(w.yMin, other.yMin);
2294
+ const shorter = Math.min(height, other.yMax - other.yMin);
2295
+ if (shorter <= 0 || overlap <= shorter / 2) return false;
2296
+ const ratio = height / (other.yMax - other.yMin);
2297
+ return ratio > 0.8 && ratio < 1.25;
2298
+ });
2299
+ };
2286
2300
  const rotated = new Set(
2287
2301
  words2.map((_, i) => i).filter((i) => {
2288
2302
  const w = words2[i];
2289
- return w.text.length > 2 && w.yMax - w.yMin > 1.5 * (w.xMax - w.xMin);
2303
+ if (w.text.length <= 2) return false;
2304
+ if (w.yMax - w.yMin <= 1.5 * (w.xMax - w.xMin)) return false;
2305
+ return !standsInALine(w);
2290
2306
  })
2291
2307
  );
2292
2308
  for (const line of lines) {