website-01/lib/content.ts

16 lines
659 B
TypeScript
Raw Normal View History

2026-06-22 14:43:46 +08:00
/**
* `content` HTML Markdown
*
*
* - RichEditor (Quill) HTML <p>
* - Markdown HTML `<em>` 便 HTML dangerouslySetInnerHTML
*/
const HTML_BLOCK_RE =
/<\/?(p|div|span|h[1-6]|ul|ol|li|table|tbody|thead|tr|td|th|br|img|a|strong|em|b|i|blockquote|pre|code|hr|figure|figcaption|section|article|header|footer|html|body)\b/i;
export function isHTMLContent(s: string | null | undefined): boolean {
if (!s) return false;
return HTML_BLOCK_RE.test(s);
}