Skip to content

Commit

Permalink
Added a flag for footnote square brackets
Browse files Browse the repository at this point in the history
Signed-off-by: Sandy <sandy@sandyuraz.com>
  • Loading branch information
thecsw committed Jun 14, 2022
1 parent 51d4cda commit f15e587
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions emilia/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type WebsiteConfig struct {
NormalizeHeadings bool `toml:"normalize_headings"`
// RomanFootnotes tells if we have to use roman numerals for footnotes
RomanFootnotes bool `toml:"roman_footnotes"`
// FootnoteBrackets decides whether to use brackets on footnotes
FootnoteBrackets bool `toml:"footnote_brackets"`
}

// AuthorConfig is the author section of the config
Expand Down
14 changes: 11 additions & 3 deletions html/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@ func processText(text string) string {

text = internals.FootnotePostProcessingRegexp.ReplaceAllStringFunc(text, func(what string) string {
num, _ := strconv.Atoi(strings.ReplaceAll(what, "!", ""))
return fmt.Sprintf(`
<sup class="footnote">[<a id="_footnoteref_%d" class="footnote" href="#_footnotedef_%d" title="View footnote.">%s</a>]</sup>
`, num, num, footnoteLabel(num))
// get the footnote HTML body
footnote := fmt.Sprintf(
`<a id="_footnoteref_%d" class="footnote" href="#_footnotedef_%d" title="View footnote.">%s</a>`,
num, num, footnoteLabel(num))
// Decide if we need to wrap the footnote in square brackets
if emilia.Config.Website.FootnoteBrackets {
footnote = "[" + footnote + "]"
}
return `
<sup class="footnote">` + footnote + `</sup>
`
})

return strings.TrimSpace(text)
Expand Down
2 changes: 2 additions & 0 deletions ishmael/darkness.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ description_length = 137
normalize_headings = false
# Roman Footnotes tells if we have to use roman numerals for footnotes
roman_footnotes = true
# Decide whether to use brackets on footnotes
footnote_brackets = true

# This is the author header section
[author]
Expand Down

0 comments on commit f15e587

Please sign in to comment.