3function indental (data, Type) {
4 function formatLine (line) {
7 for (const child of line.children) {
9 if (h[child.key]) { console.warn(`Redefined key: ${child.key}.`) }
10 h[child.key] = child.value
11 } else if (child.children.length === 0 && child.content) {
12 a[a.length] = child.content
14 h[child.content.toUpperCase()] = formatLine(child)
17 return a.length > 0 ? a : h
20 function makeLine (line) {
21 return line.indexOf(' : ') > -1 ? {
22 indent: line.search(/\S|$/),
24 key: line.split(' : ')[0].trim().toUpperCase(),
25 value: line.split(' : ')[1].trim()
27 indent: line.search(/\S|$/),
33 function skipLine (line) {
34 return line.trim() !== '' && line.trim().substr(0, 1) !== ';' && line.trim().slice(-1) !== '`'
37 const lines = data.split('\n').filter(skipLine).map(makeLine)
41 for (const line of lines) {
42 const target = stack[line.indent - 2]
43 if (target) { target.children.push(line) }
44 stack[line.indent] = line
49 for (const id in lines) {
50 const line = lines[id]
51 if (line.indent > 0) { continue }
52 const key = line.content.toUpperCase()
53 if (h[key]) { console.warn(`Redefined key: ${key}, line ${id}.`) }
54 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