Skip to content

Commit

Permalink
fix(BulletList): indentation does not work when the item has a linebr…
Browse files Browse the repository at this point in the history
…eak (#589)
  • Loading branch information
MarvinJWendt committed Nov 22, 2023
1 parent 6a494f9 commit 4d9914e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bulletlist_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,18 @@ func (l BulletListPrinter) Srender() (string, error) {
item.BulletStyle = l.BulletStyle
}
}
if item.Bullet == "" {
ret += strings.Repeat(" ", item.Level) + item.BulletStyle.Sprint(l.Bullet) + " " + item.TextStyle.Sprint(item.Text) + "\n"
} else {
ret += strings.Repeat(" ", item.Level) + item.BulletStyle.Sprint(item.Bullet) + " " + item.TextStyle.Sprint(item.Text) + "\n"

split := strings.Split(item.Text, "\n")
for i, line := range split {
if i == 0 {
if item.Bullet == "" {
ret += strings.Repeat(" ", item.Level) + item.BulletStyle.Sprint(l.Bullet) + " " + item.TextStyle.Sprint(line) + "\n"
} else {
ret += strings.Repeat(" ", item.Level) + item.BulletStyle.Sprint(item.Bullet) + " " + item.TextStyle.Sprint(line) + "\n"
}
} else {
ret += strings.Repeat(" ", item.Level) + strings.Repeat(" ", len(item.Bullet)) + " " + item.TextStyle.Sprint(line) + "\n"
}
}
}
return ret, nil
Expand Down

0 comments on commit 4d9914e

Please sign in to comment.