aboutsummaryrefslogtreecommitdiff
path: root/parser.go
diff options
context:
space:
mode:
Diffstat (limited to 'parser.go')
-rw-r--r--parser.go49
1 files changed, 20 insertions, 29 deletions
diff --git a/parser.go b/parser.go
index b80bbeb..1f46b94 100644
--- a/parser.go
+++ b/parser.go
@@ -718,6 +718,8 @@ func whatKindOfLine(line []byte) (kind int, spaces, got []byte) {
line = bytes.TrimRight(line, " \f\n\r\t\v")
+ // All of the comparison MUST be in order.
+
if len(line) == 0 {
return lineKindEmpty, nil, line
}
@@ -731,48 +733,37 @@ func whatKindOfLine(line []byte) (kind int, spaces, got []byte) {
// for example "//comment".
return lineKindComment, spaces, line
}
- if bytes.Equal(line, []byte(`'''`)) ||
- bytes.Equal(line, []byte(`---`)) ||
- bytes.Equal(line, []byte(`- - -`)) ||
- bytes.Equal(line, []byte(`***`)) ||
- bytes.Equal(line, []byte(`* * *`)) {
+
+ var strline = string(line)
+
+ switch strline {
+ case `'''`, `---`, `- - -`, `***`, `* * *`:
return lineKindHorizontalRule, spaces, line
- }
- if bytes.Equal(line, []byte(`<<<`)) {
+ case `<<<`:
return lineKindPageBreak, spaces, line
- }
- if bytes.Equal(line, []byte(`--`)) {
+ case `--`:
return elKindBlockOpen, spaces, line
- }
- if bytes.Equal(line, []byte(`____`)) {
+ case `____`:
return elKindBlockExcerpts, spaces, line
- }
- if bytes.Equal(line, []byte(`....`)) {
+ case `....`:
return elKindBlockLiteral, nil, line
- }
- if bytes.Equal(line, []byte(`++++`)) {
+ case `++++`:
return elKindBlockPassthrough, spaces, line
- }
- if bytes.Equal(line, []byte(`****`)) {
+ case `****`:
return elKindBlockSidebar, nil, line
- }
- if bytes.Equal(line, []byte(`====`)) {
+ case `====`:
return elKindBlockExample, spaces, line
+ case `[listing]`:
+ return elKindBlockListingNamed, nil, line
+ case `[literal]`:
+ return elKindBlockLiteralNamed, nil, line
+ case `toc::[]`:
+ return elKindMacroTOC, spaces, line
}
if bytes.HasPrefix(line, []byte(`|===`)) {
return elKindTable, nil, line
}
-
- if bytes.Equal(line, []byte(`[listing]`)) {
- return elKindBlockListingNamed, nil, line
- }
- if bytes.Equal(line, []byte(`[literal]`)) {
- return elKindBlockLiteralNamed, nil, line
- }
- if bytes.Equal(line, []byte(`toc::[]`)) {
- return elKindMacroTOC, spaces, line
- }
if bytes.HasPrefix(line, []byte(`image::`)) {
return elKindBlockImage, spaces, line
}