Skip to content

Commit

Permalink
fix inline link highlighting, safer latex render
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed May 6, 2022
1 parent e302f6c commit ed9a8ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
37 changes: 19 additions & 18 deletions assets/js/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function initPopover(baseURL, useContextualBacklinks, renderLatex) {
el = htmlToElement(popoverElement)
} else {
const linkDest = content[li.dataset.src.replace(/\/$/g, "").replace(basePath, "")]
console.log(linkDest.content)
if (linkDest) {
const popoverElement = `<div class="popover">
<h3>${linkDest.title}</h3>
Expand All @@ -33,25 +32,27 @@ function initPopover(baseURL, useContextualBacklinks, renderLatex) {
el = htmlToElement(popoverElement)
}
}
li.appendChild(el)
if (renderLatex) {
renderMathInElement(el, {
delimiters: [
{ left: '$$', right: '$$', display: false },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{ left: '\\[', right: '\\]', display: false }
],
throwOnError: false

if (el) {
li.appendChild(el)
if (renderLatex) {
renderMathInElement(el, {
delimiters: [
{ left: '$$', right: '$$', display: false },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{ left: '\\[', right: '\\]', display: false }
],
throwOnError: false
})
}
li.addEventListener("mouseover", () => {
el.classList.add("visible")
})
li.addEventListener("mouseout", () => {
el.classList.remove("visible")
})
}
li.addEventListener("mouseover", () => {
el.classList.add("visible")
})
li.addEventListener("mouseout", () => {
el.classList.remove("visible")
})

})
})
}
4 changes: 2 additions & 2 deletions assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const removeMarkdown = (
.replace(/(#{1,6})\s+(.+)\1?/g, '<b>$2</b>')
.replace(/\s{0,2}\[.*?\]: .*?$/g, '')
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? '$1' : '')
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
.replace(/!?\[\[\S[^\[\]\|]*(?:\|([^\[\]]*))?\S\]\]/g, '$1')
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '<a>$1</a>')
.replace(/!?\[\[\S[^\[\]\|]*(?:\|([^\[\]]*))?\S\]\]/g, '<a>$1</a>')
.replace(/^\s{0,3}>\s?/g, '')
.replace(/(^|\n)\s{0,3}>\s?/g, '\n\n')
.replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
Expand Down
2 changes: 1 addition & 1 deletion assets/styles/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ header {
font-size: 0.8rem;
}

& > p {
& > p, & > a {
margin: 0;
font-weight: 400;
user-select: none;
Expand Down

0 comments on commit ed9a8ef

Please sign in to comment.