File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -103,8 +103,8 @@ func firstBulletPointsToParagraphs(from string) string {
103103 return regexp .MustCompile (`(?m:^- )` ).ReplaceAllString (from , "\n " )
104104}
105105
106- func removeTabFromMultiLevelBulletPoints (from string ) string {
107- return regexp .MustCompile (`(?m:^\t{1,}- )` ).ReplaceAllStringFunc (from , func (s string ) string {
106+ func unindentAllRemainingBulletPoints (from string ) string {
107+ return regexp .MustCompile (`(?m:^\t{1,}[^\t] )` ).ReplaceAllStringFunc (from , func (s string ) string {
108108 return s [1 :]
109109 })
110110}
@@ -148,7 +148,10 @@ func parseContent(rawContent string) parsedContent {
148148 removeEmptyBulletPoints ,
149149 unindentMultilineStrings ,
150150 firstBulletPointsToParagraphs ,
151- removeTabFromMultiLevelBulletPoints ,
151+ // since we turned the first bullet points to paragraphs
152+ // we shift all bullet points by one tab to the left
153+ // including subsequent lines for multiline strings
154+ unindentAllRemainingBulletPoints ,
152155 )
153156 return parsedContent {
154157 attributes : parseAttributes (rawContent ),
Original file line number Diff line number Diff line change @@ -161,6 +161,30 @@ func TestParseContent(t *testing.T) {
161161 result := parseContent ("\t \t - hello\n \t \t \t - world" )
162162 require .Equal (t , "\t - hello\n \t \t - world" , result .content )
163163 })
164+
165+ t .Run ("handles fenced blocks in second-level bullet points" , func (t * testing.T ) {
166+ result := parseContent (`
167+ - ## If statement
168+ - ~~~bash
169+ if [-a file];then
170+ ...
171+ else
172+ ...
173+ fi
174+ ~~~
175+ ` )
176+ require .Equal (t , `
177+ ## If statement
178+ - ~~~bash
179+ if [-a file];then
180+ ...
181+ else
182+ ...
183+ fi
184+ ~~~
185+ ` , result .content )
186+ })
187+
164188 t .Run ("removes tabs from all subsequent lines of a bullet point" , func (t * testing.T ) {
165189 result := parseContent (`
166190- ~~~ts
You can’t perform that action at this time.
0 commit comments