diff --git a/internal/printer/html.go b/internal/printer/html.go
index 9adba5c..ff6644d 100644
--- a/internal/printer/html.go
+++ b/internal/printer/html.go
@@ -40,6 +40,7 @@ func (p Printer) convertHTMLToText(text string, wrapLines bool) string {
if wrapLines {
return p.wrapLines(builder.String(), 0)
}
+
return builder.String()
case html.TextToken:
text := token.Token().Data
diff --git a/internal/printer/wrap.go b/internal/printer/wrap.go
index 408cb03..c55b6fe 100644
--- a/internal/printer/wrap.go
+++ b/internal/printer/wrap.go
@@ -5,6 +5,7 @@
package printer
import (
+ "regexp"
"strings"
"unicode"
)
@@ -24,16 +25,13 @@ func (p Printer) wrapLines(text string, nIndent int) string {
var builder strings.Builder
- for i, line := range lines {
- extraIndent := ""
+ singleDigitListItemRegex := regexp.MustCompile(`^[0-9]{1}\.\s.*$`)
+ doubleDigitListItemRegex := regexp.MustCompile(`^[0-9]{2}\.\s.*$`)
- if strings.HasPrefix(line, symbolBullet) {
- extraIndent = " "
- }
+ for ind, line := range lines {
+ builder.WriteString(wrapLine(line, separator+extraIndent(line, singleDigitListItemRegex, doubleDigitListItemRegex), p.lineWrapCharacterLimit-nIndent))
- builder.WriteString(wrapLine(line, separator+extraIndent, p.lineWrapCharacterLimit-nIndent))
-
- if i < len(lines)-1 {
+ if ind < len(lines)-1 {
builder.WriteString(separator)
}
}
@@ -69,3 +67,19 @@ func wrapLine(line, separator string, charLimit int) string {
return builder.String()
}
+
+func extraIndent(line string, singleDigitListItemRegex, doubleDigitListItemRegex *regexp.Regexp) string {
+ if strings.HasPrefix(line, symbolBullet) {
+ return " "
+ }
+
+ if singleDigitListItemRegex.MatchString(line) {
+ return " "
+ }
+
+ if doubleDigitListItemRegex.MatchString(line) {
+ return " "
+ }
+
+ return ""
+}