@emailens/cli 0.13.13 → 0.13.14

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.
@@ -63611,6 +63611,17 @@ function blankLabelsAfterNestedShape(html3) {
63611
63611
  );
63612
63612
  return html3.slice(0, at2) + tail;
63613
63613
  }
63614
+ var LINK_LINE_BLOCKS = /* @__PURE__ */ new Set(["div", "p", "table", "ul", "ol", "h1", "h2", "h3", "h4", "h5", "h6", "center", "blockquote", "hr"]);
63615
+ var INLINE_TAGS = /* @__PURE__ */ new Set(["span", "a", "b", "strong", "i", "em", "u", "font", "small", "big", "sub", "sup"]);
63616
+ var WORD_PARSED = /^(?:mso-.*|font(?:-(?:family|size|weight|style|variant))?|color|background(?:-color)?|line-height|letter-spacing|white-space|word-wrap|text-(?:align|decoration|transform|indent|shadow)|vertical-align|direction|unicode-bidi|width|height|(?:margin|padding)(?:-(?:top|right|bottom|left))?|border(?:-(?:top|right|bottom|left))?(?:-(?:color|style|width))?)$/;
63617
+ var WORD_PARSED_VALUES = { "word-break": /^normal$/i, display: /^(?:inline|none)$/i };
63618
+ function wordParsesAll(props) {
63619
+ for (const [name, value] of props) {
63620
+ const values = WORD_PARSED_VALUES[name];
63621
+ if (values ? !values.test(value.replace(/\s*!important$/i, "").trim()) : !WORD_PARSED.test(name)) return false;
63622
+ }
63623
+ return true;
63624
+ }
63614
63625
  var PADDING = ["padding", "padding-top", "padding-right", "padding-bottom", "padding-left"];
63615
63626
  var MARGIN = ["margin", "margin-top", "margin-right", "margin-bottom", "margin-left"];
63616
63627
  var BORDER_WIDTH = [
@@ -63628,8 +63639,10 @@ var BORDER_WIDTH = [
63628
63639
  var NATURAL_LINE = 1.15;
63629
63640
  var GILL_VDMX = [14, 14, 15, 16, 18, 18, 21, 21, 23, 25, 27, 27, 29, 30, 31];
63630
63641
  var isGill = (family = "") => /^\s*['"]?gill sans/i.test(family);
63642
+ var FACE_LINE = [[/^\s*['"]?arial black\b/i, 1.41]];
63631
63643
  var naturalHeight = (size, family = "") => {
63632
- if (!isGill(family)) return Math.round(size * NATURAL_LINE);
63644
+ var _a22, _b;
63645
+ if (!isGill(family)) return Math.round(size * ((_b = (_a22 = FACE_LINE.find(([face]) => face.test(family))) == null ? void 0 : _a22[1]) != null ? _b : NATURAL_LINE));
63633
63646
  const ppem = Math.round(size);
63634
63647
  return ppem <= 22 ? GILL_VDMX[Math.max(ppem, 8) - 8] : Math.ceil(0.9292 * size) + Math.ceil(0.2305 * size);
63635
63648
  };
@@ -63794,8 +63807,14 @@ function markHiddenCells(html3) {
63794
63807
  );
63795
63808
  }
63796
63809
  function prepareWordSource(html3) {
63797
- return wordSubstitutes(markHiddenCells(dropWordUnknownColors(html3)));
63810
+ return markUnparsedInlines(wordSubstitutes(markHiddenCells(dropWordUnknownColors(html3))));
63798
63811
  }
63812
+ var UNPARSED_MARK = "data-word-unparsed";
63813
+ var INLINE_STYLE = new RegExp(String.raw`<(${[...INLINE_TAGS].join("|")})(?=\s)(?=[^>]*?\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'))`, "gi");
63814
+ var markUnparsedInlines = (html3) => html3.replace(INLINE_STYLE, (open, _tag, dq, sq) => {
63815
+ var _a22;
63816
+ return wordParsesAll(parseInlineStyle((_a22 = dq != null ? dq : sq) != null ? _a22 : "")) ? open : `${open} ${UNPARSED_MARK}`;
63817
+ });
63799
63818
  var WORD_SUBSTITUTES = { rubik: "Calibri" };
63800
63819
  var SUBSTITUTED = new RegExp(String.raw`(font(?:-family)?\s*:[^;"}]*?)(['"]?)\b(${Object.keys(WORD_SUBSTITUTES).join("|")})\b\2`, "gi");
63801
63820
  var wordSubstitutes = (html3) => html3.replace(SUBSTITUTED, (_3, lead, _q, name) => `${lead}${WORD_SUBSTITUTES[name.toLowerCase()]}`);
@@ -64009,9 +64028,18 @@ function applyWordBoxModel($3) {
64009
64028
  ]);
64010
64029
  $3(node).attr("style", serializeStyle(set));
64011
64030
  });
64031
+ const blank = (n2) => n2.type === "comment" || n2.type === "text" && !n2.data.trim();
64012
64032
  $3("a").each((_3, node) => {
64013
64033
  if (!$3(node).children("div, p").length) return;
64014
- $3(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
64034
+ let before2 = node.prev;
64035
+ while (before2 && blank(before2)) before2 = before2.prev;
64036
+ let after2 = node.next;
64037
+ while (after2 && blank(after2)) after2 = after2.next;
64038
+ const parent2 = node.parent;
64039
+ const endsCell = !after2 && (parent2 == null ? void 0 : parent2.type) === "tag" && /^t[dh]$/.test(parent2.name);
64040
+ if (!before2 || before2.type === "tag" && LINK_LINE_BLOCKS.has(before2.name))
64041
+ $3(node).before('<div style="height:21px"></div>');
64042
+ if (!endsCell) $3(node).after('<div style="height:20px"></div>');
64015
64043
  });
64016
64044
  $3("a[style*='text-decoration-line']").each((_3, node) => {
64017
64045
  const props = parseInlineStyle($3(node).attr("style") || "");
@@ -64068,6 +64096,7 @@ function applyWordBoxModel($3) {
64068
64096
  if (text3.length > 20 && INVISIBLE_ONLY.test(text3)) el2.text(String.fromCharCode(160));
64069
64097
  });
64070
64098
  $3("ul,ol").each((_3, node) => {
64099
+ var _a22;
64071
64100
  const el2 = node;
64072
64101
  const props = parseInlineStyle($3(el2).attr("style") || "");
64073
64102
  let previous = el2.prev;
@@ -64077,11 +64106,27 @@ function applyWordBoxModel($3) {
64077
64106
  const style = parseInlineStyle($3(item).attr("style") || "");
64078
64107
  return style.has("margin") || style.has("margin-top") || style.has("margin-bottom");
64079
64108
  });
64080
- props.set("margin-top", afterBreak || previous && !tight ? "1lh!important" : "0!important");
64109
+ const nested = ((_a22 = el2.parent) == null ? void 0 : _a22.type) === "tag" && el2.parent.name === "li";
64110
+ props.set("margin-top", afterBreak || previous && !tight && !nested ? "1lh!important" : "0!important");
64081
64111
  props.set("margin-bottom", tight ? "0!important" : `${LIST_TRAILING_PX}px!important`);
64082
64112
  props.set("padding-left", `${LIST_TEXT_INDENT_PX}px!important`);
64083
64113
  $3(el2).attr("style", serializeStyle(props));
64084
64114
  });
64115
+ $3("br").each((_3, node) => {
64116
+ let at2 = node;
64117
+ let unparsed = false;
64118
+ for (; ; ) {
64119
+ for (let next2 = at2.next; next2; next2 = next2.next) {
64120
+ if (next2.type !== "text" || !/^[ \t\r\n]*$/.test(next2.data)) return;
64121
+ }
64122
+ const parent2 = at2.parent;
64123
+ if ((parent2 == null ? void 0 : parent2.type) !== "tag" || !INLINE_TAGS.has(parent2.name)) break;
64124
+ if ($3(parent2).attr(UNPARSED_MARK) !== void 0) unparsed = true;
64125
+ at2 = parent2;
64126
+ }
64127
+ if (unparsed) $3(node).after("<br>");
64128
+ });
64129
+ $3(`[${UNPARSED_MARK}]`).removeAttr(UNPARSED_MARK);
64085
64130
  $3("picture source").remove();
64086
64131
  $3("table").each((_3, node) => {
64087
64132
  var _a22, _b, _c2;
@@ -64268,6 +64313,25 @@ function applyWordBoxModel($3) {
64268
64313
  props.set("line-height", "normal");
64269
64314
  $3(el2).attr("style", serializeStyle(props));
64270
64315
  });
64316
+ $3("p, div, td, th, li, h1, h2, h3, h4, h5, h6").each((_3, node) => {
64317
+ var _a22;
64318
+ const el2 = node;
64319
+ const kids = $3(el2).contents().toArray().filter((n2) => !(n2.type === "comment" || n2.type === "text" && !/[^\s]/.test(n2.data)));
64320
+ if (!kids.length || !kids.every((n2) => n2.type === "tag" && INLINE_TAGS.has(n2.name))) return;
64321
+ if ($3(el2).find("img, table, svg, a, [style*='display']").length) return;
64322
+ const spacing = [el2, ...$3(el2).parents().toArray()].map(spacingOf).find((st2) => st2.has("line-height"));
64323
+ const line = ((_a22 = spacing == null ? void 0 : spacing.get("line-height")) != null ? _a22 : "normal").replace(/\s*!important$/i, "").trim();
64324
+ if (!(line === "normal" || /^\d*\.\d+$/.test(line) && Number(line) >= 1)) return;
64325
+ const own = parseInlineStyle($3(el2).attr("style") || "");
64326
+ own.set("line-height", "0");
64327
+ $3(el2).attr("style", serializeStyle(own));
64328
+ for (const kid of kids) {
64329
+ const props = parseInlineStyle($3(kid).attr("style") || "");
64330
+ if (props.has("line-height")) continue;
64331
+ props.set("line-height", "normal");
64332
+ $3(kid).attr("style", serializeStyle(props));
64333
+ }
64334
+ });
64271
64335
  const inherited2 = (el2, prop2) => [el2, ...$3(el2).parents().toArray()].map(spacingOf).find((st2) => st2.has(prop2));
64272
64336
  const sizeOf = (el2) => {
64273
64337
  var _a22, _b, _c2;
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  simulateDarkMode,
33
33
  toFramework,
34
34
  transformForAllClients
35
- } from "./chunk-Y3WSDM76.js";
35
+ } from "./chunk-MVU52ONA.js";
36
36
  import "./chunk-ABDTBRVK.js";
37
37
  import "./chunk-2AP7CT6R.js";
38
38
  import "./chunk-NXBRJX3V.js";
@@ -33649,6 +33649,17 @@ h1 {
33649
33649
  if (!/<!--\[if/i.test(html)) return html;
33650
33650
  return vmlToCss(resolveMsoBranch(html));
33651
33651
  }
33652
+ var LINK_LINE_BLOCKS = /* @__PURE__ */ new Set(["div", "p", "table", "ul", "ol", "h1", "h2", "h3", "h4", "h5", "h6", "center", "blockquote", "hr"]);
33653
+ var INLINE_TAGS = /* @__PURE__ */ new Set(["span", "a", "b", "strong", "i", "em", "u", "font", "small", "big", "sub", "sup"]);
33654
+ var WORD_PARSED = /^(?:mso-.*|font(?:-(?:family|size|weight|style|variant))?|color|background(?:-color)?|line-height|letter-spacing|white-space|word-wrap|text-(?:align|decoration|transform|indent|shadow)|vertical-align|direction|unicode-bidi|width|height|(?:margin|padding)(?:-(?:top|right|bottom|left))?|border(?:-(?:top|right|bottom|left))?(?:-(?:color|style|width))?)$/;
33655
+ var WORD_PARSED_VALUES = { "word-break": /^normal$/i, display: /^(?:inline|none)$/i };
33656
+ function wordParsesAll(props) {
33657
+ for (const [name, value] of props) {
33658
+ const values = WORD_PARSED_VALUES[name];
33659
+ if (values ? !values.test(value.replace(/\s*!important$/i, "").trim()) : !WORD_PARSED.test(name)) return false;
33660
+ }
33661
+ return true;
33662
+ }
33652
33663
  var PADDING = ["padding", "padding-top", "padding-right", "padding-bottom", "padding-left"];
33653
33664
  var MARGIN = ["margin", "margin-top", "margin-right", "margin-bottom", "margin-left"];
33654
33665
  var BORDER_WIDTH = [
@@ -33666,8 +33677,10 @@ h1 {
33666
33677
  var NATURAL_LINE = 1.15;
33667
33678
  var GILL_VDMX = [14, 14, 15, 16, 18, 18, 21, 21, 23, 25, 27, 27, 29, 30, 31];
33668
33679
  var isGill = (family = "") => /^\s*['"]?gill sans/i.test(family);
33680
+ var FACE_LINE = [[/^\s*['"]?arial black\b/i, 1.41]];
33669
33681
  var naturalHeight = (size, family = "") => {
33670
- if (!isGill(family)) return Math.round(size * NATURAL_LINE);
33682
+ var _a2, _b;
33683
+ if (!isGill(family)) return Math.round(size * ((_b = (_a2 = FACE_LINE.find(([face]) => face.test(family))) == null ? void 0 : _a2[1]) != null ? _b : NATURAL_LINE));
33671
33684
  const ppem = Math.round(size);
33672
33685
  return ppem <= 22 ? GILL_VDMX[Math.max(ppem, 8) - 8] : Math.ceil(0.9292 * size) + Math.ceil(0.2305 * size);
33673
33686
  };
@@ -33832,8 +33845,14 @@ h1 {
33832
33845
  );
33833
33846
  }
33834
33847
  function prepareWordSource(html) {
33835
- return wordSubstitutes(markHiddenCells(dropWordUnknownColors(html)));
33848
+ return markUnparsedInlines(wordSubstitutes(markHiddenCells(dropWordUnknownColors(html))));
33836
33849
  }
33850
+ var UNPARSED_MARK = "data-word-unparsed";
33851
+ var INLINE_STYLE = new RegExp(String.raw`<(${[...INLINE_TAGS].join("|")})(?=\s)(?=[^>]*?\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'))`, "gi");
33852
+ var markUnparsedInlines = (html) => html.replace(INLINE_STYLE, (open, _tag, dq, sq) => {
33853
+ var _a2;
33854
+ return wordParsesAll(parseInlineStyle((_a2 = dq != null ? dq : sq) != null ? _a2 : "")) ? open : `${open} ${UNPARSED_MARK}`;
33855
+ });
33837
33856
  var WORD_SUBSTITUTES = { rubik: "Calibri" };
33838
33857
  var SUBSTITUTED = new RegExp(String.raw`(font(?:-family)?\s*:[^;"}]*?)(['"]?)\b(${Object.keys(WORD_SUBSTITUTES).join("|")})\b\2`, "gi");
33839
33858
  var wordSubstitutes = (html) => html.replace(SUBSTITUTED, (_, lead, _q, name) => `${lead}${WORD_SUBSTITUTES[name.toLowerCase()]}`);
@@ -34047,9 +34066,18 @@ h1 {
34047
34066
  ]);
34048
34067
  $(node).attr("style", serializeStyle(set));
34049
34068
  });
34069
+ const blank = (n) => n.type === "comment" || n.type === "text" && !n.data.trim();
34050
34070
  $("a").each((_, node) => {
34051
34071
  if (!$(node).children("div, p").length) return;
34052
- $(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
34072
+ let before = node.prev;
34073
+ while (before && blank(before)) before = before.prev;
34074
+ let after = node.next;
34075
+ while (after && blank(after)) after = after.next;
34076
+ const parent = node.parent;
34077
+ const endsCell = !after && (parent == null ? void 0 : parent.type) === "tag" && /^t[dh]$/.test(parent.name);
34078
+ if (!before || before.type === "tag" && LINK_LINE_BLOCKS.has(before.name))
34079
+ $(node).before('<div style="height:21px"></div>');
34080
+ if (!endsCell) $(node).after('<div style="height:20px"></div>');
34053
34081
  });
34054
34082
  $("a[style*='text-decoration-line']").each((_, node) => {
34055
34083
  const props = parseInlineStyle($(node).attr("style") || "");
@@ -34106,6 +34134,7 @@ h1 {
34106
34134
  if (text.length > 20 && INVISIBLE_ONLY.test(text)) el.text(String.fromCharCode(160));
34107
34135
  });
34108
34136
  $("ul,ol").each((_, node) => {
34137
+ var _a2;
34109
34138
  const el = node;
34110
34139
  const props = parseInlineStyle($(el).attr("style") || "");
34111
34140
  let previous = el.prev;
@@ -34115,11 +34144,27 @@ h1 {
34115
34144
  const style = parseInlineStyle($(item).attr("style") || "");
34116
34145
  return style.has("margin") || style.has("margin-top") || style.has("margin-bottom");
34117
34146
  });
34118
- props.set("margin-top", afterBreak || previous && !tight ? "1lh!important" : "0!important");
34147
+ const nested = ((_a2 = el.parent) == null ? void 0 : _a2.type) === "tag" && el.parent.name === "li";
34148
+ props.set("margin-top", afterBreak || previous && !tight && !nested ? "1lh!important" : "0!important");
34119
34149
  props.set("margin-bottom", tight ? "0!important" : `${LIST_TRAILING_PX}px!important`);
34120
34150
  props.set("padding-left", `${LIST_TEXT_INDENT_PX}px!important`);
34121
34151
  $(el).attr("style", serializeStyle(props));
34122
34152
  });
34153
+ $("br").each((_, node) => {
34154
+ let at = node;
34155
+ let unparsed = false;
34156
+ for (; ; ) {
34157
+ for (let next = at.next; next; next = next.next) {
34158
+ if (next.type !== "text" || !/^[ \t\r\n]*$/.test(next.data)) return;
34159
+ }
34160
+ const parent = at.parent;
34161
+ if ((parent == null ? void 0 : parent.type) !== "tag" || !INLINE_TAGS.has(parent.name)) break;
34162
+ if ($(parent).attr(UNPARSED_MARK) !== void 0) unparsed = true;
34163
+ at = parent;
34164
+ }
34165
+ if (unparsed) $(node).after("<br>");
34166
+ });
34167
+ $(`[${UNPARSED_MARK}]`).removeAttr(UNPARSED_MARK);
34123
34168
  $("picture source").remove();
34124
34169
  $("table").each((_, node) => {
34125
34170
  var _a2, _b, _c;
@@ -34306,6 +34351,25 @@ h1 {
34306
34351
  props.set("line-height", "normal");
34307
34352
  $(el).attr("style", serializeStyle(props));
34308
34353
  });
34354
+ $("p, div, td, th, li, h1, h2, h3, h4, h5, h6").each((_, node) => {
34355
+ var _a2;
34356
+ const el = node;
34357
+ const kids = $(el).contents().toArray().filter((n) => !(n.type === "comment" || n.type === "text" && !/[^\s]/.test(n.data)));
34358
+ if (!kids.length || !kids.every((n) => n.type === "tag" && INLINE_TAGS.has(n.name))) return;
34359
+ if ($(el).find("img, table, svg, a, [style*='display']").length) return;
34360
+ const spacing = [el, ...$(el).parents().toArray()].map(spacingOf).find((st) => st.has("line-height"));
34361
+ const line = ((_a2 = spacing == null ? void 0 : spacing.get("line-height")) != null ? _a2 : "normal").replace(/\s*!important$/i, "").trim();
34362
+ if (!(line === "normal" || /^\d*\.\d+$/.test(line) && Number(line) >= 1)) return;
34363
+ const own = parseInlineStyle($(el).attr("style") || "");
34364
+ own.set("line-height", "0");
34365
+ $(el).attr("style", serializeStyle(own));
34366
+ for (const kid of kids) {
34367
+ const props = parseInlineStyle($(kid).attr("style") || "");
34368
+ if (props.has("line-height")) continue;
34369
+ props.set("line-height", "normal");
34370
+ $(kid).attr("style", serializeStyle(props));
34371
+ }
34372
+ });
34309
34373
  const inherited2 = (el, prop) => [el, ...$(el).parents().toArray()].map(spacingOf).find((st) => st.has(prop));
34310
34374
  const sizeOf = (el) => {
34311
34375
  var _a2, _b, _c;
@@ -43358,7 +43422,7 @@ Href: ${href}`
43358
43422
  // package.json
43359
43423
  var package_default = {
43360
43424
  name: "@emailens/cli",
43361
- version: "0.13.13",
43425
+ version: "0.13.14",
43362
43426
  description: "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
43363
43427
  type: "module",
43364
43428
  bin: {
@@ -43399,7 +43463,7 @@ var package_default = {
43399
43463
  },
43400
43464
  devDependencies: {
43401
43465
  "@anthropic-ai/sdk": "^0.52.0",
43402
- "@emailens/engine": "^0.18.15",
43466
+ "@emailens/engine": "^0.18.16",
43403
43467
  "@types/bun": "^1.4.0",
43404
43468
  "@types/mjml": "^4.7.4",
43405
43469
  "@types/node": "^25.9.5",
package/dist/test.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  auditEmail,
6
6
  flattenToLintIssues,
7
7
  loadProjectConfig
8
- } from "./chunk-Y3WSDM76.js";
8
+ } from "./chunk-MVU52ONA.js";
9
9
  import "./chunk-ABDTBRVK.js";
10
10
  import "./chunk-2AP7CT6R.js";
11
11
  import "./chunk-NXBRJX3V.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailens/cli",
3
- "version": "0.13.13",
3
+ "version": "0.13.14",
4
4
  "description": "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@anthropic-ai/sdk": "^0.52.0",
44
- "@emailens/engine": "^0.18.15",
44
+ "@emailens/engine": "^0.18.16",
45
45
  "@types/bun": "^1.4.0",
46
46
  "@types/mjml": "^4.7.4",
47
47
  "@types/node": "^25.9.5",