@diplodoc/cli 5.35.1 → 5.35.3

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.
@@ -2067,6 +2067,9 @@
2067
2067
  // src/worker/format.ts
2068
2068
  var MAX_LENGTH = 200;
2069
2069
  var SHORT_HEAD = 20;
2070
+ function escapeHTML(str) {
2071
+ return str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
2072
+ }
2070
2073
  function format({ base, mark }, results, registry2, trim) {
2071
2074
  return results.map((entry) => {
2072
2075
  const doc = registry2[entry.ref];
@@ -2138,10 +2141,10 @@
2138
2141
  }
2139
2142
  }
2140
2143
  function highlighte(mark, text, positions) {
2141
- return positions.reduceRight((result, position) => {
2142
- const [before, content, after] = split(result, position);
2143
- return `${before}<span class="${mark}">${content}</span>${after}`;
2144
- }, text);
2144
+ return positions.reduce((accumulator, [from, to], index2) => {
2145
+ const prevTo = index2 === 0 ? 0 : positions[index2 - 1][1];
2146
+ return accumulator + escapeHTML(text.slice(prevTo, from)) + `<span class="${mark}">${escapeHTML(text.slice(from, to))}</span>`;
2147
+ }, "") + escapeHTML(text.slice(positions.length ? positions[positions.length - 1][1] : 0));
2145
2148
  }
2146
2149
  function split(text, position) {
2147
2150
  const before = text.slice(0, position[0]);