Skip to content

Commit 936faaa

Browse files
committed
fix: escaping markdown
1 parent b2c1a3c commit 936faaa

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

documentation/Standard-Lib.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Standard Library Cheatsheet
66

7-
Last updated: Mon, 30 Dec 2019 12:00:50 GMT
7+
Last updated: Mon, 30 Dec 2019 12:04:13 GMT
88

99

1010
## Usage
@@ -52,7 +52,7 @@ Last updated: Mon, 30 Dec 2019 12:00:50 GMT
5252
| [`右移`](../lib/js/位經.wy#L6) | `x>>y` |
5353
| [`補零右移`](../lib/js/位經.wy#L11) | `x>>>y` |
5454
| [`位与`](../lib/js/位經.wy#L16) | `x&y` |
55-
| [`位或`](../lib/js/位經.wy#L21) | `x|y` |
55+
| [`位或`](../lib/js/位經.wy#L21) | `x\|y` |
5656
| [`异或`](../lib/js/位經.wy#L26) | `x^y` |
5757
| [`与非`](../lib/js/位經.wy#L31) | `~(x&y)` |
5858
| [`位變`](../lib/js/位經.wy#L36) | `~x` |

tools/stdlib_doc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ to update the document.
4444
Then you can submit a pull request. Thank you!
4545
`;
4646

47+
function escapeMarkdown(text) {
48+
return text.replace(/\|/g, "\\|").replace(/`/g, "\\`");
49+
}
50+
4751
function getLineIndexes(text) {
4852
let previous = 0;
4953
var lines = [];
@@ -88,7 +92,8 @@ function readFile(filepath, relativePath) {
8892
markdown += `| Wenyan | Javascript Equivalent |\n|---|---|\n`;
8993

9094
for (const { wenyan, js, line } of results) {
91-
markdown += `| [\`${wenyan}\`](${GithubPath}#L${line + 1}) | \`${js}\` |\n`;
95+
markdown += `| [\`${escapeMarkdown(wenyan)}\`](${GithubPath}#L${line +
96+
1}) | \`${escapeMarkdown(js)}\` |\n`;
9297
}
9398

9499
return markdown + "\n";

0 commit comments

Comments
 (0)