@bettercms-ai/convert 0.17.1 → 0.17.2

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.d.ts CHANGED
@@ -1293,10 +1293,11 @@ declare function isSourceCandidate(path: string): boolean;
1293
1293
  * could lift — and the target is a number someone has to be able to reach. They are not copy an
1294
1294
  * author edits, so they are not copy this measures.
1295
1295
  *
1296
- * - a decorative glyph: two characters or fewer, a single non-letter symbol, or an ordinal
1297
- * (`01`, `2.`, `3 /`) that numbers a list rather than saying anything;
1296
+ * - a decorative glyph: no letter and no digit (`✓`, `→`), or an ordinal (`01`, `2.`, `3 /`)
1297
+ * that numbers a list rather than saying anything. Length decides nothing: `OK` and `$1,200`
1298
+ * are copy. The server's `extract-fields.ts` isDecorativeGlyph, verbatim;
1298
1299
  * - the platform badge every free site renders;
1299
- * - a skip link, which exists for keyboards and is never edited.
1300
+ * - a skip link, which exists for keyboards and is never edited. @see isSkipLink
1300
1301
  */
1301
1302
  declare const isDecorativeGlyph: (text: string) => boolean;
1302
1303
  interface XrayBucket {
package/dist/index.js CHANGED
@@ -6811,7 +6811,7 @@ function isSourceCandidate(path) {
6811
6811
  }
6812
6812
 
6813
6813
  // src/xray.ts
6814
- var SKIP_TAGS = /* @__PURE__ */ new Set(["svg", "iframe", "head", "title"]);
6814
+ var SKIP_TAGS = /* @__PURE__ */ new Set(["svg", "math", "iframe", "head", "title", "object", "canvas", "select"]);
6815
6815
  var CONTEXT_TAGS = /* @__PURE__ */ new Set([
6816
6816
  "nav",
6817
6817
  "header",
@@ -6829,10 +6829,16 @@ var CONTEXT_TAGS = /* @__PURE__ */ new Set([
6829
6829
  "figure",
6830
6830
  "blockquote"
6831
6831
  ]);
6832
- var BOUND_ATTRS = ["data-bcms-field", "data-bcms-layout-field", "data-bcms-path", "data-bcms-block"];
6833
- var isDecorativeGlyph = (text) => text.length <= 2 || /^\d{1,2}\s*[/.)\-–]?$/.test(text) || !new RegExp("\\p{L}", "u").test(text) || /^made with\b/i.test(text) || /^skip to\b/i.test(text);
6832
+ var BOUND_ATTRS = ["data-bcms-field", "data-bcms-layout-field"];
6833
+ var isDecorativeGlyph = (text) => {
6834
+ const t = flat2(text);
6835
+ return t === "" || !/[\p{L}\p{N}]/u.test(t) || new RegExp("^\\p{Nd}{1,2}\\s*[/.)\\-\u2013\u2014]?$", "u").test(t);
6836
+ };
6837
+ var PLATFORM_BADGE = /^made with\b/iu;
6834
6838
  var MAX_BUCKETS = 12;
6835
6839
  var flat2 = (value) => value.replace(/\s+/g, " ").trim();
6840
+ var textOf = (node) => node.type === "text" ? node.value : node.type === "element" ? node.children.map(textOf).join("") : "";
6841
+ var isSkipLink = (node, attrs) => node.tag === "a" && (attrs.get("href") ?? "").startsWith("#") && (/^skip\b/iu.test(flat2(textOf(node))) || /\bskip[-_]?(link|nav|to|content)\b/iu.test(attrs.get("class") ?? ""));
6836
6842
  function measureUnaddressable(html) {
6837
6843
  const parsed = parse2(html);
6838
6844
  let visible = 0;
@@ -6841,7 +6847,7 @@ function measureUnaddressable(html) {
6841
6847
  const visit = (node, tag, context, bound) => {
6842
6848
  if (node.type === "text") {
6843
6849
  const text = flat2(node.value);
6844
- if (!text || isDecorativeGlyph(text)) return;
6850
+ if (isDecorativeGlyph(text) || PLATFORM_BADGE.test(text)) return;
6845
6851
  visible += text.length;
6846
6852
  if (bound) return;
6847
6853
  unaddressable += text.length;
@@ -6855,7 +6861,7 @@ function measureUnaddressable(html) {
6855
6861
  }
6856
6862
  if (node.type !== "element" || node.raw || SKIP_TAGS.has(node.tag)) return;
6857
6863
  const attrs = new Map(node.attrs.map((a) => [a.name, a.value]));
6858
- if (attrs.has("hidden") || attrs.get("aria-hidden") === "true" || /display\s*:\s*none/.test(attrs.get("style") ?? "")) {
6864
+ if (attrs.has("hidden") || attrs.get("aria-hidden") === "true" || /display\s*:\s*none/i.test(attrs.get("style") ?? "") || isSkipLink(node, attrs)) {
6859
6865
  return;
6860
6866
  }
6861
6867
  const owned = bound || BOUND_ATTRS.some((name) => attrs.has(name));
@@ -6866,7 +6872,7 @@ function measureUnaddressable(html) {
6866
6872
  return {
6867
6873
  visible,
6868
6874
  unaddressable,
6869
- buckets: [...buckets.values()].sort((a, b) => b.chars - a.chars).slice(0, MAX_BUCKETS)
6875
+ buckets: [...buckets.values()].sort((a, b) => b.chars - a.chars || `${a.tag} @ ${a.context}`.localeCompare(`${b.tag} @ ${b.context}`)).slice(0, MAX_BUCKETS)
6870
6876
  };
6871
6877
  }
6872
6878