优化移动设备体验

This commit is contained in:
tianyaxiang 2025-01-30 01:31:45 +08:00
parent 6f0ac58505
commit cdca9d4d3f

View File

@ -74,7 +74,9 @@ export function convertToWechat(markdown: string, options: RendererOptions = {})
customRenderer.heading = function({ text, depth }: Tokens.Heading) { customRenderer.heading = function({ text, depth }: Tokens.Heading) {
const style = options.block?.[`h${depth}` as keyof typeof options.block] const style = options.block?.[`h${depth}` as keyof typeof options.block]
const styleStr = cssPropertiesToString(style) const styleStr = cssPropertiesToString(style)
return `<h${depth}${styleStr ? ` style="${styleStr}"` : ''}>${text}</h${depth}>` const tokens = marked.Lexer.lexInline(text)
const content = marked.Parser.parseInline(tokens, { renderer: customRenderer })
return `<h${depth}${styleStr ? ` style="${styleStr}"` : ''}>${content}</h${depth}>`
} }
customRenderer.paragraph = function({ text }: Tokens.Paragraph) { customRenderer.paragraph = function({ text }: Tokens.Paragraph) {