mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 12:39:49 +08:00
site: support bold for change doc (#51076)
This commit is contained in:
parent
0f30e808a2
commit
39509d4e85
@ -103,22 +103,30 @@ const ParseChangelog: React.FC<{ changelog: string }> = (props) => {
|
||||
const nodes: React.ReactNode[] = [];
|
||||
|
||||
let isQuota = false;
|
||||
let isBold = false;
|
||||
let lastStr = '';
|
||||
|
||||
for (let i = 0; i < changelog.length; i += 1) {
|
||||
const char = changelog[i];
|
||||
|
||||
if (char !== '`') {
|
||||
if (char !== '`' && char !== '*') {
|
||||
lastStr += char;
|
||||
} else {
|
||||
let node: React.ReactNode = lastStr;
|
||||
if (isQuota) {
|
||||
node = <code>{node}</code>;
|
||||
} else if (isBold) {
|
||||
node = <strong>{node}</strong>;
|
||||
}
|
||||
|
||||
nodes.push(node);
|
||||
lastStr = '';
|
||||
isQuota = !isQuota;
|
||||
if (char === '`') {
|
||||
isQuota = !isQuota;
|
||||
} else if (char === '*' && changelog[i + 1] === '*') {
|
||||
isBold = !isBold;
|
||||
i += 1; // Skip the next '*'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user