File size: 365 Bytes
755dd12
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
/**
 * 解析返回回答中的引用标记[[citation:\d+]]
 * @param text 
 */
export const citationMarkdownParse = (text: string) => {
  return text
    .replace(/\[\[([cC])itation/g, "[citation")
    .replace(/[cC]itation:(\d+)]]/g, "citation:$1]")
    .replace(/\[\[([cC]itation:\d+)]](?!])/g, `[$1]`)
    .replace(/\[[cC]itation:(\d+)]/g, "[citation]($1)");
};