present: allow line-wrapping of bullet list items
This is not strictly necessary, but being able to wrap these long lines
helps make the diffs for the Markdown conversion of old files easier to read.
The wrapping of the blog is in CL 222839.
For golang/go#33955.
Change-Id: I26c3f8db6b137c194f03b2538f221aa4fc3f2324
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222843
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/present/doc.go b/present/doc.go
index ff75d66..e12e985 100644
--- a/present/doc.go
+++ b/present/doc.go
@@ -44,7 +44,8 @@
- bullets
- more bullets
- - a bullet with
+ - a bullet continued
+ on the next line
*** Sub-subsection
diff --git a/present/parse.go b/present/parse.go
index 98baec7..35de0dd 100644
--- a/present/parse.go
+++ b/present/parse.go
@@ -376,9 +376,17 @@
e = Text{Lines: []string{pre}, Pre: true}
case strings.HasPrefix(text, "- "):
var b []string
- for ok && strings.HasPrefix(text, "- ") {
- b = append(b, text[2:])
- text, ok = lines.next()
+ for {
+ if strings.HasPrefix(text, "- ") {
+ b = append(b, text[2:])
+ } else if len(b) > 0 && strings.HasPrefix(text, " ") {
+ b[len(b)-1] += "\n" + strings.TrimSpace(text)
+ } else {
+ break
+ }
+ if text, ok = lines.next(); !ok {
+ break
+ }
}
lines.back()
e = List{Bullet: b}