HTML export: Export #+TITLE as h1 and offset other headlines accordingly

emacs exports #+TITLE as <h1> and all other headlines accordingly as
`lvl + 1` - we'll go with that.
This commit is contained in:
Niklas Fasching 2019-12-22 13:58:19 +01:00
parent b61e49eb85
commit 614307a8f5
8 changed files with 90 additions and 84 deletions

View file

@ -88,6 +88,9 @@ func (w *HTMLWriter) WriterWithExtensions() Writer {
func (w *HTMLWriter) Before(d *Document) {
w.document = d
w.log = d.Log
if title := d.Get("TITLE"); title != "" {
w.WriteString(fmt.Sprintf(`<h1 class="title">%s</h1>`+"\n", title))
}
w.WriteOutline(d)
}
@ -214,7 +217,7 @@ func (w *HTMLWriter) WriteHeadline(h Headline) {
}
}
w.WriteString(fmt.Sprintf(`<h%d id="%s">`, h.Lvl, h.ID()) + "\n")
w.WriteString(fmt.Sprintf(`<h%d id="%s">`, h.Lvl+1, h.ID()) + "\n")
if w.document.GetOption("todo") && h.Status != "" {
w.WriteString(fmt.Sprintf(`<span class="todo">%s</span>`, h.Status) + "\n")
}
@ -231,7 +234,7 @@ func (w *HTMLWriter) WriteHeadline(h Headline) {
w.WriteString("&#xa0;&#xa0;&#xa0;")
w.WriteString(fmt.Sprintf(`<span class="tags">%s</span>`, strings.Join(tags, "&#xa0;")))
}
w.WriteString(fmt.Sprintf("\n</h%d>\n", h.Lvl))
w.WriteString(fmt.Sprintf("\n</h%d>\n", h.Lvl+1))
WriteNodes(w, h.Children...)
}