Skip to content

Commit

Permalink
Merge pull request #297 from StampyAI/glossary-bugs
Browse files Browse the repository at this point in the history
fix glossary bugs
  • Loading branch information
mruwnik authored Aug 6, 2023
2 parents 669609d + 6b74380 commit dc2fdaf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/routes/questions/$question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function Question({
const updateTextNodes = (el: Node, textProcessor: (node: Node) => Node) => {
Array.from(el.childNodes).forEach((child) => updateTextNodes(child, textProcessor))

if (el.nodeType == Node.TEXT_NODE && el.textContent && el?.parentElement?.tagName != 'A') {
if (el.nodeType == Node.TEXT_NODE && el.textContent) {
const node = textProcessor(el)
el?.parentNode?.replaceChild(node, el)
}
Expand Down Expand Up @@ -223,11 +223,13 @@ function Contents({pageid, html, glossary}: {pageid: PageId; html: string; gloss
* - an on hover popup with a short explaination of the glossary item
*/
const insertGlossary = (textNode: Node) => {
const html = textNode.textContent || ''
const html = (textNode.textContent || '').replace('’', "'").replace('—', '-')
// The glossary items have to be injected somewhere, so this does it by manually wrapping any known
// definitions with spans. This is done from the longest to the shortest to make sure that sub strings
// of longer definitions don't override them.
const updated = Object.keys(glossary)
const updated = Object.values(glossary)
.filter((item) => item.pageid != pageid)
.map(({term}) => term)
.sort((a, b) => b.length - a.length)
.reduce(
(html, entry) =>
Expand Down

0 comments on commit dc2fdaf

Please sign in to comment.