diff --git a/org/document.go b/org/document.go
index 9e60dc6..0d9ab8f 100644
--- a/org/document.go
+++ b/org/document.go
@@ -146,20 +146,27 @@ func (d *Document) Get(key string) string {
// see https://orgmode.org/manual/Export-settings.html
func (d *Document) GetOption(key string) bool {
- for _, field := range strings.Fields(d.Get("OPTIONS")) {
- if strings.HasPrefix(field, key) {
- switch field[len(key)+len(":"):] {
- case "t":
- return true
- case "nil":
- return false
- default:
- d.Log.Printf("Bad value for export option %s (%s)", key, field)
- return false
+ get := func(settings map[string]string) string {
+ for _, field := range strings.Fields(settings["OPTIONS"]) {
+ if strings.HasPrefix(field, key+":") {
+ return field[len(key)+1:]
}
}
+ return ""
+ }
+ value := get(d.BufferSettings)
+ if value == "" {
+ value = get(d.DefaultSettings)
+ }
+ switch value {
+ case "t":
+ return true
+ case "nil":
+ return false
+ default:
+ d.Log.Printf("Bad value for export option %s (%s)", key, value)
+ return false
}
- return false
}
func (d *Document) parseOne(i int, stop stopFn) (consumed int, node Node) {
diff --git a/org/testdata/options.html b/org/testdata/options.html
index ccf7074..0902d83 100644
--- a/org/testdata/options.html
+++ b/org/testdata/options.html
@@ -1,13 +1,15 @@
-#+OPTIONS:
toggles supported by go-org
+DONE
+[A]
+#+OPTIONS:
toggles supported by go-org
tag1 tag2
-go-org
supports multiple export toggles as described in the export settings Org mode manual.
-By default those toggles are enabled. This files starts with #+OPTIONS:
(empty options) and thus
-disables all settings.
+go-org
supports multiple export toggles as described in the export settings section of the Org mode manual.
+By default (most of?) those toggles are enabled. This file starts with #+OPTIONS: toc:nil f:nil e:nil
and thus
+disables the table of contents, footnotes & entities.
That means, entities like ---
--- (mdash) will be left untouched, footnotes like [fn:1]
will
not be exported and there won't be a table of contents at the top.
-Also, the above headline will be exported without priority, todo status & tags.
+As buffer options are merged with the defaults, the above headline will be exported with priority, todo status & tags.
diff --git a/org/testdata/options.org b/org/testdata/options.org
index 4fa4d7f..6042cb9 100644
--- a/org/testdata/options.org
+++ b/org/testdata/options.org
@@ -1,12 +1,12 @@
-#+OPTIONS:
+#+OPTIONS: toc:nil f:nil e:nil
* DONE [#A] =#+OPTIONS:= toggles supported by =go-org= :tag1:tag2:
-=go-org= supports multiple export toggles as described in the [[https://orgmode.org/manual/Export-settings.html][export settings]] Org mode manual.
-By default those toggles are enabled. This files starts with =#+OPTIONS:= (empty options) and thus
-disables all settings.
+=go-org= supports multiple export toggles as described in the [[https://orgmode.org/manual/Export-settings.html][export settings]] section of the Org mode manual.
+By default (most of?) those toggles are enabled. This file starts with =#+OPTIONS: toc:nil f:nil e:nil= and thus
+disables the table of contents, footnotes & entities.
That means, entities like =---= --- (mdash) will be left untouched, footnotes like =[fn:1]= [fn:1] will
not be exported and there won't be a table of contents at the top.
-Also, the above headline will be exported without priority, todo status & tags.
+As buffer options are merged with the defaults, the above headline will be exported *with* priority, todo status & tags.
| key | description |
diff --git a/org/testdata/options.pretty_org b/org/testdata/options.pretty_org
index 43b0001..aecc9d2 100644
--- a/org/testdata/options.pretty_org
+++ b/org/testdata/options.pretty_org
@@ -1,12 +1,12 @@
-#+OPTIONS:
+#+OPTIONS: toc:nil f:nil e:nil
* DONE [#A] =#+OPTIONS:= toggles supported by =go-org= :tag1:tag2:
-=go-org= supports multiple export toggles as described in the [[https://orgmode.org/manual/Export-settings.html][export settings]] Org mode manual.
-By default those toggles are enabled. This files starts with =#+OPTIONS:= (empty options) and thus
-disables all settings.
+=go-org= supports multiple export toggles as described in the [[https://orgmode.org/manual/Export-settings.html][export settings]] section of the Org mode manual.
+By default (most of?) those toggles are enabled. This file starts with =#+OPTIONS: toc:nil f:nil e:nil= and thus
+disables the table of contents, footnotes & entities.
That means, entities like =---= --- (mdash) will be left untouched, footnotes like =[fn:1]= [fn:1] will
not be exported and there won't be a table of contents at the top.
-Also, the above headline will be exported without priority, todo status & tags.
+As buffer options are merged with the defaults, the above headline will be exported *with* priority, todo status & tags.
| key | description |