Skip to content

Commit

Permalink
Initialize accoutrement right before filling them
Browse files Browse the repository at this point in the history
Signed-off-by: Sandy <sandy@sandyuraz.com>
  • Loading branch information
thecsw committed Dec 27, 2022
1 parent ea287b9 commit e42ea07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions emilia/accoutrement.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ func InitializeAccoutrement(page *yunyun.Page) {
}

// FillAccoutrement parses `options` and fills the `target`.
func FillAccoutrement(options *string, target *yunyun.Accoutrement) {
func FillAccoutrement(options *string, page *yunyun.Page) {
// Exit immediately if it's an empty string.
if len(*options) < 1 {
return
}
// Let's first initialize it before filling.
InitializeAccoutrement(page)
for _, option := range strings.Split(*options, " ") {
elements := strings.SplitN(option, ":", 2)
key := gana.First(elements)
Expand All @@ -53,7 +55,7 @@ func FillAccoutrement(options *string, target *yunyun.Accoutrement) {
}
// If action is found, then execute it.
if action, ok := accotrementActions[key]; ok {
action(value, target)
action(value, page.Accoutrement)
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions parse/orgmode/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ func (p ParserOrgmode) Parse() *yunyun.Page {
// optionsStrings will get populated as the page is being scanned
// and then parsed out before leaving this parser.
optionsStrings := ""
emilia.InitializeAccoutrement(page)
defer emilia.FillAccoutrement(&optionsStrings, page.Accoutrement)
defer emilia.FillAccoutrement(&optionsStrings, page)

// Optional parsing to see if H.E. has been left on the first line
// as the date
Expand Down

0 comments on commit e42ea07

Please sign in to comment.