@mgdis/core-ui-helpers 1.0.6 → 1.0.7

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.
@@ -1576,7 +1576,7 @@ let ignore_map$1;
1576
1576
  */
1577
1577
  const minify = (html, config) => {
1578
1578
  let reinsert_ignored = false;
1579
- const { checked_html, ignored } = getState();
1579
+ const { checked_html, ignored, constants } = getState();
1580
1580
 
1581
1581
  if (!checked_html && !isHtml(html)) return html
1582
1582
 
@@ -1607,6 +1607,18 @@ const minify = (html, config) => {
1607
1607
  // Collapse any remaining multiple spaces to single spaces.
1608
1608
  html = html.replace(/ {2,}/g, ' ');
1609
1609
 
1610
+ // Protect space between text content and an opening tag (e.g., "text <a>")
1611
+ html = html.replace(
1612
+ /(\S) (<[a-zA-Z][a-zA-Z0-9_:-]*)/g,
1613
+ `$1___MINIFY-PROTECTED-SPACE___$2`
1614
+ );
1615
+
1616
+ // Protect space between a closing tag and text content (e.g., "</a> text")
1617
+ html = html.replace(
1618
+ /(<\/[a-zA-Z][a-zA-Z0-9_:-]*>) (\S)/g,
1619
+ `$1___MINIFY-PROTECTED-SPACE___$2`
1620
+ );
1621
+
1610
1622
  // Remove specific single spaces between tags and whitespace within tags.
1611
1623
  html = html.replace(/ >/g, ">"); // <tag > -> <tag>
1612
1624
  html = html.replace(/ </g, "<"); // leading space before tag
@@ -1615,6 +1627,9 @@ const minify = (html, config) => {
1615
1627
  html = html.replace(/<\s+\//g, '</'); // < /tag> -> </tag>
1616
1628
  html = html.replace(/<\/\s+/g, '</'); // </ tag> -> </tag>
1617
1629
 
1630
+ // Unprotect space around inner tags
1631
+ html = html.replace(new RegExp('___MINIFY-PROTECTED-SPACE___', 'g'), ' ');
1632
+
1618
1633
  // Trim spaces around equals signs in attributes (run before value trim)
1619
1634
  // This handles `attr = "value"` -> `attr="value"`
1620
1635
  html = html.replace(/ = /g, "=");
@@ -1759,6 +1774,9 @@ const process = () => {
1759
1774
  output_lines[output_lines.length - 1] =
1760
1775
  output_lines.at(-1) + current_line_value.charAt(0);
1761
1776
  current_line_value = current_line_value.slice(1).trim();
1777
+
1778
+ /* If nothing left after extracting punctuation, skip this line. */
1779
+ if (current_line_value.length === 0) return
1762
1780
  }
1763
1781
  }
1764
1782