Add lossless inline-definition-footnote rendering for the OrgWriter

This commit is contained in:
Niklas Fasching 2018-12-02 17:24:10 +01:00
parent fc982125c9
commit a570fc736f
6 changed files with 49 additions and 29 deletions

View file

@ -44,19 +44,8 @@ func (w *HTMLWriter) emptyClone() *HTMLWriter {
}
func (w *HTMLWriter) before(d *Document) {}
func (w *HTMLWriter) after(d *Document) {
fs := d.Footnotes
if len(fs.Definitions) == 0 {
return
}
w.WriteString(`<div id="footnotes">` + "\n")
w.WriteString(`<h1 class="footnotes-title">` + fs.Title + `</h1>` + "\n")
w.WriteString(`<div class="footnote-definitions">` + "\n")
for _, name := range fs.Order {
w.writeNodes(fs.Definitions[name])
}
w.WriteString("</div>\n</div>\n")
w.writeFootnotes(d)
}
func (w *HTMLWriter) writeNodes(ns ...Node) {
@ -141,6 +130,19 @@ func (w *HTMLWriter) writeFootnoteDefinition(f FootnoteDefinition) {
w.WriteString("</div>\n")
}
func (w *HTMLWriter) writeFootnotes(d *Document) {
fs := d.Footnotes
if len(fs.Definitions) == 0 {
return
}
w.WriteString(`<div id="footnotes">` + "\n")
w.WriteString(`<h1 class="footnotes-title">` + fs.Title + `</h1>` + "\n")
w.WriteString(`<div class="footnote-definitions">` + "\n")
for _, name := range fs.Order {
w.writeNodes(fs.Definitions[name])
}
w.WriteString("</div>\n</div>\n")
}
func (w *HTMLWriter) writeHeadline(h Headline) {
w.WriteString(fmt.Sprintf("<h%d>", h.Lvl))
w.writeNodes(h.Title...)