taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

Error process <pre><code><code/><pre/> block #77

Closed mashirozx closed 4 years ago

mashirozx commented 4 years ago

CODE:

const html = `
    <div class="language-python highlighter-rouge">
      <div class="highlight">
        <pre
          class="highlight"><code><span class="k">print</span><span class="p">(</span><span class="s">'hello'</span><span class="p">)</span><br><span class="n">i</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><br></code></pre>
      </div>
    </div>
    `
    const _html = htmlParser(html)
    console.log('or--\n'+html+'\naf---\n'+_html);

RESULT:

or--

    <div class="language-python highlighter-rouge">
      <div class="highlight">
        <pre
          class="highlight"><code><span class="k">print</span><span class="p">(</span><span class="s">'hello'</span><span class="p">)</span><br><span class="n">i</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><br></code></pre>
      </div>
    </div>

af---

    <div class="language-python highlighter-rouge">
      <div class="highlight">
        <pre class="highlight"></pre>
      </div>
    </div>
taoqf commented 4 years ago

Maybe you're using v1.2, please try 1.3

mashirozx commented 4 years ago

work well now