diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-11-16 01:05:52 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-11-16 01:05:52 +0700 |
| commit | 43dfd5e2dc5c2c08668659534e0fe2e6b678526f (patch) | |
| tree | 88199e897d72bb766767ecf9ed0e291e82754182 /html_backend.go | |
| parent | 4a96e9e82173f4c4e369fb71050f931575317c86 (diff) | |
| download | asciidoctor-go-43dfd5e2dc5c2c08668659534e0fe2e6b678526f.tar.xz | |
all: support section "[discrete]" headings style
Diffstat (limited to 'html_backend.go')
| -rw-r--r-- | html_backend.go | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/html_backend.go b/html_backend.go index f0026cb..c63d30b 100644 --- a/html_backend.go +++ b/html_backend.go @@ -481,14 +481,39 @@ func htmlWriteSection(doc *Document, node *adocNode, out io.Writer, isForToC boo fmt.Fprint(out, "</a>") } fmt.Fprintf(out, "</%s>", tag) + if node.kind == nodeKindSectionL1 { fmt.Fprint(out, "\n<div class=\"sectionbody\">") } } +func hmltWriteSectionDiscrete(doc *Document, node *adocNode, out io.Writer) { + var ( + tag string + ) + switch node.level { + case nodeKindSectionL1: + tag = "h2" + case nodeKindSectionL2: + tag = "h3" + case nodeKindSectionL3: + tag = "h4" + case nodeKindSectionL4: + tag = "h5" + case nodeKindSectionL5: + tag = "h6" + } + + fmt.Fprintf(out, "\n<%s id=%q class=%q>", tag, node.ID, attrNameDiscrete) + node.title.toHTML(doc, out, false) + fmt.Fprintf(out, "</%s>", tag) +} + func htmlWriteToC(doc *Document, node *adocNode, out io.Writer, level int) { var sectClass string + isDiscrete := node.style&styleSectionDiscrete > 0 + switch node.kind { case nodeKindSectionL1: sectClass = "sectlevel1" @@ -505,7 +530,7 @@ func htmlWriteToC(doc *Document, node *adocNode, out io.Writer, level int) { sectClass = "" } - if len(sectClass) > 0 { + if len(sectClass) > 0 && !isDiscrete { if level < node.level { fmt.Fprintf(out, "\n<ul class=\"%s\">", sectClass) } else if level > node.level { @@ -529,7 +554,7 @@ func htmlWriteToC(doc *Document, node *adocNode, out io.Writer, level int) { if node.child != nil { htmlWriteToC(doc, node.child, out, node.level) } - if len(sectClass) > 0 { + if len(sectClass) > 0 && !isDiscrete { fmt.Fprint(out, "</li>") } if node.next != nil { |
