feat: latex in search results

This commit is contained in:
Jacky Zhao 2022-12-03 21:03:12 -08:00
parent 4cd6f7efdf
commit ce5df837f5
3 changed files with 14 additions and 4 deletions

View file

@ -5,7 +5,7 @@ function htmlToElement(html) {
return template.content.firstChild
}
function initPopover(baseURL, useContextualBacklinks, renderLatex) {
function initPopover(baseURL, useContextualBacklinks) {
const basePath = baseURL.replace(window.location.origin, "")
fetchData.then(({ content }) => {
const links = [...document.getElementsByClassName("internal-link")]
@ -42,7 +42,7 @@ function initPopover(baseURL, useContextualBacklinks, renderLatex) {
if (el) {
li.appendChild(el)
if (renderLatex) {
if (LATEX_ENABLED) {
renderMathInElement(el, {
delimiters: [
{ left: '$$', right: '$$', display: false },

View file

@ -203,6 +203,16 @@ const displayResults = (term, finalResults, extractHighlight = false) => {
}
)
.join("\n")
if (LATEX_ENABLED) {
renderMathInElement(results, {
delimiters: [
{ left: '$$', right: '$$', display: false },
{ left: '$', right: '$', display: false },
],
throwOnError: false
})
}
const anchors = [...document.getElementsByClassName("result-card")]
anchors.forEach((anchor) => {
anchor.onclick = () => redir(anchor.id, term)