Improve footnote handling
- Footnotes separator rather than headline to get around i18n - Warn on footnote redefinition - Do not export footnote definitions at point of definition, only in the footnote section. - Do not automatically exclude Footnotes section to get around possibly hiding other content of such a section - and i18n. The user has the choice of explicitly hiding the section via a :noexport: tag. and some other refactoring
This commit is contained in:
parent
beff0c0d8a
commit
eb7db9b968
11 changed files with 114 additions and 60 deletions
|
@ -14,7 +14,7 @@ type Document struct {
|
|||
Path string
|
||||
tokens []token
|
||||
Nodes []Node
|
||||
Footnotes *Footnotes
|
||||
Footnotes Footnotes
|
||||
StatusKeywords []string
|
||||
MaxEmphasisNewLines int
|
||||
AutoLink bool
|
||||
|
@ -72,7 +72,7 @@ func FrontMatterHandler(fm FrontMatter, k, v string) error {
|
|||
|
||||
func NewDocument() *Document {
|
||||
return &Document{
|
||||
Footnotes: &Footnotes{
|
||||
Footnotes: Footnotes{
|
||||
Title: "Footnotes",
|
||||
Definitions: map[string]*FootnoteDefinition{},
|
||||
},
|
||||
|
@ -222,6 +222,16 @@ func (d *Document) parseMany(i int, stop stopFn) (int, []Node) {
|
|||
return i - start, nodes
|
||||
}
|
||||
|
||||
func (d *Document) addFootnote(name string, definition *FootnoteDefinition) {
|
||||
if definition != nil {
|
||||
if _, exists := d.Footnotes.Definitions[name]; exists {
|
||||
d.Log.Printf("Footnote [fn:%s] redefined! %#v", name, definition)
|
||||
}
|
||||
d.Footnotes.Definitions[name] = definition
|
||||
}
|
||||
d.Footnotes.addOrder = append(d.Footnotes.addOrder, name)
|
||||
}
|
||||
|
||||
func tokenize(line string) token {
|
||||
for _, lexFn := range lexFns {
|
||||
if token, ok := lexFn(line); ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue