Highlight.js and <details>
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 806
- Forks
- 434
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 32
Description
Description of problem
When using progressive disclosure using the details element in a ReSpec document, Highlight.js ceases to function and erases the content from the rendering tree.
URL to affected spec or repo:
https://w3c.github.io/sustyweb/drafts/ (Note as a temporary fix we're using nohighlight as a workaround.)
What happened (e.g., it crashed)?:
The code inside the pre element is erased and an empty tag is rendered instead of syntax being highlighted.
Expected behavior (e.g., it shouldn't crash):
The syntax should be highlighted, as it is for any code that would exist outside of the details element.
Optional, steps to reproduce:
- Create a ReSpec draft document.
- Add a details element with some syntax inside.
Show / Hide content.
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(g,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,v=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf
- This test showcases a basic ReSpec with it non-functional test.txt
- This test showcases a basic HTML file with it functional test2.txt
Note: I have verified that this issue does not occur in a normal HTML document using highlight.js therefore it possibly is due to ReSpec or its implementation of highlight?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the affected ReSpec draft and compare the attached test.txt case, where highlighting fails, with test2.txt, where Highlight.js works in plain HTML. Trace ReSpec's Highlight.js processing for code inside a details element and verify that the code remains in the rendering tree and receives syntax highlighting without the nohighlight workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100