MCPcopy
hub / github.com/readest/readest / replace

Function replace

apps/readest-app/src/services/transformers/warichu.ts:133–147  ·  view source on GitHub ↗
(_: string, innerText: string)

Source from the content-addressed store, hash-verified

131 if (!/warichuu?|<warichu/i.test(result)) return result;
132
133 const replace = (_: string, innerText: string) => {
134 const { html, text } = sanitizeInnerHTML(innerText);
135 if (!text) return '';
136 const { open, content, close } = extractParens(text);
137 // Also extract parens from the HTML version, keeping tags intact
138 const htmlParens = extractHtmlParens(html, open, close);
139 return (
140 `<span class="warichu-pending"` +
141 ` data-open="${escapeAttr(open)}"` +
142 ` data-close="${escapeAttr(close)}"` +
143 ` data-text="${escapeAttr(content)}"` +
144 ` data-html="${escapeAttr(htmlParens)}"` +
145 `>${open}${content}${close}</span>`
146 );
147 };
148
149 result = result.replace(WARICHU_SPAN_REGEX, replace);
150 result = result.replace(WARICHU_ELEMENT_REGEX, replace);

Callers

nothing calls this directly

Calls 4

sanitizeInnerHTMLFunction · 0.85
extractParensFunction · 0.85
extractHtmlParensFunction · 0.85
escapeAttrFunction · 0.85

Tested by

no test coverage detected