diff --git a/ui/src/components/search/ResultItem.tsx b/ui/src/components/search/ResultItem.tsx index 7f09a8d3b..30379b179 100644 --- a/ui/src/components/search/ResultItem.tsx +++ b/ui/src/components/search/ResultItem.tsx @@ -1,11 +1,9 @@ import React from "react"; -import ReactHtmlParser from "react-html-parser"; -import { MathJax } from "better-react-mathjax"; import { ArticleIdentifier, Result } from "@/types"; import PublicationInfo from "../shared/PublicationInfo"; import Authors from "../shared/Authors"; -import { resolveIdentifierLink } from "@/utils/utils"; +import { cleanText, renderComplexSytnax, resolveIdentifierLink } from "@/utils/utils"; import FulltextFiles from "../shared/FulltextFiles"; interface ResultItemProps { @@ -27,7 +25,11 @@ const ResultItem: React.FC = ({ article }) => { return (
  • - {ReactHtmlParser(article?.title)} +
    @@ -36,9 +38,10 @@ const ResultItem: React.FC = ({ article }) => { - {article?.publication_date}
    -

    - {ReactHtmlParser(article?.abstract)} -

    +

    Published in: diff --git a/ui/src/components/search/SearchResults.tsx b/ui/src/components/search/SearchResults.tsx index 1ab444d5c..9845d5212 100644 --- a/ui/src/components/search/SearchResults.tsx +++ b/ui/src/components/search/SearchResults.tsx @@ -57,9 +57,9 @@ const SearchResults: React.FC = ({ onChange={sortResults} defaultValue="_updated_at" > -
    + -
    +
    )} diff --git a/ui/src/pages/records/[recordId].tsx b/ui/src/pages/records/[recordId].tsx index 0fcffc74a..9467d5f9f 100644 --- a/ui/src/pages/records/[recordId].tsx +++ b/ui/src/pages/records/[recordId].tsx @@ -1,12 +1,10 @@ import React from "react"; -import ReactHtmlParser from "react-html-parser"; import { GetServerSideProps } from "next"; -import { MathJax } from "better-react-mathjax"; import { Result } from "@/types"; import Authors from "@/components/shared/Authors"; import DetailPageInfo from "@/components/detail/DetailPageInfo"; -import { authToken, getApiUrl } from "@/utils/utils"; +import { authToken, cleanText, getApiUrl, renderComplexSytnax } from "@/utils/utils"; import { JsonPreview } from "@/components/shared/JsonPreview"; interface RecordPageProps { @@ -17,27 +15,31 @@ const RecordPage: React.FC = ({ article }) => { return (
    -
    -
    -

    - {ReactHtmlParser(article?.title)} -

    - -

    - {ReactHtmlParser(article?.abstract)} -

    -
    +
    +

    + +

    -
    +
    -
    +
    diff --git a/ui/src/utils/utils.tsx b/ui/src/utils/utils.tsx index 288d46589..82f014d1f 100644 --- a/ui/src/utils/utils.tsx +++ b/ui/src/utils/utils.tsx @@ -1,3 +1,5 @@ +import ReactHtmlParser from "react-html-parser"; + import { ArticleIdentifier, Params, QueryType, queryTypes } from "@/types"; import { Token } from "../../token"; @@ -65,4 +67,14 @@ const resolveIdentifierLink = (identifier: ArticleIdentifier) => { } }; -export { getSearchUrl, getApiUrl, resolveIdentifierLink }; + // strip

    and tags to resolve errors:

    cannot appear as a descendant of

    and is not a valid tag. + const cleanText = (text: string) => text.replace(/<\/?(p|italic|sup|i|)>/g, "") ?? ""; + + const renderComplexSytnax = (abstract: string) => { + if (abstract.includes("