Skip to content

Commit

Permalink
Fix: Answers with links to information not parsing #3839 (#3968)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Fix: Answers with links to information not parsing #3839

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
cike8899 authored Dec 10, 2024
1 parent 9a6d976 commit e0533f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
26 changes: 0 additions & 26 deletions web/reducer.js

This file was deleted.

7 changes: 5 additions & 2 deletions web/src/pages/chat/markdown-content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import { useTranslation } from 'react-i18next';

import 'katex/dist/katex.min.css'; // `rehype-katex` does not import the CSS for you

import { replaceTextByOldReg } from '../utils';
import styles from './index.less';

const reg = /(#{2}\d+\${2})/g;
const reg = /(#{2}\d+@{2})/g;
const curReg = /(~{2}\d+\${2})/g;

const getChunkIndex = (match: string) => Number(match.slice(2, -2));
Expand Down Expand Up @@ -156,7 +157,9 @@ const MarkdownContent = ({

const renderReference = useCallback(
(text: string) => {
let replacedText = reactStringReplace(text, reg, (match, i) => {
const nextText = replaceTextByOldReg(text);

let replacedText = reactStringReplace(nextText, reg, (match, i) => {
const chunkIndex = getChunkIndex(match);
return (
<Popover content={getPopoverContent(chunkIndex)} key={i}>
Expand Down
8 changes: 8 additions & 0 deletions web/src/pages/chat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ export const buildMessageItemReference = (

return reference ?? { doc_aggs: [], chunks: [], total: 0 };
};

const oldReg = /(#{2}\d+\${2})/g;

export const replaceTextByOldReg = (text: string) => {
return text.replace(oldReg, function (substring) {
return `${substring.slice(0, -2)}@@`;
});
};

0 comments on commit e0533f1

Please sign in to comment.