rename element to be more accurate

This commit is contained in:
Fraser
2023-08-12 17:06:54 -04:00
parent f00bde5e88
commit 42f3666dec
3 changed files with 8 additions and 9 deletions
+6 -5
View File
@@ -10,11 +10,12 @@ export type Glossary = Map<string, GlossaryItem>;
export const GlossaryContext = createContext<{g: Glossary, r: RegExp} | null>(null);
// A component which wraps a paragraph and injects glossary terms into it as
// hoverable pop-up links. The text is immediately rendered normally, but after
// the glossary is loaded (which happens once per page, asynchronously), the
// glossary terms are replaced with elements.
export const GlossaryP: React.FC<{content: string}> = ({content}) => {
// A component which wraps arbitrary html in a span, and injects glossary terms
// into it as hoverable pop-up links. The text is immediately rendered normally,
// but after the glossary is loaded (which happens once per page, asynchronously),
// the glossary terms are replaced with elements.
export const GlossarySpan: React.FC<{content: string}> = ({content}) => {
const g = useContext(GlossaryContext);
-2
View File
@@ -43,5 +43,3 @@ const tempHackFetch = (_url: string) => {
}, 1000);
});
}
+2 -2
View File
@@ -10,7 +10,7 @@ import Image from 'next/image';
import Header from "../header";
import { SearchBox, Followup } from "../searchbox";
import logo from "../logo.svg"
import { GlossaryP } from "../glossary";
import { GlossarySpan } from "../glossary";
type Citation = {
title: string;
@@ -203,7 +203,7 @@ const ShowAssistantEntry: React.FC<{entry: AssistantEntry}> = ({entry}) => {
response.split("\n").map(paragraph => ( <p> {
paragraph.split(in_text_citation_regex).map((text, i) => {
if (i % 2 === 0) {
return <GlossaryP content={text.trim()} />;
return <GlossarySpan content={text.trim()} />;
}
i = parseInt(text) - 1;
if (!citations.has(i)) return `[${text}]`;