aboutsummaryrefslogtreecommitdiff
path: root/document_parser.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2020-11-16 01:05:52 +0700
committerShulhan <m.shulhan@gmail.com>2020-11-16 01:05:52 +0700
commit43dfd5e2dc5c2c08668659534e0fe2e6b678526f (patch)
tree88199e897d72bb766767ecf9ed0e291e82754182 /document_parser.go
parent4a96e9e82173f4c4e369fb71050f931575317c86 (diff)
downloadasciidoctor-go-43dfd5e2dc5c2c08668659534e0fe2e6b678526f.tar.xz
all: support section "[discrete]" headings style
Diffstat (limited to 'document_parser.go')
-rw-r--r--document_parser.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/document_parser.go b/document_parser.go
index 1e2391e..3009d4c 100644
--- a/document_parser.go
+++ b/document_parser.go
@@ -278,10 +278,19 @@ func (docp *documentParser) parseBlock(parent *adocNode, term int) {
}
node.kind = docp.kind
- node.WriteString(
- // BUG: "= =a" could become "a", it should be "=a"
- strings.TrimLeft(line, "= \t"),
- )
+ // BUG: "= =a" could become "a", it should be "=a"
+ node.WriteString(strings.TrimLeft(line, "= \t"))
+
+ isDiscrete := node.style&styleSectionDiscrete > 0
+ if isDiscrete {
+ node.kind = nodeKindSectionDiscrete
+ node.level = docp.kind
+ node.parseSection(docp.doc, isDiscrete)
+ parent.addChild(node)
+ node = new(adocNode)
+ line = ""
+ continue
+ }
var expParent = docp.kind - 1
for parent.kind != expParent {
@@ -291,7 +300,7 @@ func (docp *documentParser) parseBlock(parent *adocNode, term int) {
break
}
}
- node.parseSection(docp.doc)
+ node.parseSection(docp.doc, false)
parent.addChild(node)
parent = node
node = new(adocNode)
@@ -405,8 +414,7 @@ func (docp *documentParser) parseBlock(parent *adocNode, term int) {
node = &adocNode{}
continue
- case nodeKindBlockOpen, nodeKindBlockExample,
- nodeKindBlockSidebar:
+ case nodeKindBlockOpen, nodeKindBlockExample, nodeKindBlockSidebar:
node.kind = docp.kind
docp.parseBlock(node, docp.kind)
parent.addChild(node)