Skip to content

Commit

Permalink
better code block to html conversion
Browse files Browse the repository at this point in the history
also fixes firefox including <select> in innerText
  • Loading branch information
jhchen committed Sep 21, 2018
1 parent c44241b commit e298692
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions formats/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ class CodeBlockContainer extends Container {
}

html(index, length) {
let text = this.domNode.innerText;
// TODO find more robust solution for <select> turning into \n
if (text.startsWith('\n')) {
text = text.slice(1);
}
text = text.slice(index, index + length);
const text = this.children
.map(child => child.domNode.innerText)
.join('\n')
.slice(index, index + length);
return `<pre>${escapeText(text)}</pre>`;
}
}
Expand Down

0 comments on commit e298692

Please sign in to comment.