Add lossless inline-definition-footnote rendering for the OrgWriter
This commit is contained in:
parent
fc982125c9
commit
a570fc736f
6 changed files with 49 additions and 29 deletions
29
org/org.go
29
org/org.go
|
@ -33,14 +33,7 @@ func NewOrgWriter() *OrgWriter {
|
|||
|
||||
func (w *OrgWriter) before(d *Document) {}
|
||||
func (w *OrgWriter) after(d *Document) {
|
||||
fs := d.Footnotes
|
||||
if len(fs.Definitions) == 0 {
|
||||
return
|
||||
}
|
||||
w.WriteString("* " + fs.Title + "\n")
|
||||
for _, name := range fs.Order {
|
||||
w.writeNodes(fs.Definitions[name])
|
||||
}
|
||||
w.writeFootnotes(d)
|
||||
}
|
||||
|
||||
func (w *OrgWriter) emptyClone() *OrgWriter {
|
||||
|
@ -146,6 +139,19 @@ func (w *OrgWriter) writeBlock(b Block) {
|
|||
w.WriteString(w.indent + "#+END_" + b.Name + "\n")
|
||||
}
|
||||
|
||||
func (w *OrgWriter) writeFootnotes(d *Document) {
|
||||
fs := d.Footnotes
|
||||
if len(fs.Definitions) == 0 {
|
||||
return
|
||||
}
|
||||
w.WriteString("* " + fs.Title + "\n")
|
||||
for _, name := range fs.Order {
|
||||
if fnDefinition := fs.Definitions[name]; !fnDefinition.Inline {
|
||||
w.writeNodes(fnDefinition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (w *OrgWriter) writeFootnoteDefinition(f FootnoteDefinition) {
|
||||
w.WriteString(fmt.Sprintf("[fn:%s] ", f.Name))
|
||||
w.writeNodes(f.Children...)
|
||||
|
@ -228,7 +234,12 @@ func (w *OrgWriter) writeLinebreak(l Linebreak) {
|
|||
}
|
||||
|
||||
func (w *OrgWriter) writeFootnoteLink(l FootnoteLink) {
|
||||
w.WriteString("[fn:" + l.Name + "]")
|
||||
w.WriteString("[fn:" + l.Name)
|
||||
if l.Definition != nil {
|
||||
w.WriteString(":")
|
||||
w.writeNodes(l.Definition.Children...)
|
||||
}
|
||||
w.WriteString("]")
|
||||
}
|
||||
|
||||
func (w *OrgWriter) writeRegularLink(l RegularLink) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue