diff --git a/xuan-deduct-uniapp/src/utils/markdownToHtml.js b/xuan-deduct-uniapp/src/utils/markdownToHtml.js index 9a7815c..b6c7619 100644 --- a/xuan-deduct-uniapp/src/utils/markdownToHtml.js +++ b/xuan-deduct-uniapp/src/utils/markdownToHtml.js @@ -6,7 +6,7 @@ export function markdownToHtml(markdown) { const lines = html.split('\n') if (lines.length > 0) { lines.shift() - html = lines.join('\n').trim() + html = lines.map(line => line.trimStart()).join('\n').trim() } html = html.replace(/^### (.*$)/gim, '

$1

') @@ -20,19 +20,19 @@ export function markdownToHtml(markdown) { html = html.replace(/_(.+?)_/g, '$1') html = html.replace(/`(.+?)`/g, '$1') - html = html.replace(/^\s*[-•]\s(.+)$/gim, '
  • $1
  • ') - html = html.replace(/^\s*\*\s(.+)$/gim, '
  • $1
  • ') - html = html.replace(/^\s*\+\s(.+)$/gim, '
  • $1
  • ') + html = html.replace(/^[-•]\s(.+)$/gim, '
  • $1
  • ') + html = html.replace(/^\*\s(.+)$/gim, '
  • $1
  • ') + html = html.replace(/^\+\s(.+)$/gim, '
  • $1
  • ') html = html.replace(/(]*>.*<\/li>\n?)+/g, function(match) { return '' }) - html = html.replace(/\n\n/g, '

    ') + html = html.replace(/\n\n/g, '

    ') html = html.replace(/\n/g, '
    ') if (!html.startsWith('<')) { - html = '

    ' + html + '

    ' + html = '

    ' + html + '

    ' } return html