blob: 086d9ddcee3a06f19fa0df56a49a55e7075dd868 (
plain) (
blame)
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
73
74
75
76
77
78
79
80
81
82
|
# This is a really rudementary way to make making file lists less HTML-y
# I made it so:
# 1) You don't have to write quite as much HTML
# 2) The Data columns for each file get to be formatted as Markdown (<td> is not recognized as a block-level element, so the stuff inside get formatted https://kristaps.bsd.lv/lowdown/lowdown.5.html#HTML_Blocks)
# Very roughly, each file list has either this:
# <details><summary>Folder Info</summary> <table> <tr>File Data</tr> </table> </details>
# or this:
# <table> <tr>File Data</tr> </table>
# structure, the difference being that in the first, all of the files are in a folder.
# In Markdown you type in something like (without the "# " in front):
#
# &&fos
# Description
# &&fs0
# <td>Data 1</td>
# <td>Data 1.1</td>
# <td>Data 1.2</td>
# &&fs
# <td>Data 2</td>
# <td>Data 2.1</td>
# <td>Data 2.2</td>
# &&fod
#
# or
#
# &&nos
# <td>Data 1</td>
# <td>Data 1.1</td>
# <td>Data 1.2</td>
# &&fs
# <td>Data 2</td>
# <td>Data 2.1</td>
# <td>Data 2.2</td>
# &&nod
#
# And the lines starting with && (I'll call them ftags) get replaced by some HTML. The <td></td> around each file Data is mandatory.
# &&fs0 must only be used on before the very first file data, when files are in a folder. There must be no empty lines, lines mustn't start with spaces, there mustn't be anything around ftags and ftags have to be on their own lines.
# The commands have fairly intuitive abbreviations:
# &&nos no folder start (start file list, without making a folder)
# &&fos folder start
# &&fs0 file start of first file in folder (must only be used when items are in a folder!)
# &&fs file start
# &&nod no folder end (end file list, without having made a folder)
# &&fod folder end
BEGIN {
nam[1] = "nos"
rep[1] = "<table class=\"file-list\"><tr>"
nam[2] = "fos"
rep[2] = "<details class=\"file-wrapper\"><summary>"
nam[3] = "fs0"
rep[3] = "</summary><table class=\"file-list\"><tr>"
nam[4] = "fs"
rep[4] = "</tr><tr>"
nam[5] = "nod"
rep[5] = "</tr></table>"
nam[6] = "fod"
rep[6] = "</tr></table></details>"
for (i = 1; i <= length(nam); i++) {
pat[i] = "&&" nam[i]
}
}
function substitute(ind) {
gsub(/(<p>|<\/p>)/, "")
gsub(pat[ind], rep[ind])
}
/^[ \t]*(<p>|)&&/ {
for (i = 1; i <= length(nam); i++) {
if (index($0, nam[i]) != 0)
substitute(i)
}
}
{
print
}
|