(html: string)
| 83 | }; |
| 84 | |
| 85 | export 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. |
no test coverage detected