mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
If in a pre block dont replace whitespace when highlighting
This commit is contained in:
parent
ed7303b9fb
commit
aa856a5366
2 changed files with 9 additions and 3 deletions
|
|
@ -195,7 +195,6 @@ export function ArticleContainer(props: ArticleContainerProps): JSX.Element {
|
|||
readerTableHeaderColor: theme.colors.readerTableHeader.toString(),
|
||||
readerHeadersColor: theme.colors.readerHeader.toString(),
|
||||
}
|
||||
console.log('setting font family: ', styles.fontFamily)
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -121,10 +121,17 @@ export function makeHighlightNodeAttributes(
|
|||
})
|
||||
const { parentNode, nextSibling } = node
|
||||
|
||||
var isPre = false
|
||||
var nodeElement = (node instanceof HTMLElement) ? node : node.parentElement
|
||||
if (nodeElement) {
|
||||
isPre = (window.getComputedStyle(nodeElement).whiteSpace.startsWith('pre'))
|
||||
}
|
||||
|
||||
parentNode?.removeChild(node)
|
||||
textPartsToHighlight.forEach(({ highlight, text: rawText }, i) => {
|
||||
// Prevent hardcoded \n, we'll create new-lines based on the startsParagraph data
|
||||
const text = rawText.replace(/\n/g, '')
|
||||
// If we are not in preformatted text, prevent hardcoded \n,
|
||||
// we'll create new-lines based on the startsParagraph data
|
||||
const text = isPre ? rawText : rawText.replace(/\n/g, '')
|
||||
const newTextNode = document.createTextNode(text)
|
||||
|
||||
if (!highlight) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue