Refactor: Return string value from GetOption
Turns out org export options can have meaningful values beside true and false - let's make it possible to use them.
This commit is contained in:
parent
614307a8f5
commit
7a2cd1abb1
2 changed files with 13 additions and 17 deletions
|
@ -174,7 +174,7 @@ func (d *Document) Get(key string) string {
|
|||
// - pri (export headline priority)
|
||||
// - tags (export headline tags)
|
||||
// see https://orgmode.org/manual/Export-settings.html for more information
|
||||
func (d *Document) GetOption(key string) bool {
|
||||
func (d *Document) GetOption(key string) string {
|
||||
get := func(settings map[string]string) string {
|
||||
for _, field := range strings.Fields(settings["OPTIONS"]) {
|
||||
if strings.HasPrefix(field, key+":") {
|
||||
|
@ -187,15 +187,11 @@ func (d *Document) GetOption(key string) bool {
|
|||
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
|
||||
if value == "" {
|
||||
value = "nil"
|
||||
d.Log.Printf("Missing value for export option %s", key)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func (d *Document) parseOne(i int, stop stopFn) (consumed int, node Node) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue