MCPcopy Index your code
hub / github.com/ether/etherpad / applyMonospaceToCode

Function applyMonospaceToCode

src/node/utils/ExportSanitizeHtml.ts:85–98  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

83};
84
85export const applyMonospaceToCode = (html: string): string =>
86 html.replace(MONO_TAGS_RE, (_, tag, attrs, content) => {
87 const styled = wrapNonAnchorSegments(content);
88 // Block-level treatment for <pre> (always) and <code>/<tt>/etc.
89 // when the wrapper carries an inline style (ep_headings2 +
90 // ep_align emit `<code style='text-align:right'>` for each pad
91 // line). Forward the style to a wrapping `<p>`.
92 const styleMatch = STYLE_ATTR_RE.exec(attrs);
93 if (tag.toLowerCase() === 'pre' || styleMatch) {
94 const styleAttr = styleMatch ? ` style="${styleMatch[2]}"` : '';
95 return `<p${styleAttr}>${styled}</p>`;
96 }
97 return styled;
98 });
99
100// Drop block elements whose only content is whitespace. Etherpad plugins
101// like ep_headings2 emit a heading-styled blank-line block (e.g.

Callers 2

export.tsFile · 0.85
ExportHandler.tsFile · 0.85

Calls 1

wrapNonAnchorSegmentsFunction · 0.85

Tested by

no test coverage detected