/** * 将普通文本转为带段落信息的HTML字符串 * @param text 文本 */ export const parseText2Paragraphs = (text: string) => { const htmlText = text.replace(/[\n\r]+/g, '
') const paragraphs = htmlText.split('
') let string = '' for (const paragraph of paragraphs) { if (paragraph) string += `
${paragraph}
` } return string }