mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
18 lines
513 B
TypeScript
18 lines
513 B
TypeScript
import 'hydrooj';
|
|
import TurndownService from 'turndown';
|
|
import { JSDOM } from 'jsdom';
|
|
|
|
const turndownService = new TurndownService();
|
|
|
|
export function convertHTML(html: string) {
|
|
const DOM = new JSDOM(html);
|
|
const eles = DOM.window.document.querySelectorAll('span.katex-mathml');
|
|
eles.forEach((ele) => {
|
|
const MathML = ele.innerHTML;
|
|
ele.parentElement.replaceWith(MathML);
|
|
});
|
|
return turndownService.turndown(DOM.serialize());
|
|
}
|
|
|
|
global.Hydro.lib.convertHTML = convertHTML;
|