@@ -16,7 +16,7 @@ import (
1616
1717var (
1818 chapterOneFileOrder = []string {"_index" , "Data_Structure" , "Algorithm" , "Time_Complexity" }
19- chapterOneMenuOrder = []string {"_index" , "#关于作者 " , "Data_Structure" , "Algorithm" , "Time_Complexity" }
19+ chapterOneMenuOrder = []string {"_index" , "#about the author " , "Data_Structure" , "Algorithm" , "Time_Complexity" }
2020 chapterTwoFileOrder = []string {"_index" , "Array" , "String" , "Two_Pointers" , "Linked_List" , "Stack" , "Tree" , "Dynamic_Programming" , "Backtracking" , "Depth_First_Search" , "Breadth_First_Search" ,
2121 "Binary_Search" , "Math" , "Hash_Table" , "Sorting" , "Bit_Manipulation" , "Union_Find" , "Sliding_Window" , "Segment_Tree" , "Binary_Indexed_Tree" }
2222 chapterThreeFileOrder = []string {"_index" , "Segment_Tree" , "UnionFind" , "LRUCache" , "LFUCache" }
@@ -35,13 +35,13 @@ var (
3535
3636 chapterMap = map [string ]map [string ]string {
3737 "ChapterOne" : {
38- "_index" : "第一章 序章 " ,
39- "Data_Structure" : "1.1 数据结构知识 " ,
40- "Algorithm" : "1.2 算法知识 " ,
41- "Time_Complexity" : "1.3 时间复杂度 " ,
38+ "_index" : "Chapter 1 Prologue " ,
39+ "Data_Structure" : "1.1 Data structure knowledge " ,
40+ "Algorithm" : "1.2 Algorithm knowledge " ,
41+ "Time_Complexity" : "1.3 Time Complexity " ,
4242 },
4343 "ChapterTwo" : {
44- "_index" : "第二章 算法专题 " ,
44+ "_index" : "Chapter 2 Algorithms Topics " ,
4545 "Array" : "2.01 Array" ,
4646 "String" : "2.02 String" ,
4747 "Two_Pointers" : "2.03 ✅ Two Pointers" ,
@@ -63,14 +63,14 @@ var (
6363 "Binary_Indexed_Tree" : "2.19 ✅ Binary Indexed Tree" ,
6464 },
6565 "ChapterThree" : {
66- "_index" : "第三章 一些模板 " ,
66+ "_index" : "Chapter 3 Some Templates " ,
6767 "Segment_Tree" : "3.1 Segment Tree" ,
6868 "UnionFind" : "3.2 UnionFind" ,
6969 "LRUCache" : "3.3 LRUCache" ,
7070 "LFUCache" : "3.4 LFUCache" ,
7171 },
7272 "ChapterFour" : {
73- "_index" : "第四章 Leetcode 题解 " ,
73+ "_index" : "Chapter 4 Leetcode Solution " ,
7474 },
7575 }
7676)
@@ -79,7 +79,7 @@ func getChapterFourFileOrder() ([]string, []int) {
7979 solutions , solutionIds := util .LoadChapterFourDir ()
8080 chapterFourFileOrder := []string {"_index" }
8181 chapterFourFileOrder = append (chapterFourFileOrder , solutions ... )
82- fmt .Printf ("ChapterFour 中包括 _index 有 %v 个文件 , len(id) = %v\n " , len (chapterFourFileOrder ), len (solutionIds ))
82+ fmt .Printf ("There are %v files in ChapterFour including _index , len(id) = %v\n " , len (chapterFourFileOrder ), len (solutionIds ))
8383 return chapterFourFileOrder , solutionIds
8484}
8585
@@ -146,33 +146,33 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
146146 tmp := ""
147147 if index == 0 {
148148 if chapter == "ChapterOne" {
149- // 第一页不需要“上一章”
150- tmp = "\n \n " + delLine + fmt .Sprintf ("<p align = \" right\" ><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >下一页 ➡️</a></p>\n " , chapter , order [index + 1 ])
149+ // The first page does not need a "previous chapter"
150+ tmp = "\n \n " + delLine + fmt .Sprintf ("<p align = \" right\" ><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >next page ➡️</a></p>\n " , chapter , order [index + 1 ])
151151 } else {
152152 if chapter == "ChapterFour" {
153- tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️上一章 </a></p>\n " , preChapter , preOrder [len (preOrder )- 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >下一页 ➡️</a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )+ 1 ]), order [index + 1 ]) + preNextFotter
153+ tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️previous chapter </a></p>\n " , preChapter , preOrder [len (preOrder )- 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >Next page ➡️</a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )+ 1 ]), order [index + 1 ]) + preNextFotter
154154 } else {
155- tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️上一章 </a></p>\n " , preChapter , preOrder [len (preOrder )- 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >下一页 ➡️</a></p>\n " , chapter , order [index + 1 ]) + preNextFotter
155+ tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️previous chapter </a></p>\n " , preChapter , preOrder [len (preOrder )- 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >next page ➡️</a></p>\n " , chapter , order [index + 1 ]) + preNextFotter
156156 }
157157 }
158158 } else if index == len (order )- 1 {
159159 if chapter == "ChapterFour" {
160- // 最后一页不需要“下一页”
161- tmp = "\n \n " + delLine + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >⬅️上一页 </a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )- 1 ]), order [index - 1 ])
160+ // Last page doesn't need "next page"
161+ tmp = "\n \n " + delLine + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >⬅️previous page </a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )- 1 ]), order [index - 1 ])
162162 } else {
163- tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️上一页 </a></p>\n " , chapter , order [index - 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/\" >下一章 ➡️</a></p>\n " , nextChapter ) + preNextFotter
163+ tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️previous page </a></p>\n " , chapter , order [index - 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/\" >next chapter ➡️</a></p>\n " , nextChapter ) + preNextFotter
164164 }
165165 } else if index == 1 {
166166 if chapter == "ChapterFour" {
167- tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/\" >⬅️上一页 </a></p>\n " , chapter ) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >下一页 ➡️</a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )+ 1 ]), order [index + 1 ]) + preNextFotter
167+ tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/\" >⬅️previous page </a></p>\n " , chapter ) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >next page ➡️</a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )+ 1 ]), order [index + 1 ]) + preNextFotter
168168 } else {
169- tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/\" >⬅️上一页 </a></p>\n " , chapter ) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >下一页 ➡️</a></p>\n " , chapter , order [index + 1 ]) + preNextFotter
169+ tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/\" >⬅️previous page </a></p>\n " , chapter ) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >next page ➡️</a></p>\n " , chapter , order [index + 1 ]) + preNextFotter
170170 }
171171 } else {
172172 if chapter == "ChapterFour" {
173- tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >⬅️上一页 </a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )- 1 ]), order [index - 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >下一页 ➡️</a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )+ 1 ]), order [index + 1 ]) + preNextFotter
173+ tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >⬅️previous page </a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )- 1 ]), order [index - 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/%v/\" >next page ➡️</a></p>\n " , chapter , util .GetChpaterFourFileNum (chapterFourIds [(index - 1 )+ 1 ]), order [index + 1 ]) + preNextFotter
174174 } else {
175- tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️上一页 </a></p>\n " , chapter , order [index - 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >下一页 ➡️</a></p>\n " , chapter , order [index + 1 ]) + preNextFotter
175+ tmp = "\n \n " + preNextHeader + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >⬅️previous page </a></p>\n " , chapter , order [index - 1 ]) + fmt .Sprintf ("<p><a href=\" https://books.halfrost.com/leetcode/%v/%v/\" >next page ➡️</a></p>\n " , chapter , order [index + 1 ]) + preNextFotter
176176 }
177177 }
178178
@@ -185,7 +185,7 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
185185 fmt .Println (err )
186186 return
187187 }
188- // 当前没有上一页和下一页,才添加
188+ // There is no previous page and next page, just add
189189 if ! exist && err == nil {
190190 res , err = eofAdd (fmt .Sprintf ("../website/content/%v/%v.md" , chapter , path ), tmp )
191191 if err != nil {
@@ -196,7 +196,7 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
196196 count ++
197197 }
198198 }
199- fmt .Printf ("添加了 %v 个文件的 pre-next\n " , count )
199+ fmt .Printf ("Added pre-next of %v files \n " , count )
200200}
201201
202202func eofAdd (filePath string , labelString string ) ([]byte , error ) {
@@ -250,14 +250,14 @@ func delPreNextLabel(order []string, chapterFourIds []int, chapter string) {
250250 fmt .Println (err )
251251 return
252252 }
253- // 存在才删除
253+ // Delete only if it exists
254254 if exist && err == nil {
255255 removeLine (fmt .Sprintf ("../website/content/%v/%v.md" , chapter , path ), lineNum + 1 )
256256 count ++
257257 }
258258 }
259- fmt .Printf ("删除了 %v 个文件的 pre-next\n " , count )
260- // 另外一种删除方法
259+ fmt .Printf ("Deleted pre-next of %v files \n " , count )
260+ // another way to delete
261261 // res, err := eofDel(fmt.Sprintf("../website/content/ChapterOne/%v.md", v))
262262 // if err != nil {
263263 // fmt.Println(err)
0 commit comments