Vditor 的 getHtml() 返回的代码块没被渲染

md 原文如下

# 从小到大
nums = [1, 4, 5, 7, 3, 5, 9]
for i in range(0, len(nums)):
    Min = {
        "num": int(float('inf')),
        "index": 0
    }
    for j in range(0, len(nums) - i):
        if nums[j] < Min["num"]:
            Min["num"] = nums[j]
            Min["index"] = j
    nums.pop(Min["index"])
    nums.append(Min["num"])
for i in range(0, len(nums)):
    print(nums[i])

vditor.getHtml()返回内容如下

`<pre><code class="language-python"># 从小到大\nnums = [1, 4, 5, 7, 3, 5, 9]\nfor i in range(0, len(nums)):\n    Min = {\n        "num": int(float('inf')),\n        "index": 0\n    }\n    for j in range(0, len(nums) - i):\n        if nums[j] < Min["num"]:\n            Min["num"] = nums[j]\n            Min["index"] = j\n    nums.pop(Min["index"])\n    nums.append(Min["num"])\nfor i in range(0, len(nums)):\n    print(nums[i])\n\n</code></pre>\n`

我希望返回如下

<pre class="vditor-ir__preview" data-render="1"><div class="vditor-copy"><textarea></textarea><span aria-label="复制" onmouseover="this.setAttribute('aria-label', '复制')" class="vditor-tooltipped vditor-tooltipped__w" onclick="this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '已复制')"><svg><use xlink:href="#vditor-icon-copy"></use></svg></span></div><code class="language-python hljs" style="max-height: 776px;"><span class="hljs-comment"># 从小到大</span>
nums = [<span class="hljs-number">1</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">7</span>, <span class="hljs-number">3</span>, <span class="hljs-number">5</span>, <span class="hljs-number">9</span>]
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(nums)):
    Min = {
        <span class="hljs-string">"num"</span>: <span class="hljs-built_in">int</span>(<span class="hljs-built_in">float</span>(<span class="hljs-string">'inf'</span>)),
        <span class="hljs-string">"index"</span>: <span class="hljs-number">0</span>
    }
    <span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(nums) - i):
        <span class="hljs-keyword">if</span> nums[j] < Min[<span class="hljs-string">"num"</span>]:
            Min[<span class="hljs-string">"num"</span>] = nums[j]
            Min[<span class="hljs-string">"index"</span>] = j
    nums.pop(Min[<span class="hljs-string">"index"</span>])
    nums.append(Min[<span class="hljs-string">"num"</span>])
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(nums)):
    <span class="hljs-built_in">print</span>(nums[i])

</code></pre>

请问如何解决?

  • Vditor

    Vditor 是一款浏览器端的 Markdown 编辑器,支持所见即所得、即时渲染(类似 Typora)和分屏预览模式。它使用 TypeScript 实现,支持原生 JavaScript、Vue、React 和 Angular。

    186 引用 • 1112 回帖
  • Q&A

    提问之前请先看《提问的智慧》,好的问题比好的答案更有价值。

    3337 引用 • 16883 回帖 • 485 关注

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
  • 5aSP
    作者

    补充解释一下问题:

    getHTML()返回的内容是第一个箭头所指代码,请问如何获取第二个箭头所指代码?

    image.png

  • 5aSP
    作者

    已解决。