@@ -51,7 +51,9 @@ type questionType struct {
5151 Dislikes int `json:"dislikes"`
5252 IsLiked int `json:"isLiked"`
5353 SimilarQuestions string `json:"similarQuestions"`
54+ TopicTags []tagType `json:"topicTags"`
5455 CodeSnippets []codeSnippetsType `json:"codeSnippets"`
56+ Hints []string `json:"hints"`
5557}
5658
5759type codeSnippetsType struct {
@@ -82,11 +84,26 @@ func (question questionType) getDescContent() []byte {
8284 buf .WriteString ("<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->" )
8385 buf .WriteString (authInfo )
8486 buf .WriteString (fmt .Sprintf ("\n ## %s. %s%s\n \n " , question .QuestionFrontendId , question .Title , question .Difficulty ))
85- //remove style
87+ // remove style
8688 reg , err := regexp .Compile (`<style[\S\s]+?</style>` )
8789 checkErr (err )
8890 buf .WriteString (reg .ReplaceAllString (question .Content , "" ))
91+ buf .Write (question .getTopicTags ())
8992 buf .Write (question .getSimilarQuestion ())
93+ buf .Write (question .getHints ())
94+ return buf .Bytes ()
95+ }
96+
97+ func (question questionType ) getTopicTags () []byte {
98+ tags := question .TopicTags
99+ var buf bytes.Buffer
100+ if len (tags ) > 0 {
101+ buf .WriteString ("\n \n ### Related Topics\n " )
102+ }
103+ format := "[[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)] "
104+ for _ , tag := range tags {
105+ buf .WriteString (fmt .Sprintf (format , tag .Name , tag .Slug ))
106+ }
90107 return buf .Bytes ()
91108}
92109
@@ -109,6 +126,18 @@ func (question questionType) getSimilarQuestion() []byte {
109126 return buf .Bytes ()
110127}
111128
129+ func (question questionType ) getHints () []byte {
130+ hints := question .Hints
131+ var buf bytes.Buffer
132+ if len (hints ) > 0 {
133+ buf .WriteString ("\n ### Hints\n " )
134+ }
135+ for _ , hint := range hints {
136+ buf .WriteString (fmt .Sprintf (" 1. %s\n " , hint ))
137+ }
138+ return buf .Bytes ()
139+ }
140+
112141func (question questionType ) getFilePath (filename string ) string {
113142 return path .Join ("problems" , question .TitleSlug , filename )
114143}
0 commit comments