"use client"; import { toWechatHtml } from "./wechat"; import { copyHtml } from "./clipboard"; /** * Zhihu accepts the same kind of inlined HTML as WeChat, but math expressions * need LATEX. We strip MathJax containers and replace. */ export function toZhihuHtml(fullHtml: string): string { let html = toWechatHtml(fullHtml); // Replace any mjx-container with the data-eeimg image markup html = html.replace( /]*?>([\s\S]*?)<\/mjx-container>/g, (_full, inner) => { const tex = (inner.match(/aria-label="([^"]*)"/) ?? [])[1] ?? (inner.match(/]*?>([\s\S]*?)<\/math>/) ?? [])[1] ?? ""; const safe = tex.replace(/"/g, """); return `${safe}`; }, ); return html; } export async function copyToZhihu(fullHtml: string): Promise { const html = toZhihuHtml(fullHtml); await copyHtml(html); }