diff --git a/README.org b/README.org index 0d123fe..ebb9d70 100644 --- a/README.org +++ b/README.org @@ -7,9 +7,6 @@ Take a look at [[https://niklasfasching.github.io/go-org/][github pages]] for so - more keywords: https://orgmode.org/manual/In_002dbuffer-settings.html - headlines - unique ids: see [[https://github.com/kaushalmodi/ox-hugo/blob/8472cf2d8667754c9da3728255634e8001a1da6d/ox-hugo.el#L1785-L1850][ox-hugo]] for auto generation -- improve list parsing - - handle list items with empty first line - - handle ordered list overrides [@10] ** links https://orgmode.org/manual/External-links.html https://orgmode.org/manual/Internal-links.html diff --git a/org/list.go b/org/list.go index e4265dc..63f89b4 100644 --- a/org/list.go +++ b/org/list.go @@ -25,16 +25,16 @@ type DescriptiveListItem struct { Details []Node } -var unorderedListRegexp = regexp.MustCompile(`^(\s*)([+*-])\s(.*)`) -var orderedListRegexp = regexp.MustCompile(`^(\s*)(([0-9]+|[a-zA-Z])[.)])\s+(.*)`) +var unorderedListRegexp = regexp.MustCompile(`^(\s*)([+*-])(\s+(.*)|\s*$)`) +var orderedListRegexp = regexp.MustCompile(`^(\s*)(([0-9]+|[a-zA-Z])[.)])(\s+(.*)|\s*$)`) var descriptiveListItemRegexp = regexp.MustCompile(`\s::(\s|$)`) var listItemStatusRegexp = regexp.MustCompile(`\[( |X|-)\]\s`) func lexList(line string) (token, bool) { if m := unorderedListRegexp.FindStringSubmatch(line); m != nil { - return token{"unorderedList", len(m[1]), m[3], m}, true + return token{"unorderedList", len(m[1]), m[4], m}, true } else if m := orderedListRegexp.FindStringSubmatch(line); m != nil { - return token{"orderedList", len(m[1]), m[4], m}, true + return token{"orderedList", len(m[1]), m[5], m}, true } return nilToken, false } diff --git a/org/testdata/lists.html b/org/testdata/lists.html index 4970e90..9729362 100644 --- a/org/testdata/lists.html +++ b/org/testdata/lists.html @@ -6,6 +6,12 @@ unordered list item 1
+list item with empty first and second line
+normally an empty line breaks the list item - but we make an exception for the first line and don't count it towards that limit
+
unordered list item 2 - with inline
markup
+list item with empty first and second line - see above +
+