slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
42.3k stars 3.31k forks source link

Syntax highlighting is not working for html/xml language. #4283

Open Triggered41 opened 4 days ago

Triggered41 commented 4 days ago

Syntax highlighting is not working for html/xml language.

Note: Since "highlight" is not an option in "syntax" in "modules" I could not really try manually highlighting the code to see if that works, I tried creating customBlot but failed (maybe cause I didn't know what I was doing)

modules: {
    syntax: {
        highlight: (val) => // this function is not called anywhere so could not do manual highlight
    }
}

Steps for Reproduction

  1. Visit [https://quilljs.com/docs/formats]
  2. Add a code block in the quill editor
  3. Write some xml code for example: <tag attr>value</tag>

Expected behavior:

highlighted output should be

<span class="hljs-tag">&lt;<span class="hljs-name">tag</span> <span class="hljs-attr">attr</span>&gt;</span>value<span class="hljs-tag">&lt;/<span class="hljs-name">tag</span>&gt;</span> above was gained through

hljs.highlight('<tag attr>value</tag>', {language: 'xml'}).value

Actual output that we get

<span class="ql-token hljs-tag">&lt;tag attr&gt;</span>value<span class="ql-token hljs-tag">&lt;/tag&gt;</span>

above output can be seen in inspector

Platforms:

Browser: Chrome : Version 126.0.6478.127 (Official Build) (64-bit) OS: Windows 10

Version:

2.0.2

thank you!

enzedonline commented 2 days ago

I can confirm this. Code highlighting is also stripped out by getSemanticHTML().