@spintax/core 0.1.4 → 0.1.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/dist/index.js CHANGED
@@ -911,13 +911,19 @@ var DECIMAL_RE = /\b\d+\.\d+\b/gu;
911
911
  var MULTI_ABBR_RE = new RegExp(`\\b(?:\\p{L}{1,2}\\.${S}*){2,}`, "gu");
912
912
  var SINGLE_ABBR_RE = new RegExp(`(?<![\\p{L}\\p{N}])(?:${SINGLE_ABBREVS.join("|")})\\.(?=${S}|$|<)`, "giu");
913
913
  var TRAILING_PUNCT_RE = /([.,;:!]+)$/u;
914
+ var SENTENCE_OPENERS = "\xBF\xA1";
915
+ var LEAD = `(?:<[^>]+>|[${SENTENCE_OPENERS}]|${S})*`;
914
916
  var SPACE_BEFORE_PUNCT_RE = new RegExp(`${S}+([,;:!?.])`, "gu");
915
917
  var SPACE_AFTER_COMMA_RE = new RegExp(`([,;:])(?!\\d)(?!${S}|$|<)`, "gu");
916
- var SPACE_AFTER_SENTENCE_RE = new RegExp(`([.!?])(?!\\d)(?!${S}|$|<)`, "gu");
917
- var CAP_FIRST_RE = new RegExp(`^(${S}*(?:<[^>]+>${S}*)*)(\\p{Ll})`, "u");
918
- var CAP_AFTER_SENTENCE_RE = new RegExp(`([.!?\u2026])(${S}*(?:<\\/?[^>]+>${S}*)*)(\\p{Ll})`, "gu");
919
- var CAP_AFTER_BLOCK_RE = new RegExp(`(<\\/?(?:p|h[1-6]|li|blockquote|div|td|th)[^>]*>${S}*)(\\p{Ll})`, "giu");
920
- var CAP_AFTER_BREAK_RE = new RegExp(`(\\n${S}*)(\\p{Ll})`, "gu");
918
+ var SPACE_AFTER_SENTENCE_RE = new RegExp(`([.!?]+)(?![.!?])(?!\\d)(?!${S}|$|<)`, "gu");
919
+ var SPACE_AFTER_OPENER_RE = new RegExp(`([${SENTENCE_OPENERS}])${S}+`, "gu");
920
+ var CAP_FIRST_RE = new RegExp(`^(${LEAD})(\\p{Ll})`, "u");
921
+ var CAP_AFTER_SENTENCE_RE = new RegExp(`([.!?\u2026])(${LEAD})(\\p{Ll})`, "gu");
922
+ var CAP_AFTER_BLOCK_RE = new RegExp(
923
+ `(<\\/?(?:p|h[1-6]|li|blockquote|div|td|th)[^>]*>${LEAD})(\\p{Ll})`,
924
+ "giu"
925
+ );
926
+ var CAP_AFTER_BREAK_RE = new RegExp(`(\\n${LEAD})(\\p{Ll})`, "gu");
921
927
  var up = (ch) => ch.toUpperCase();
922
928
  function postProcess(input) {
923
929
  const placeholders = /* @__PURE__ */ new Map();
@@ -949,6 +955,7 @@ function postProcess(input) {
949
955
  text = text.replace(SPACE_BEFORE_PUNCT_RE, "$1");
950
956
  text = text.replace(SPACE_AFTER_COMMA_RE, "$1 ");
951
957
  text = text.replace(SPACE_AFTER_SENTENCE_RE, "$1 ");
958
+ text = text.replace(SPACE_AFTER_OPENER_RE, "$1");
952
959
  text = text.replace(CAP_FIRST_RE, (_m, lead, ch) => lead + up(ch));
953
960
  text = text.replace(CAP_AFTER_SENTENCE_RE, (_m, p, gap, ch) => p + gap + up(ch));
954
961
  text = text.replace(CAP_AFTER_BLOCK_RE, (_m, tag, ch) => tag + up(ch));