fix inline link highlighting, safer latex render
This commit is contained in:
		
							parent
							
								
									e302f6c423
								
							
						
					
					
						commit
						ed9a8efd1f
					
				
					 3 changed files with 22 additions and 21 deletions
				
			
		| 
						 | 
					@ -23,7 +23,6 @@ function initPopover(baseURL, useContextualBacklinks, renderLatex) {
 | 
				
			||||||
          el = htmlToElement(popoverElement)
 | 
					          el = htmlToElement(popoverElement)
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          const linkDest = content[li.dataset.src.replace(/\/$/g, "").replace(basePath, "")]
 | 
					          const linkDest = content[li.dataset.src.replace(/\/$/g, "").replace(basePath, "")]
 | 
				
			||||||
          console.log(linkDest.content)
 | 
					 | 
				
			||||||
          if (linkDest) {
 | 
					          if (linkDest) {
 | 
				
			||||||
            const popoverElement = `<div class="popover">
 | 
					            const popoverElement = `<div class="popover">
 | 
				
			||||||
    <h3>${linkDest.title}</h3>
 | 
					    <h3>${linkDest.title}</h3>
 | 
				
			||||||
| 
						 | 
					@ -33,6 +32,8 @@ function initPopover(baseURL, useContextualBacklinks, renderLatex) {
 | 
				
			||||||
            el = htmlToElement(popoverElement)
 | 
					            el = htmlToElement(popoverElement)
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (el) {
 | 
				
			||||||
          li.appendChild(el)
 | 
					          li.appendChild(el)
 | 
				
			||||||
          if (renderLatex) {
 | 
					          if (renderLatex) {
 | 
				
			||||||
            renderMathInElement(el, {
 | 
					            renderMathInElement(el, {
 | 
				
			||||||
| 
						 | 
					@ -51,7 +52,7 @@ function initPopover(baseURL, useContextualBacklinks, renderLatex) {
 | 
				
			||||||
          li.addEventListener("mouseout", () => {
 | 
					          li.addEventListener("mouseout", () => {
 | 
				
			||||||
            el.classList.remove("visible")
 | 
					            el.classList.remove("visible")
 | 
				
			||||||
          })
 | 
					          })
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,8 +38,8 @@ const removeMarkdown = (
 | 
				
			||||||
      .replace(/(#{1,6})\s+(.+)\1?/g, '<b>$2</b>')
 | 
					      .replace(/(#{1,6})\s+(.+)\1?/g, '<b>$2</b>')
 | 
				
			||||||
      .replace(/\s{0,2}\[.*?\]: .*?$/g, '')
 | 
					      .replace(/\s{0,2}\[.*?\]: .*?$/g, '')
 | 
				
			||||||
      .replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? '$1' : '')
 | 
					      .replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? '$1' : '')
 | 
				
			||||||
      .replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
 | 
					      .replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '<a>$1</a>')
 | 
				
			||||||
      .replace(/!?\[\[\S[^\[\]\|]*(?:\|([^\[\]]*))?\S\]\]/g, '$1')
 | 
					      .replace(/!?\[\[\S[^\[\]\|]*(?:\|([^\[\]]*))?\S\]\]/g, '<a>$1</a>')
 | 
				
			||||||
      .replace(/^\s{0,3}>\s?/g, '')
 | 
					      .replace(/^\s{0,3}>\s?/g, '')
 | 
				
			||||||
      .replace(/(^|\n)\s{0,3}>\s?/g, '\n\n')
 | 
					      .replace(/(^|\n)\s{0,3}>\s?/g, '\n\n')
 | 
				
			||||||
      .replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
 | 
					      .replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -569,7 +569,7 @@ header {
 | 
				
			||||||
    font-size: 0.8rem;
 | 
					    font-size: 0.8rem;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  & > p {
 | 
					  & > p, & > a {
 | 
				
			||||||
    margin: 0;
 | 
					    margin: 0;
 | 
				
			||||||
    font-weight: 400;
 | 
					    font-weight: 400;
 | 
				
			||||||
    user-select: none;
 | 
					    user-select: none;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue