Closed edentsai closed 1 year ago
use Node.textContext instead of Element.innerHTML for calculate line num height with escaped HTML characters.
Node.textContext
Element.innerHTML
Fix the issues: https://github.com/stargrey/obsidian-better-codeblock/issues/12
When code block contains HTML characters, the code-block-linenum span will be set wrong height: 0px, for example:
height: 0px
the Markdown code block in Obsidian:
```html <!-- Hello World --> <div> Hello World </div>
the rendered HTML result in Reading view: ```html <span class="code-block-linenum-wrap"> <span class="code-block-linenum" style="height: 0px;"></span> <span class="code-block-linenum" style="height: 0px;"></span> <span class="code-block-linenum" style="height: 24px;"></span> <span class="code-block-linenum" style="height: 0px;"></span> </span>
Reference:
Note.textContent
use
Node.textContext
instead ofElement.innerHTML
for calculate line num height with escaped HTML characters.Fix the issues: https://github.com/stargrey/obsidian-better-codeblock/issues/12
When code block contains HTML characters, the code-block-linenum span will be set wrong
height: 0px
, for example:the Markdown code block in Obsidian:
Reference:
Note.textContent
https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent