@@ 511,14 511,14 @@ func (el *element) parseListUnorderedItem(line []byte) {
}
if len(line[x:]) > 3 {
var (
- checklist = line[x : x+3]
- sym string
+ checklist = line[x : x+3]
+ strchecklist = string(checklist)
+ sym string
)
- if bytes.Equal(checklist, []byte(`[ ]`)) {
+ switch strchecklist {
+ case `[ ]`:
sym = symbolUnchecked
- } else if bytes.Equal(checklist, []byte(`[x]`)) ||
- bytes.Equal(checklist, []byte(`[X]`)) ||
- bytes.Equal(checklist, []byte(`[*]`)) {
+ case `[x]`, `[X]`, `[*]`:
sym = symbolChecked
}
if len(sym) != 0 {
@@ 532,7 532,6 @@ func (el *element) parseListUnorderedItem(line []byte) {
}
break
}
-
}
}
el.Write(line[x:])
@@ 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
}