diff --git a/org/drawer.go b/org/drawer.go index ce22564..8bb9974 100644 --- a/org/drawer.go +++ b/org/drawer.go @@ -67,6 +67,9 @@ func (d *Document) parsePropertyDrawer(i int, parentStop stopFn) (int, Node) { } for ; !stop(d, i); i++ { m := propertyRegexp.FindStringSubmatch(d.tokens[i].matches[0]) + if m == nil { + return 0, nil + } k, v := strings.ToUpper(m[2]), strings.TrimSpace(m[4]) drawer.Properties = append(drawer.Properties, []string{k, v}) } diff --git a/org/testdata/headlines.html b/org/testdata/headlines.html index c9d0cf6..310bdfb 100644 --- a/org/testdata/headlines.html +++ b/org/testdata/headlines.html @@ -12,6 +12,8 @@
  • excluded headline
  • +
  • malformed property drawer +
  • @@ -76,3 +78,13 @@ it's possible to use #+SETUPFILE - in this cas +

    +malformed property drawer +

    +

    +:PROPERTIES: +not a property +

    +

    +:END: +

    diff --git a/org/testdata/headlines.org b/org/testdata/headlines.org index 1909921..1cbf9b8 100644 --- a/org/testdata/headlines.org +++ b/org/testdata/headlines.org @@ -27,3 +27,7 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains the fo this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag. By default =EXCLUDE_TAGS= is just =:noexport:=. +* malformed property drawer +:PROPERTIES: +not a property +:END: diff --git a/org/testdata/headlines.pretty_org b/org/testdata/headlines.pretty_org index 0f22cac..7fb00bd 100644 --- a/org/testdata/headlines.pretty_org +++ b/org/testdata/headlines.pretty_org @@ -27,3 +27,7 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains the fo this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag. By default =EXCLUDE_TAGS= is just =:noexport:=. +* malformed property drawer +:PROPERTIES: +not a property +:END: diff --git a/org/testdata/misc.html b/org/testdata/misc.html index 2a308cc..bc3fd0a 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -145,6 +145,11 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains th * excluded headline :custom_noexport: this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag. By default =EXCLUDE_TAGS= is just =:noexport:=. + +* malformed property drawer +:PROPERTIES: +not a property +:END: