-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_list.go
72 lines (60 loc) · 1.63 KB
/
mod_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package white600
import (
"strings"
)
// convList ...list generation
func (data *MarkdownInfo) convList() {
var text []string
var line = data.currentData.currentLine
var nest = 0
var oldNest = len(data.options.listNest)
// list type and open list
for md, tag := range listStyle {
if strings.Index(strings.Trim(line, " "), md) == 0 {
nest = 1 + strings.Index(line, md)/2
line = line[strings.Index(line, md)+len(md):]
// open <ul> or <ol>
for nest > len(data.options.listNest) {
data.options.listNest = append(data.options.listNest, tag)
text = append(text, "<")
text = append(text, tag)
text = append(text, ">")
}
}
}
// close
data.listTagClose(nest, oldNest)
// open <li>
text = append(text, "<li>")
text = append(text, data.inlineConv(line))
data.html = append(data.html, text...)
}
// closeList ...close list
func (data *MarkdownInfo) closeList() {
data.listTagClose(0, len(data.options.listNest))
}
// listTagClose
func (data *MarkdownInfo) listTagClose(nest int, oldNest int) {
var text = []string{""}
// close
for nest < len(data.options.listNest) {
text = append(text, "</li></")
text = append(text, data.options.listNest[len(data.options.listNest)-1])
text = append(text, ">")
data.options.listNest = data.options.listNest[:len(data.options.listNest)-1]
}
// </li>
if nest <= oldNest && nest != 0 {
if nest == oldNest {
text = append(text[:1], text...)
text[0] = "</li>"
} else {
text = append(text, "</li>")
}
}
// append
//text = append(text, data.markdownLines[0])
// join
//data.markdownLines[0] = strings.Join(text, "")
data.html = append(data.html, text...)
}