diff options
Merge branch 'master' into 'blog/black-hole-shader'
# Conflicts:
# src/blog/index.md
10 files changed, 331 insertions, 363 deletions
| -rw-r--r-- | awk-edits/#stack.awk | 26 | ||||
| -rw-r--r-- | awk-edits/File-type.awk | 97 | ||||
| -rw-r--r-- | awk-edits/Heading-anchors.awk | 2 | ||||
| -rw-r--r-- | awk-edits/Icons.awk | 30 | ||||
| -rw-r--r-- | awk-edits/MEL-Iconified.awk | 42 | ||||
| -rw-r--r-- | awk-edits/MEL-Presentation.awk | 94 | ||||
| -rw-r--r-- | awk-edits/MEL-Teaching.awk | 8 | ||||
| -rw-r--r-- | awk-edits/MEL-parser.awk | 134 | ||||
| -rw-r--r-- | awk-edits/Pagenav.awk | 28 | ||||
| -rw-r--r-- | awk-edits/Presentation.awk | 233 |
diff --git a/awk-edits/#stack.awk b/awk-edits/#stack.awk new file mode 100644 index 0000000..a8b0b2a --- /dev/null +++ b/awk-edits/#stack.awk @@ -0,0 +1,26 @@ +function newStack(name) { + __stacks[name, "length"] = 0 +} + +function topStack(name) { + return __stacks[name, __stacks[name, "length"] - 1] +} + +function lengthStack(name) { + return __stacks[name, "length"] +} + +function pushStack(name, value) { + __stacks[name, __stacks[name, "length"]++] = value +} + +function popStack(name, value) { + delete __stacks[name, --__stacks[name, "length"]] +} + +function deleteStack(name) { + for (i = 0; i < __stacks[name, "length"]; i++) { + delete __stacks[name, i] + } + delete __stacks[name, "length"] +} diff --git a/awk-edits/File-type.awk b/awk-edits/File-type.awk deleted file mode 100644 index 32e22b9..0000000 --- a/awk-edits/File-type.awk +++ /dev/null @@ -1,97 +0,0 @@ -# .*(misc|preserved).*html -# -# == About == -# -# Each file list is a "details" element, that contains a table, each row being a different file -# or alternatively, just the table on it's own. -# -# -- Result HTML -- -# -# <details> -# <summary>Folder Info</summary> -# <table> -# <tr>File Data</tr> -# </table> -# </details> -# or -# <table> -# <tr>File Data</tr> -# </table> - -# -# == ftags == -# -# &&folder The text right afterwards is the title of the folder. All files -# are hidden inside the collapsed details tag (click to show). -# The file table is indented. You cannot have a folder inside a folder. -# It can be omitted, and the files table will be shown as-is. -# -# &&file Everything that follows this tag is the data for a file. You should -# use &&fd to specify columns of information! Depending on the context, -# it might be flrepllaced with the start of a table, closing the summary -# and starting table, or closing and opening a table row. -# -# &&/files This tag must exist at the bottom of a file list, no matter if it was -# started with or without a &&folder. -# -# &&fd Defines a column of information for a file (row). Practically, it is -# flrepllaced with <td>, and </td> is added to the end of the line. -# If you don't use it, make sure to have the leading and trailing td tags! -# -# &&ft-TYPE Depending on TYPE, it inserts an image tag that contains the file "icon" -# for the corresponding type. -# Available values for TYPE: photo, text, zip, movie, markdown -# -# -- Placement/Flow -- -# -# All ftags, except &&fd, can be placed on their own line (empty line above and below) -# or before/after another ftag. -# Folder title must be inside the same paragraph as the ftag itself. This means that, -# after -# every &&folder ftag, the text can continue directly next to it and/or on new lines, -# without there being any empty lines (you can add those with <br> or two spaces at -# line end). -# -# -- Example Usage -- -# -# (I like to indent a bit &&fd ftags, for readability's sake, but you don't have to) -# -# &&file -# &&ft-text -# &&fd Notes -# &&fd 10 KB -# &&/files -# -# &&folder Math -# &&file -# &&ft-text -# &&fd Homework 1 -# &&file -# &&ft-text -# &&fd Homework 2 -# &&/files -# -# &&folder Art Project<br> -# Status: 70% complete<br> -# Note: Reserach Van Gogh paintings -# -# &&file -# &&fd Painting 1 -# &&fd 100% Complete -# -# &&file -# &&fd Painting 2 -# &&fd 40% Complete -# -# &&/files - -function flSub(name, repl) { - sub("&&" name, "<span class=\"file-type-icon\">" repl "</span>") -} - -/&&ft-photo/ { flSub("ft-photo", "\\") } -/&&ft-text/ { flSub("ft-text", "\\") } -/&&ft-zip/ { flSub("ft-zip", "\\") } -/&&ft-movie/ { flSub("ft-movie", "\\") } -/&&ft-markdown/ { flSub("ft-markdown", "\\") } -/&&ft-browser/ { flSub("ft-browser", "\\") } diff --git a/awk-edits/Heading-anchors.awk b/awk-edits/Heading-anchors.awk index 10f4aa9..7d4edf8 100644 --- a/awk-edits/Heading-anchors.awk +++ b/awk-edits/Heading-anchors.awk @@ -12,5 +12,5 @@ gap = "<div class=\"gap" ((substr($0, RSTART + 2, 1) == 2) ? "" : "-small") "\"></div>" ORS } match($0, /id="[^"]*"/) - $0 = gap $0 ORS "<a class=\"h-anchor\" href=\"#" substr($0, RSTART + 4, RLENGTH - 5) "\" aria-hidden=\"true\">§</a>" + $0 = gap $0 ORS "<a class=\"h-anchor\" href=\"#" substr($0, RSTART + 4, RLENGTH - 5) "\" aria-hidden=\"true\">#</a>" } diff --git a/awk-edits/Icons.awk b/awk-edits/Icons.awk deleted file mode 100644 index ae780bd..0000000 --- a/awk-edits/Icons.awk +++ /dev/null @@ -1,30 +0,0 @@ -# .*html -# -# == About == -# -# A collection of ftags that generate an image HTML tag, containing the specified -# thing. This is done, because these tags need to have specific classes, which is -# supported in Markdown, but is less flexible and more tedious. -# -# -- Placement/Flow -- -# -# They can reside absolutely anywhere in text. - -function flagSub(name, alt) { - gsub("&&" name, - "<img src=\"/img/" name ".svg\" class=\"flag unzoomable svg\" alt=\"" name "\" height=18>") -} - -/&&gb/ { flagSub("gb", "ENG") } -/&&bg/ { flagSub("bg", "BGN") } - -function articleIconSub(name, filename) { - sub("p>&&" name, - "p class=\"special-par " name "-par\">\\&\\&" name) - gsub("&&" name, - "<img src=\"/img/" filename "\" class=\"special-par-icon borderless unzoomable\" alt=\"" name "\">") -} - -/&&question/ { articleIconSub("question", "dialog-question.png") } -/&&warn/ { articleIconSub("warn", "dialog-warning.png") } -/&&important/ { articleIconSub("important", "dialog-important.png") } diff --git a/awk-edits/MEL-Iconified.awk b/awk-edits/MEL-Iconified.awk new file mode 100644 index 0000000..332be46 --- /dev/null +++ b/awk-edits/MEL-Iconified.awk @@ -0,0 +1,42 @@ +# .*html + +BEGIN { + usesMEL() + # + # Flags + # + + melFlagTag("gb", "ENG") + melFlagTag("bg", "BGN") + + # + # Noteworthy paragraphs + # + + melParTag("question", "dialog-question.png") + melParTag("warn", "dialog-warning.png") + melParTag("important", "dialog-important.png") + + # + # File type + # + + melFiletypeTag("ft-photo", "") + melFiletypeTag("ft-text", "") + melFiletypeTag("ft-zip", "") + melFiletypeTag("ft-movie", "") + melFiletypeTag("ft-markdown", "") + melFiletypeTag("ft-browser", "") +} + +function melFlagTag(name, alt) { + MEL[name, MELINSERT] = "<img src=\"/img/" name ".svg\" class=\"flag unzoomable svg\" alt=\"" name "\" height=18>" +} + +function melParTag(name, image) { + MEL[name, MELPARAGRAPH] = "class=\"special-par " name "-par\"><img src=\"/img/" image "\" class=\"special-par-icon borderless unzoomable\" alt=\"" name "\">" +} + +function melFiletypeTag(name, repl) { + MEL[name, MELINSERT] = "<span class=\"file-type-icon\">" repl "</span>" +} diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk new file mode 100644 index 0000000..cabc928 --- /dev/null +++ b/awk-edits/MEL-Presentation.awk @@ -0,0 +1,94 @@ +# .*(slides|teaching)/.*html + +BEGIN { + usesMEL() + # + # Elements, dependent (and semidependent) on available font size + # + + fontSizes[1] = "18" + fontSizes[2] = "20" + fontSizes[3] = "22" + fontSizes[4] = "25" + fontSizes[5] = "27" + fontSizes[6] = "35" + + # Certain tags can exist without explicitly defining the font size + # while others cannot + # fontSizes[0] is used for simpler code for the tags which don't + # require font size + fontSizes[0] = "" + + # Tags which can exist without specified font-size + for (ind in fontSizes) { + fontClass = (ind != 0) ? " font" fontSizes[ind] : "" + + MEL["slide" fontSizes[ind], MELOPEN] = "<div id=\"[SLIDEID]\" class=\"slide" fontClass "\">" + MEL["slide" fontSizes[ind], MELCLOSE] = "</div>" + MEL["middle" fontSizes[ind], MELOPEN] = "<div id=\"[SLIDEID]\" class=\"slide centered-slide" fontClass "\"><div></div><div>" + MEL["middle" fontSizes[ind], MELCLOSE] = "</div><div></div></div>" + MEL["title" fontSizes[ind], MELOPEN] = "<div id=\"[SLIDEID]\" class=\"slide centered-slide centered" fontClass "\"><div></div><div>" + MEL["title" fontSizes[ind], MELCLOSE] = "</div><div></div></div>" + + standardPresentationTag("centered" fontSizes[ind], "centered" fontClass) + } + + # refer to definition of fontSizes[0] + delete fontSizes[0] + + # Tags which cannot exist without specified font-size + for (ind in fontSizes) { + standardPresentationTag("font" fontSizes[ind]) + } + + # + # Special cases + # + + MEL["presentation", MELINSERT] = ORS \ +"<nav id=\"presentCont\">" ORS \ +" <span id=\"prevSlideBtn\" class=\"btn nodisplay\">←</span>" ORS \ +" <a id=\"slideIndex\" class=\"nodisplay\" href=\"#slide-0\">0</a>" ORS \ +" <span id=\"nextSlideBtn\" class=\"btn nodisplay\">→</span>" ORS \ +" <span id=\"articleBtn\" class=\"btn setting-btn\">Article view ☲</span>" ORS \ +" <span id=\"presentBtn\" class=\"btn setting-btn\">Present ⎚</span>" ORS \ +" <span id=\"printBtn\" class=\"btn setting-btn\">Print ⎙</span>" ORS \ +" </nav><br><br>" ORS \ +" <script type=\"text/javascript\" src=\"/scripts/presentation.js\" crossorigin=\"anonymous\"></script>" + + MEL["row", MELOPEN] = "<div class=\"layout-table\"><div class=\"layout-row\">" # <table><tr> (layout-row > * is td) + MEL["row", MELCLOSE] = "</div></div>" # </tr><table> + + MEL["sqrow", MELOPEN] = "<div class=\"layout-table fixed-layout\"><div class=\"layout-row\">" # <table><tr> (layout-row > * is td) + MEL["sqrow", MELCLOSE] = "</div></div>" + + MEL["newrow", MELINSERT] = "</div><div class=\"layout-row\">" # </tr><tr> + + # + # Generated tags + # + + for (i = 1; i <= 9; i++) { + MEL["br" i, MELINSERT] = "<div class=\"br" i "\"></div>" + } + for (i = 5; i <= 95; i++) { + standardPresentationTag("width" i "%", "width" i "per") + } + + # + # Ordinary + # + + standardPresentationTag("fright", "float-right") + standardPresentationTag("column") +} + +function standardPresentationTag(name, class) { + if (class == "") class = name + MEL[name, MELOPEN] = "<div class=\"" class "\">" + MEL[name, MELCLOSE] = "</div>" +} + +/\[SLIDEID\]/ { + sub(/\[SLIDEID\]/, "slide-" slideIndex++) +} diff --git a/awk-edits/MEL-Teaching.awk b/awk-edits/MEL-Teaching.awk new file mode 100644 index 0000000..245d6fa --- /dev/null +++ b/awk-edits/MEL-Teaching.awk @@ -0,0 +1,8 @@ +# .*teaching/.*html + +BEGIN { + usesMEL() + + MEL["solution-link", MELLINEOPEN] = "<div class=\"exercise-solution\"><" + MEL["solution-link", MELLINECLOSE] = " ></div>" +} diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk new file mode 100644 index 0000000..777caa1 --- /dev/null +++ b/awk-edits/MEL-parser.awk @@ -0,0 +1,134 @@ +# .*html +# +# == About == +# +# MEL is the "Markdown Extensions Language" +# It's a general metalanguage (I made) for adding custom syntax to Markdown (via awk) +# The idea is it provides parsing for general constructs, and you only need to define +# the names of those constructs and with what they get replaced with +# +# Slightly based on ftags, this system allows you to easily implement the following construts: +# &(name ... &) Multiline "tag", everything inside is formatted by "name" +# &{name ... &} In practice, it just replaces "&[name" and "&]" with the appropriate HTML +# &[name ... &] All three can be used interchangeably, though it's preferrable if +# you use the matching braces and semantically, in your "language" +# square brackets are used for the largest components +# curly for structural components and normal braces for styling +# &:name Format/encapsulate everything until the end of the paragraph +# &::name Format/encapsulate everything until the end of the line +# &.name Insert standalone element as-is +# +# Though it's not decided (or implemented) yet, potentially there will also be: +# &)-( Used to simplify cases of &(name1 ... &) &(name1 ... &) &(name1 ... &) +# &}-{ into &(name1 ... &)-( ... &)-( ... &) +# &]-[ Or maybe for special cases, where rather than doing something like +# &{elementsList &(element1 ... &) &(element2 ... &) &} +# you could simply do +# &{elementsList ... &}-{ ... &}-{ ... &} +# So it will surf as a separator between direct subelements + +BEGIN { + usesMEL() + newStack("mel") +} + +function usesMEL() { + MELOPEN = "o" + MELCLOSE = "c" + MELLINEOPEN = "lo" + MELLINECLOSE = "lc" + MELINSERT = "i" + MELPARAGRAPH = "p" + MELLINE = "l" +} + +function printErr(message, column, columnPointer) { + column = length($0) - length(lineCopy) + RSTART - 5 + print "ERROR by MEL-parser.awk: " message " | Found in " FILENAME " at line " FNR " & column " column ":" > "/dev/stderr" + columnPointer = "" + for (i = 1; i < column; i++) + columnPointer = columnPointer " " + for (i = -5; i < RLENGTH; i++) + columnPointer = columnPointer "^" + print $0 "\n" columnPointer "\n" > "/dev/stderr" +} + +/<code>/ { + melInsideCode = 1 +} + +/<\/code>/ { + melInsideCode = 0 +} + +melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&[{[()\]}:.]/ { + newLine = "" + lineCopy = $0 + paragraphed = 0 + append = "" + while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { + RSTART += 5 + RLENGTH -= 5 + + # Inside closing tag + if (RLENGTH == 1) { + replaceWith = MEL[topStack("mel"), MELCLOSE] + + if (replaceWith == "") + printErr("Missing closing tag for \"" topStack("mel") "\"") + + popStack("mel") + } + # Inside insert + else if (substr(lineCopy, RSTART, 1) == ".") { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = MEL[name, MELINSERT] + + if (replaceWith == "") + printErr("Unknown insertion tag \"" name "\"") + } + # Inside one line + else if (substr(lineCopy, RSTART, 2) == "::") { + name = substr(lineCopy, RSTART + 2, RLENGTH - 2) + + replaceWith = MEL[name, MELLINEOPEN] + append = append MEL[name, MELLINECLOSE] + + if (replaceWith == "") + printErr("Missing beginning for line tag \"" name "\"") + else if (MEL[name, MELLINECLOSE] == "") + printErr("Missing ending for line tag \"" name "\"") + else if (replaceWith == "" && MEL[name, MELLINECLOSE] == "") + printErr("Unknown single line tag \"" name "\"") + } + # Inside paragraph + else if (substr(lineCopy, RSTART, 1) == ":") { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = " " MEL[name, MELPARAGRAPH] + + if (replaceWith == " ") + printErr("Unknown paragraph tag \"" name "\"") + + RSTART -= 1 + RLENGTH += 1 + paragraphed = 1 + } + # Inside opening tag + else { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = MEL[name, MELOPEN] + pushStack("mel", name) + + if (replaceWith == "") + printErr("Unknown opening tag \"" name "\"") + } + newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith + lineCopy = substr(lineCopy, RSTART + RLENGTH) + } + $0 = newLine lineCopy append + if (paragraphed == 0 && newLine != "") + gsub(/(<p>|<\/p>)/, "") +} diff --git a/awk-edits/Pagenav.awk b/awk-edits/Pagenav.awk index 14772ef..3b05c10 100644 --- a/awk-edits/Pagenav.awk +++ b/awk-edits/Pagenav.awk @@ -16,10 +16,34 @@ nopagenav == 0 && /<h1/ { match(FILENAME, /(blog|slides|teaching|tutorials|misc)\/.*\//) + path = substr(FILENAME, RSTART, length(FILENAME) - RSTART - 3) + + # Stats element + stats = "<div id=\"pagenav-stats\">" ORS \ +" <strong>Reading: " (int(words / 180) + 1) " min</strong> || <strong>Created: " created "</strong> || <strong>Edited: " edited "</strong>" ORS \ +" || <a href=\"https://gitlab.com/Syndamia/syndamiadotcom/-/blob/master/src/" path "md\"><strong>GitLab source</strong></a>" ORS \ +"</div>" + + # Breadcrumbs element + sub(/\/[^/]*$/, "", path) + foldersLen = split(path, folders, "/") + + href = ".." + breadcrumb = " » <em>" folders[foldersLen] "</em>" + for (i = foldersLen-1; i > 0; i--) { + breadcrumb = " » " "<a href=" href ">" folders[i] "</a>" breadcrumb + href = "../" href + } + breadcrumb = \ +" <div id=\"pagenav-breadcrumb\">" ORS \ +" " breadcrumb ORS \ +" </div>" + + # Pagenav element $0 = $0 ORS \ "<div id=\"pagenav\">" ORS \ -" <strong>Reading: " (int(words / 180) + 1) " min</strong> || <strong>Created: " created "</strong> || <strong>Edited: " edited "</strong>" ORS \ -" || <a href=\"https://gitlab.com/Syndamia/syndamiadotcom/-/blob/master/src/" substr(FILENAME, RSTART, length(FILENAME) - RSTART - 3) "md\"><strong>GitLab source</strong></a>" ORS \ + stats ORS \ + breadcrumb ORS \ "</div>" nopagenav = 1 diff --git a/awk-edits/Presentation.awk b/awk-edits/Presentation.awk deleted file mode 100644 index 4d3826a..0000000 --- a/awk-edits/Presentation.awk +++ /dev/null @@ -1,233 +0,0 @@ -# .*(slides|teaching)/.*html -# -# == 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. -# Inside each slide, normal element flow is respected. -# Each slide is the size of a landscape-oriented A4 sheet of paper. Light/dark -# mode settings are respected (of course). -# Currently, this is active only in pages under the "slides" 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 following this tag is part of a slide. Each slide is -# presented in the order it appears in. -# &&/slide Ends (the last started) slide. -# -# &&clide Same as &&slide, but everything following is centered -# vertically. Uses flexbox. -# &&/slide Ends (the last started) clide. Not compatible with &&/slide! -# -# &&table Starts a table, where everything following it is formatted as a -# table cell in a row. -# &&ftable Same as &&table, but all colums have the same width. -# &&tarow Ends the last started row and begins a new row. -# Effectively everything following it is on a new row. -# &&/table Ends (the last started) (table row and) table or ftable. -# -# &&linebN Adds a line break (vertical spacing) of N (text) lines. -# Spacing is equivalent to N em. -# Available values for N: 1, 2, 3, 4, 5, 6, 7, 8, 9 -# -# &&fontSIZE Changes font size to SIZE, in pixels. Default size is 30px. -# Available values for SIZE: 18, 20, 22, 25, 27, 35 -# &&/font Text between &&fontSIZE and &&/font is sized accordingly -# -# &¢ered Center horizontally (only) text. -# &&/centered Text between &¢ered and &&/centered is aligned. -# -# &&fright Aligns following elements and text to the right. -# &&/fright Text between &&fright and &&/fright is aligned to the right -# -# &&cont Basic container with no properties. Useful if you need to group -# multiple elements into one table cell. -# &&/cont Ends (the last started) &&cont -# -# &&widthPER Sets the element's width to be PER percentage. Primarily made -# for images, since perfect scaling is impossible. -# Available values for PER: 5, 10, 15, 20, ..., 90, 95 -# &&/width Text between &&widthPER and &&/width 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 and while printing. -# -# -- 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. -# -# -- Regarding flex -- -# -# The older versions of the script, prior to commit -# 687ff3652e5695183ba1691e7d4b94470f8407b3 -# used extensively flexbox for element alignment. This was done with the hope that -# spacing out elements evenly and centering them would be very easy, which turned -# out to be false. -# -# Now, the only thing that uses flexbox is &&clide, and it only allows to center -# everything in the slide vertically. -# Vertical centerings for portions of elements can be done with &&linebN, which, -# though imperfect, does the job very well and should suffice. -# Evenly spacing out elements next to each other can be done with &&table and -# &&ftable. -# -# -- Example Usage -- -# -# Refer to src/talks/demo/index.md - -BEGIN { - # names is name of ftag, meaning if `names[i] = "examp"` the ftag will be &&examp - # ended specifies how the HTML tag is ended - # `ended[i] = 0` means no closing ftag (so no &&/examp) - # `ended[i] = 1` means &&/examp exists - # `ended[i] = 2` means self-closing, so no &&/examp, but &&examp includes the closing tag - # - # &&examp is usually replaced by `<div class="examp">` - # &&/examp is usually replaced by `</div>` - # in case ended[i] = 2, &&examp is replaced by `<div class="examp"></div>` - - # Main elements and exceptions to the normal replace format - names[ 1] = "presentation" - ended[ 1] = 0 - names[ 2] = "slide" - ended[ 2] = 1 - names[ 3] = "clide" - ended[ 3] = 1 - names[ 4] = "table" - ended[ 4] = 1 - names[ 5] = "ftable" - ended[ 5] = 0 - names[ 6] = "tarow" - ended[ 6] = 0 - names[ 7] = "/font" # all font ftags can be closed with a &&/font - ended[ 7] = 0 - - # Line breaks - names[ 8] = "lineb1" - ended[ 8] = 2 - names[ 9] = "lineb2" - ended[ 9] = 2 - names[10] = "lineb3" - ended[10] = 2 - names[11] = "lineb4" - ended[11] = 2 - names[12] = "lineb5" - ended[12] = 2 - names[13] = "lineb6" - ended[13] = 2 - names[14] = "lineb7" - ended[14] = 2 - names[15] = "lineb8" - ended[15] = 2 - names[16] = "lineb9" - ended[16] = 2 - - # Font sizes - names[17] = "font18" - ended[17] = 0 - names[18] = "font20" - ended[18] = 0 - names[19] = "font22" - ended[19] = 0 - names[20] = "font25" - ended[20] = 0 - names[21] = "font27" - ended[21] = 0 - names[22] = "font35" - ended[22] = 0 - - # Everything else - names[23] = "centered" - ended[23] = 1 - names[24] = "fright" - ended[24] = 1 - names[25] = "cont" - ended[25] = 1 - names[26] = "/width" - ended[26] = 0 - - nameslength = 26 # POSIX compatibility: length(names) isn't valid - - for (i = 95; i >= 5; i -= 5) { - nameslength++ - names[nameslength] = "width" i - ended[nameslength] = 0 - } - - pres = ORS \ -"<nav id=\"presentCont\">" ORS \ -" <span id=\"prevSlideBtn\" class=\"btn nodisplay\">\\←</span>" ORS \ -" <a id=\"slideIndex\" class=\"nodisplay\" href=\"#slide-0\">0</a>" ORS \ -" <span id=\"nextSlideBtn\" class=\"btn nodisplay\">\\→</span>" ORS \ -" <span id=\"articleBtn\" class=\"btn setting-btn\">Article view \\☲</span>" ORS \ -" <span id=\"presentBtn\" class=\"btn setting-btn\">Present \\⎚</span>" ORS \ -" <span id=\"printBtn\" class=\"btn setting-btn\">Print \\⎙</span>" ORS \ -" </nav><br><br>" ORS \ -" <script type=\"text/javascript\" src=\"/scripts/presentation.js\" crossorigin=\"anonymous\"></script>" - - for (i = 1; i <= nameslength; 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>" - } - } - - rep[ 1] = pres - rep[ 3] = "<div class=\"slide clide\"><div></div><div>" # flex-col + flex:1 + <div> - crep[3] = "</div><div></div></div>" # </div> + flex:1 + /flex-col - rep[ 4] = "<div class=\"layout-table\"><div class=\"layout-row\">" # <table><tr> (layout-row > * is td) - crep[4] = "</div></div>" # </tr><table> - rep[ 5] = "<div class=\"layout-table fixed-layout\"><div class=\"layout-row\">" # <table><tr> (layout-row > * is td) - rep[ 6] = "</div><div class=\"layout-row\">" # </tr><tr> - rep[ 7] = "</div>" # &&/font - rep[26] = "</div>" # &&/width - - presInsideCode = 0 - slideIndex = 0 -} - -function presentationSubstitute(ind) { - gsub(/(<p>|<\/p>)/, "") - if ((ind == 2 || ind == 3) && index($0, pat[ind]) != 0) { # &&slide or &&clide - gsub(pat[ind], "<div id=\"slide-" slideIndex "\"" substr(rep[ind], 5)) - slideIndex++ - } - else { - gsub(pat[ind], rep[ind]) - } - if (ended[ind] == 1) - gsub(cpat[ind], crep[ind]) -} - -/<code>/ { - presInsideCode = 1 -} - -/<\/code>/ { - presInsideCode = 0 -} - -presInsideCode == 0 && /^[ \t]*(<p>)?&&/ { - for (i = 1; i <= nameslength; i++) { - if (index($0, names[i]) != 0) - presentationSubstitute(i) - } -} |