3function indental (data, Type) {
4 function formatLine (line) {
7 for (const id in line.children) {
8 const child = line.children[id]
10 if (h[child.key]) { console.warn(`Redefined key: ${child.key}.`) }
11 h[child.key] = child.value
12 } else if (child.children.length === 0 && child.content) {
13 a[a.length] = child.content
15 h[child.content.toUpperCase()] = formatLine(child)
18 return a.length > 0 ? a : h
21 function makeLine (line) {
22 return line.indexOf(' : ') > -1 ? {
23 indent: line.search(/\S|$/),
25 key: line.split(' : ')[0].trim().toUpperCase(),
26 value: line.split(' : ')[1].trim()
28 indent: line.search(/\S|$/),
34 function skipLine (line) {
35 return line.trim() !== '' && line.substr(0, 1) !== ';'
38 const lines = data.split('\n').filter(skipLine).map(makeLine)
42 for (const id in lines) {
43 const line = lines[id]
44 const target = stack[line.indent - 2]
45 if (target) { target.children.push(line) }
46 stack[line.indent] = line
51 for (const id in lines) {
52 const line = lines[id]
53 if (line.indent > 0) { continue }
54 const key = line.content.toUpperCase()
55 if (h[key]) { console.warn(`Redefined key: ${key}, line ${id}.`) }
56 h[key] = Type ? new Type(key, formatLine(line)) : formatLine(line)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list