Add support for ": example" elements

This commit is contained in:
Niklas Fasching 2018-12-16 23:21:26 +01:00
parent 24ace5aa0e
commit c012b0a533
8 changed files with 75 additions and 0 deletions

View file

@ -88,6 +88,8 @@ func (w *HTMLWriter) writeNodes(ns ...Node) {
case Paragraph:
w.writeParagraph(n)
case Example:
w.writeExample(n)
case HorizontalRule:
w.writeHorizontalRule(n)
case Text:
@ -264,6 +266,17 @@ func (w *HTMLWriter) writeParagraph(p Paragraph) {
w.WriteString("\n</p>\n")
}
func (w *HTMLWriter) writeExample(e Example) {
w.WriteString(`<pre class="example">` + "\n")
if len(e.Children) != 0 {
for _, n := range e.Children {
w.writeNodes(n)
w.WriteString("\n")
}
}
w.WriteString("\n</pre>\n")
}
func (w *HTMLWriter) writeHorizontalRule(h HorizontalRule) {
w.WriteString("<hr>\n")
}