aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-07-17 17:21:39 +0700
committerShulhan <ms@kilabit.info>2022-07-17 17:23:28 +0700
commit62d968c8aef49e2ce4fd476e5518c1a8fae26e96 (patch)
tree96472e087baddcf57f4ede4aa39bf85e14f3e530
parent9decc98ee17cd4153ea43dff14a142472c29a137 (diff)
downloadasciidoctor-go-62d968c8aef49e2ce4fd476e5518c1a8fae26e96.tar.xz
all: make the parseHeader state clear
The state should store the previous kind of line being parsed, not the next state.
-rw-r--r--document_parser.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/document_parser.go b/document_parser.go
index fc0679c..9992d75 100644
--- a/document_parser.go
+++ b/document_parser.go
@@ -586,14 +586,14 @@ func (docp *documentParser) parseBlock(parent *element, term int) {
// (*DOC_ATTRIBUTE)
func (docp *documentParser) parseHeader() {
const (
- stateTitle int = iota
+ stateBegin int = iota
+ stateTitle
stateAuthor
stateRevision
- stateEnd
)
var (
- state int = stateTitle
+ state int = stateBegin
key string
value string
@@ -622,25 +622,25 @@ func (docp *documentParser) parseHeader() {
}
continue
}
- if state == stateTitle {
+ if state == stateBegin {
if isTitle(line) {
docp.doc.header.Write(bytes.TrimSpace(line[2:]))
docp.doc.Title.raw = string(docp.doc.header.raw)
- state = stateAuthor
+ state = stateTitle
} else {
docp.doc.rawAuthors = string(line)
- state = stateRevision
+ state = stateAuthor
}
continue
}
switch state {
- case stateAuthor:
+ case stateTitle:
docp.doc.rawAuthors = string(line)
- state = stateRevision
+ state = stateAuthor
- case stateRevision:
+ case stateAuthor:
docp.doc.rawRevision = string(line)
- state = stateEnd
+ state = stateRevision
}
}
}