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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#
# == About ==
#
# This is my way of making slide-based presentations. In short, it just groups
# Markdown formatting into rectangles and adds options for layout formatting.
# Each slide is the size of a landscape-oriented A4 sheet of paper. Light/dark
# mode settings are respected (of course).
# Currently, this appliest only to pages under the "talks" folder.
#
# == ftags ==
#
# &&presentation Must appear before any other presentation ftags.
# It "loads" everything necessary for a presentation, that being
# the navigation bar and logic script (which also inserts the
# custom stylesheet).
# Can be only one per page. Also refer to -- Surroundings --
#
# &&slide Everything below this tag is part of a slide. Each slide is
# presented in the order it appears in.
# &&/slide Ends (the last started) slide.
#
# &&frow A row of paragraphs, where each item is evenly sized and is
# spaced out horizontally. In the HTML, it is a simple flexbox.
# This is one of the two main ways to configure how content is
# laid out on a slide.
# &&/frow Every HTML element/paragraph between &&frow and &&/frow is an
# item that will be laid out.
#
# &&fcol A column of paragraphs, where each item is evenly sized and is
# spaced out vertically. In the HTML, it is a simple flexbox.
# This is one of the two main ways to configure how content is
# laid out on a slide.
# &&/fcol Every HTML element/paragraph between &&fcol and &&/fcol is an
# item that will be laid out.
#
# &&flexer An empty container, which can be used as a blank space item
# inside &&frow or &&fcol. In the styling, it just has `flex: 1`.
#
# &¢ered Aligns text to the center, literally.
# &&/centered Text between &¢ered and &&/centered is aligned.
#
# &&fright Aligns element and the text inside to the right. In the styling,
# it just has text-align and float set to right.
# &&/fright Text between &&fright and &&/fright is aligned to the right
#
# &&fontSIZE Changes to font size to SIZE, in pixels. Default size is 24px.
# Available values for SIZE: 18, 20, 27, 30, 37
# &&/font Text between &&fontSIZE and &&/font is sized accordingly
#
# -- Surroundings --
#
# As stated, there can only be one presentation per page.
# Everything that is around a presentation and it's slides is normally hidden
# during presenting mode, but will show up if you try to print the presentation.
# Exceptions to this rule are headings and paragraphs, which won't show up in
# presenting mode or during print.
#
# -- Placement/Flow --
#
# All ftags can be placed on their own line, or in a line with other ftags.
# The only requirement is that such a line must start with an ftag, ftags in the
# middle of text aren't recognized.
#
# -- Example Usage --
#
# Refer to src/talks/demo.md
BEGIN {
if (substr(ARGV[1], "talks") == 0) exit # FILENAME isn't available yet
# Exceptions to the normal format
names[ 1] = "presentation"
ended[ 1] = 0
names[ 2] = "/font" # all font ftags can be closed with a &&/font
ended[ 2] = 0
names[ 3] = "slide"
ended[ 3] = 1
names[ 4] = "centered"
ended[ 4] = 1
names[ 5] = "flexer"
ended[ 5] = 2
names[ 6] = "frow"
ended[ 6] = 1
names[ 7] = "fcol"
ended[ 7] = 1
names[ 8] = "font18"
ended[ 8] = 0
names[ 9] = "font20"
ended[ 9] = 0
names[10] = "font27"
ended[10] = 0
names[11] = "font30"
ended[11] = 0
names[12] = "font35"
ended[12] = 0
names[13] = "fright"
ended[13] = 1
pres = ORS \
"<nav id=\"presentCont\">" ORS \
" <img id=\"prevSlideBtn\" class=\"unzoomable btn setting-btn icon nodisplay\" src=\"/img/arrow-left-tabler.svg\" alt=\"Previous\">" ORS \
" <img id=\"nextSlideBtn\" class=\"unzoomable btn setting-btn icon nodisplay\" src=\"/img/arrow-right-tabler.svg\" alt=\"Next\">" ORS \
" <img id=\"presentBtn\" class=\"unzoomable btn setting-btn icon\" src=\"/img/presentation-tabler.svg\" alt=\"Present\">" ORS \
" <img id=\"printBtn\" class=\"unzoomable btn setting-btn icon\" src=\"/img/printer-tabler.svg\" alt=\"Print\">" ORS \
" </nav>" ORS \
" <script type=\"text/javascript\" src=\"/scripts/presentation.js\" integrity=\"sha512-79MwfB0EQJMdVjVnd3PA0Cn9fo4JaMUmNuyZNEGSbaMEGcqdE8sWWAbMLheaoptDyb/KuYgNw0pKwvR5Dw+lJw==\" crossorigin=\"anonymous\"></script>"
pat[1] = "&&presentation"
rep[1] = pres
pat[2] = "&&/font"
rep[2] = "</div>"
for (i = 3; i <= length(names); i++) {
pat[i] = "&&" names[i]
rep[i] = "<div class=\"" names[i] "\">"
if (ended[i] == 1) {
cpat[i] = "&&/" names[i]
crep[i] = "</div>"
}
else if (ended[i] == 2) {
rep[i] = rep[i] "</div>"
}
}
}
function substitute(ind) {
gsub(/(<p>|<\/p>)/, "")
gsub(pat[ind], rep[ind])
if (ended[ind] == 1)
gsub(cpat[ind], crep[ind])
}
/^[ \t]*(<p>|)&&/ {
for (i = 1; i <= length(names); i++) {
if (index($0, names[i]) != 0)
substitute(i)
}
}
{
print
}
|