Add support for some #+OPTIONS toggles

see https://orgmode.org/manual/Export-settings.html
This commit is contained in:
Niklas Fasching 2018-12-26 16:58:16 +01:00
parent 5c51067b59
commit d036ddea4d
5 changed files with 120 additions and 9 deletions

View file

@ -85,6 +85,7 @@ func NewDocument() *Document {
DefaultSettings: map[string]string{
"TODO": "TODO | DONE",
"EXCLUDE_TAGS": "noexport",
"OPTIONS": "toc:t e:t f:t pri:t todo:t tags:t",
},
Log: log.New(os.Stderr, "go-org: ", 0),
}
@ -180,6 +181,24 @@ func (d *Document) Get(key string) string {
return ""
}
// 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
}
}
}
return false
}
func (d *Document) parseOne(i int, stop stopFn) (consumed int, node Node) {
switch d.tokens[i].kind {
case "unorderedList", "orderedList":