yandeu / five-server-vscode

⚡ VSCode Extension for Five Server.
https://marketplace.visualstudio.com/items?itemName=yandeu.five-server
Other
121 stars 9 forks source link

highlight stops working after two tags in <p> #22

Closed fekoch closed 1 year ago

fekoch commented 2 years ago

Describe the bug If you use two or more tags inside a <p></p> (like <b>, <br> and <span>) the highlight feature stops working inside and after the second tag.

working: working

<b> and <br> not working

2x <span> not working

my .fivesereverrc.json:

{
    "highlight": true, 
    "injectBody": true
  }

full index.html:

<!DOCTYPE html>
<html>
    <head></head>

    <body>
        <p>Working normally <br> Still Working</p>
        <p>With <b>bold</b> also</p>
        <p>With <b>bold</b> and <br> lineBreak not</p>
        <p>with <b>bold</b> and <br> linebreak <b>again bold not</b></p>
        <p>With break<br> and break<br> not</p>
        <p>With <b>bold</b> and <b>bold not</b></p>
        <p>A <span>span</span> and a <span>span</span> not</p>
    </body>
</html>

Installed Plugins: only yandeu.five-server (v0.1.4)

Editor:

Version: 1.69.2
Commit: 3b889b090b5ad5793f524b5d1d39fda662b96a2a
Date: 2022-07-19T13:15:38.080Z
Electron: 18.3.6
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.18-electron.0
OS: Linux x64 5.15.55-1-MANJARO
yandeu commented 2 years ago

For me, it highlights all the <p>'s, but non of the <b>'s nor <span>'s.

I guess the issue is somewhere here: https://github.com/yandeu/five-server/blob/512302a00c080bbaf3caa25c79c97f8e86166257/src/workers/parseBody.ts#L35

injectHighlight() does not look like a very good implementation. Re-writing the parser would probably help.

yandeu commented 2 years ago

I'm about to improve it here: https://github.com/yandeu/five-server/tree/better-body-parsing