web_ppt / frontend /src /utils /textParser.ts
CatPtain's picture
Upload 339 files
89ce340 verified
raw
history blame
384 Bytes
/**
* 将普通文本转为带段落信息的HTML字符串
* @param text 文本
*/
export const parseText2Paragraphs = (text: string) => {
const htmlText = text.replace(/[\n\r]+/g, '<br>')
const paragraphs = htmlText.split('<br>')
let string = ''
for (const paragraph of paragraphs) {
if (paragraph) string += `<div>${paragraph}</div>`
}
return string
}