Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 0d6e410

Browse files
aQuaaQua
authored andcommitted
helper 字符替换功能,再也不用手动更换字符了
1 parent 9d8d0e3 commit 0d6e410

File tree

3 files changed

+116
-51
lines changed

3 files changed

+116
-51
lines changed

Helper/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
// 程序辅助设置
88
const (
9-
VERSION = "6.1.10"
9+
VERSION = "6.1.11"
1010
)
1111

1212
func main() {

Helper/problemReadme.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"log"
6+
"strings"
67

78
"github.com/PuerkitoBio/goquery"
89
)
@@ -22,6 +23,8 @@ func creatREADME(p problem) {
2223

2324
content := fmt.Sprintf(fileFormat, p.ID, p.Title, p.link(), questionDescription)
2425

26+
content = changeCharacter(content)
27+
2528
filename := fmt.Sprintf("%s/README.md", p.Dir())
2629

2730
write(filename, content)
@@ -42,3 +45,17 @@ func getDescription(url string) string {
4245

4346
return desc
4447
}
48+
49+
func changeCharacter(s string) string {
50+
changeMap := map[string]string{
51+
""": "\"",
52+
"&lt;": "<",
53+
"&gt;": ">",
54+
"&nbsp;": "",
55+
"\n \n": "\n",
56+
}
57+
for old, new := range changeMap {
58+
s = strings.Replace(s, old, new, -1)
59+
}
60+
return s
61+
}

0 commit comments

Comments
 (0)