From efa4e784bafeb146dd35ea09f2f481aaedc7e69f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 23 Feb 2024 21:29:18 +0200 Subject: (awk-edits) Added initial MEL parser --- awk-edits/#stack.awk | 26 ++++++++++++++++ awk-edits/MEL-parser.awk | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 awk-edits/#stack.awk create mode 100644 awk-edits/MEL-parser.awk (limited to 'awk-edits') 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/MEL-parser.awk b/awk-edits/MEL-parser.awk new file mode 100644 index 0000000..ebd68bd --- /dev/null +++ b/awk-edits/MEL-parser.awk @@ -0,0 +1,78 @@ +# .*(slides|teaching)/.*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 { + newStack("mel") + MELSINGLE = "s" + MELOPEN = "o" + MELCLOSE = "c" +} + +// { + melInsideCode = 1 +} + +/<\/code>/ { + melInsideCode = 0 +} + +melInsideCode == 0 && /^[ \t]*(

)?&/ { + newLine = "" + lineCopy = $0 + while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:[{(<>)}\]&]+)|[\]})])/)) { + RSTART = RSTART + 5 + RLENGTH = RLENGTH - 5 + + # Inside closing tag + if (RLENGTH == 1) { + replaceWith = MEL[topStack("mel"), MELCLOSE] + popStack("mel") + } + # Inside opening tag + else if (substr(lineCopy, RSTART, 1) ~ /[[{(]/) { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = MEL[name, MELOPEN] + pushStack("mel", name) + } + # Inside paragraph/one line/insert + # TODO: currently all work as insert + else { + nameStart = 1 + (substr(lineCopy, RSTART + 1, 1) == ":") + name = substr(lineCopy, RSTART + nameStart, RLENGTH - nameStart) + + replaceWith = MEL[name, MELSINGLE] + } + newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith + lineCopy = substr(lineCopy, RSTART + RLENGTH) + } + $0 = newLine lineCopy + if (length(newLine) > 0) + gsub(/(

|<\/p>)/, "") +} -- cgit v1.3.1-26-gb76a From e41ff94d4042870c29c5d5cb70fba6020b18fd0c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 23 Feb 2024 21:29:56 +0200 Subject: (awk-edits) Added a MEL-based Presentation.awk alternative With slightly modified tag names --- awk-edits/MEL-Presentation.awk | 91 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 awk-edits/MEL-Presentation.awk (limited to 'awk-edits') diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk new file mode 100644 index 0000000..849a8f8 --- /dev/null +++ b/awk-edits/MEL-Presentation.awk @@ -0,0 +1,91 @@ +# .*(slides|teaching)/.*html + +BEGIN { + # + # 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) { + standardPresentationTag("centered" fontSizes[ind]) + + fontClass = (ind != 0) ? " font" fontSizes[ind] : "" + MEL["slide" fontSizes[ind], MELOPEN] = "

" + MEL["slide" fontSizes[ind], MELCLOSE] = "
" + MEL["vcen" fontSizes[ind], MELOPEN] = "
" + MEL["vcen" fontSizes[ind], MELCLOSE] = "
" + MEL["title" fontSizes[ind], MELOPEN] = "
" + MEL["title" fontSizes[ind], MELCLOSE] = "
" + } + + # 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", MELSINGLE] = ORS \ +"

" ORS \ +" " + + MEL["rows", MELOPEN] = "
" # (layout-row > * is td) + MEL["rows", MELCLOSE] = "" #
+ + MEL["eqrows", MELOPEN] = "
" #
(layout-row > * is td) + MEL["eqrows", MELCLOSE] = "" + + MEL["newrow", MELSINGLE] = "
" #
+ + # + # Generated tags + # + + for (i = 1; i <= 9; i++) { + MEL["br" i, MELSINGLE] = "
" + } + for (i = 5; i <= 95; i++) { + standardPresentationTag("width" i "%") + } + + # + # Ordinary + # + + standardPresentationTag("fright") + standardPresentationTag("cont") +} + +function standardPresentationTag(name) { + MEL[name, MELOPEN] = "
" + MEL[name, MELCLOSE] = "
" +} + +/\[SLIDEID\]/ { + sub(/\[SLIDEID\]/, slideIndex++) +} -- cgit v1.3.1-26-gb76a From 867b5015fda689bc5414557557a00cd8ad62699d Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 12:51:29 +0200 Subject: (awk-edits) Properly implemented MEL paragraph tag --- awk-edits/MEL-Presentation.awk | 8 +++---- awk-edits/MEL-parser.awk | 53 ++++++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 22 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk index 849a8f8..7fae51d 100644 --- a/awk-edits/MEL-Presentation.awk +++ b/awk-edits/MEL-Presentation.awk @@ -1,4 +1,4 @@ -# .*(slides|teaching)/.*html +# .*html BEGIN { # @@ -43,7 +43,7 @@ BEGIN { # Special cases # - MEL["presentation", MELSINGLE] = ORS \ + MEL["presentation", MELINSERT] = ORS \ "
(layout-row > * is td) MEL["eqrows", MELCLOSE] = "" - MEL["newrow", MELSINGLE] = "
" #
+ MEL["newrow", MELINSERT] = "
" #
# # Generated tags # for (i = 1; i <= 9; i++) { - MEL["br" i, MELSINGLE] = "
" + MEL["br" i, MELINSERT] = "
" } for (i = 5; i <= 95; i++) { standardPresentationTag("width" i "%") diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index ebd68bd..d1eb4d5 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -1,4 +1,4 @@ -# .*(slides|teaching)/.*html +# .*html # # == About == # @@ -29,9 +29,11 @@ BEGIN { newStack("mel") - MELSINGLE = "s" - MELOPEN = "o" - MELCLOSE = "c" + MELOPEN = "o" + MELCLOSE = "c" + MELINSERT = "s" + MELPARAGRAPH = "p" + MELLINE = "l" } // { @@ -42,37 +44,52 @@ BEGIN { melInsideCode = 0 } -melInsideCode == 0 && /^[ \t]*(

)?&/ { +melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { newLine = "" lineCopy = $0 - while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:[{(<>)}\]&]+)|[\]})])/)) { - RSTART = RSTART + 5 - RLENGTH = RLENGTH - 5 + paragraphed = 0 + while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { + RSTART += 5 + RLENGTH -= 5 # Inside closing tag if (RLENGTH == 1) { replaceWith = MEL[topStack("mel"), MELCLOSE] popStack("mel") } - # Inside opening tag - else if (substr(lineCopy, RSTART, 1) ~ /[[{(]/) { + # Inside insert + else if (substr(lineCopy, RSTART, 1) == ".") { name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - replaceWith = MEL[name, MELOPEN] - pushStack("mel", name) + replaceWith = MEL[name, MELINSERT] + } + # Inside one line TODO + else if (substr(lineCopy, RSTART, 2) == "::") { + name = substr(lineCopy, RSTART + 2, RLENGTH - 2) + + # RLENGTH = length(lineCopy) + replaceWith = MEL[name, MELLINE] + } + # Inside paragraph + else if (substr(lineCopy, RSTART, 1) == ":") { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = " " MEL[name, MELPARAGRAPH] + RSTART -= 1 + RLENGTH += 1 + paragraphed = 1 } - # Inside paragraph/one line/insert - # TODO: currently all work as insert + # Inside opening tag else { - nameStart = 1 + (substr(lineCopy, RSTART + 1, 1) == ":") - name = substr(lineCopy, RSTART + nameStart, RLENGTH - nameStart) + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - replaceWith = MEL[name, MELSINGLE] + replaceWith = MEL[name, MELOPEN] + pushStack("mel", name) } newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith lineCopy = substr(lineCopy, RSTART + RLENGTH) } $0 = newLine lineCopy - if (length(newLine) > 0) + if (paragraphed == 0 && length(newLine) > 0) gsub(/(

|<\/p>)/, "") } -- cgit v1.3.1-26-gb76a From 125616dd74ee83dbf34a0c862eafeb2ca79560b0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 12:52:11 +0200 Subject: (awk-edits) Reworked Icons.awk into MEL format --- awk-edits/MEL-Iconified.awk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 awk-edits/MEL-Iconified.awk (limited to 'awk-edits') diff --git a/awk-edits/MEL-Iconified.awk b/awk-edits/MEL-Iconified.awk new file mode 100644 index 0000000..9c7655f --- /dev/null +++ b/awk-edits/MEL-Iconified.awk @@ -0,0 +1,26 @@ +# .*html + +BEGIN { + # + # Flags + # + + melFlagTag("gb", "ENG") + melFlagTag("bg", "BGN") + + # + # Noteworthy paragraphs + # + + melParTag("question", "dialog-question.png") + melParTag("warn", "dialog-warning.png") + melParTag("important", "dialog-important.png") +} + +function melFlagTag(name, alt) { + MEL[name, MELINSERT] = "\""" +} + +function melParTag(name, image) { + MEL[name, MELPARAGRAPH] = "class=\"special-par " name "-par\">\""" +} -- cgit v1.3.1-26-gb76a From 1105938f1226f419dbf177caa50d2802544bdc8b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 12:54:51 +0200 Subject: (awk-edits) Renamed mel parser file so it's always before custom mel scripts --- awk-edits/MEL--Parser.awk | 95 +++++++++++++++++++++++++++++++++++++++++++++++ awk-edits/MEL-parser.awk | 95 ----------------------------------------------- 2 files changed, 95 insertions(+), 95 deletions(-) create mode 100644 awk-edits/MEL--Parser.awk delete mode 100644 awk-edits/MEL-parser.awk (limited to 'awk-edits') diff --git a/awk-edits/MEL--Parser.awk b/awk-edits/MEL--Parser.awk new file mode 100644 index 0000000..d1eb4d5 --- /dev/null +++ b/awk-edits/MEL--Parser.awk @@ -0,0 +1,95 @@ +# .*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 { + newStack("mel") + MELOPEN = "o" + MELCLOSE = "c" + MELINSERT = "s" + MELPARAGRAPH = "p" + MELLINE = "l" +} + +// { + melInsideCode = 1 +} + +/<\/code>/ { + melInsideCode = 0 +} + +melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { + newLine = "" + lineCopy = $0 + paragraphed = 0 + while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { + RSTART += 5 + RLENGTH -= 5 + + # Inside closing tag + if (RLENGTH == 1) { + replaceWith = MEL[topStack("mel"), MELCLOSE] + popStack("mel") + } + # Inside insert + else if (substr(lineCopy, RSTART, 1) == ".") { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = MEL[name, MELINSERT] + } + # Inside one line TODO + else if (substr(lineCopy, RSTART, 2) == "::") { + name = substr(lineCopy, RSTART + 2, RLENGTH - 2) + + # RLENGTH = length(lineCopy) + replaceWith = MEL[name, MELLINE] + } + # Inside paragraph + else if (substr(lineCopy, RSTART, 1) == ":") { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = " " MEL[name, MELPARAGRAPH] + RSTART -= 1 + RLENGTH += 1 + paragraphed = 1 + } + # Inside opening tag + else { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = MEL[name, MELOPEN] + pushStack("mel", name) + } + newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith + lineCopy = substr(lineCopy, RSTART + RLENGTH) + } + $0 = newLine lineCopy + if (paragraphed == 0 && length(newLine) > 0) + gsub(/(

|<\/p>)/, "") +} diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk deleted file mode 100644 index d1eb4d5..0000000 --- a/awk-edits/MEL-parser.awk +++ /dev/null @@ -1,95 +0,0 @@ -# .*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 { - newStack("mel") - MELOPEN = "o" - MELCLOSE = "c" - MELINSERT = "s" - MELPARAGRAPH = "p" - MELLINE = "l" -} - -// { - melInsideCode = 1 -} - -/<\/code>/ { - melInsideCode = 0 -} - -melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { - newLine = "" - lineCopy = $0 - paragraphed = 0 - while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { - RSTART += 5 - RLENGTH -= 5 - - # Inside closing tag - if (RLENGTH == 1) { - replaceWith = MEL[topStack("mel"), MELCLOSE] - popStack("mel") - } - # Inside insert - else if (substr(lineCopy, RSTART, 1) == ".") { - name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - - replaceWith = MEL[name, MELINSERT] - } - # Inside one line TODO - else if (substr(lineCopy, RSTART, 2) == "::") { - name = substr(lineCopy, RSTART + 2, RLENGTH - 2) - - # RLENGTH = length(lineCopy) - replaceWith = MEL[name, MELLINE] - } - # Inside paragraph - else if (substr(lineCopy, RSTART, 1) == ":") { - name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - - replaceWith = " " MEL[name, MELPARAGRAPH] - RSTART -= 1 - RLENGTH += 1 - paragraphed = 1 - } - # Inside opening tag - else { - name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - - replaceWith = MEL[name, MELOPEN] - pushStack("mel", name) - } - newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith - lineCopy = substr(lineCopy, RSTART + RLENGTH) - } - $0 = newLine lineCopy - if (paragraphed == 0 && length(newLine) > 0) - gsub(/(

|<\/p>)/, "") -} -- cgit v1.3.1-26-gb76a From ab29c6dfd0c640b831e94d56cd3718d4db0dfd0c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 14:39:00 +0200 Subject: (awk-edits) MEL scripts now require a function so there are no script ordering problems Before if MEL--Parser wasn't put before other MEL files by find command, MEL.... variables wouldn't init and results would be unuseable --- awk-edits/MEL--Parser.awk | 6 +++++- awk-edits/MEL-Iconified.awk | 1 + awk-edits/MEL-Presentation.awk | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL--Parser.awk b/awk-edits/MEL--Parser.awk index d1eb4d5..248eff2 100644 --- a/awk-edits/MEL--Parser.awk +++ b/awk-edits/MEL--Parser.awk @@ -28,10 +28,14 @@ # So it will surf as a separator between direct subelements BEGIN { + usesMEL() newStack("mel") +} + +function usesMEL() { MELOPEN = "o" MELCLOSE = "c" - MELINSERT = "s" + MELINSERT = "i" MELPARAGRAPH = "p" MELLINE = "l" } diff --git a/awk-edits/MEL-Iconified.awk b/awk-edits/MEL-Iconified.awk index 9c7655f..bbe353d 100644 --- a/awk-edits/MEL-Iconified.awk +++ b/awk-edits/MEL-Iconified.awk @@ -1,6 +1,7 @@ # .*html BEGIN { + usesMEL() # # Flags # diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk index 7fae51d..408ef6f 100644 --- a/awk-edits/MEL-Presentation.awk +++ b/awk-edits/MEL-Presentation.awk @@ -1,6 +1,7 @@ # .*html BEGIN { + usesMEL() # # Elements, dependent (and semidependent) on available font size # -- cgit v1.3.1-26-gb76a From 82d49ec07ee13b5c4726a29a6267b9ee83891b4d Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 14:39:24 +0200 Subject: (awk-edits) Ported File-type.awk to MEL --- awk-edits/MEL-Iconified.awk | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'awk-edits') diff --git a/awk-edits/MEL-Iconified.awk b/awk-edits/MEL-Iconified.awk index bbe353d..332be46 100644 --- a/awk-edits/MEL-Iconified.awk +++ b/awk-edits/MEL-Iconified.awk @@ -16,6 +16,17 @@ BEGIN { 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) { @@ -25,3 +36,7 @@ function melFlagTag(name, alt) { function melParTag(name, image) { MEL[name, MELPARAGRAPH] = "class=\"special-par " name "-par\">\""" } + +function melFiletypeTag(name, repl) { + MEL[name, MELINSERT] = "" repl "" +} -- cgit v1.3.1-26-gb76a From 3fc1b4e5b19a8d2150e9272ab894b678ce90c7d6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 14:39:49 +0200 Subject: (awk-edits) Reverted to old MEL parser file name --- awk-edits/MEL--Parser.awk | 99 ----------------------------------------------- awk-edits/MEL-parser.awk | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 99 deletions(-) delete mode 100644 awk-edits/MEL--Parser.awk create mode 100644 awk-edits/MEL-parser.awk (limited to 'awk-edits') diff --git a/awk-edits/MEL--Parser.awk b/awk-edits/MEL--Parser.awk deleted file mode 100644 index 248eff2..0000000 --- a/awk-edits/MEL--Parser.awk +++ /dev/null @@ -1,99 +0,0 @@ -# .*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" - MELINSERT = "i" - MELPARAGRAPH = "p" - MELLINE = "l" -} - -// { - melInsideCode = 1 -} - -/<\/code>/ { - melInsideCode = 0 -} - -melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { - newLine = "" - lineCopy = $0 - paragraphed = 0 - while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { - RSTART += 5 - RLENGTH -= 5 - - # Inside closing tag - if (RLENGTH == 1) { - replaceWith = MEL[topStack("mel"), MELCLOSE] - popStack("mel") - } - # Inside insert - else if (substr(lineCopy, RSTART, 1) == ".") { - name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - - replaceWith = MEL[name, MELINSERT] - } - # Inside one line TODO - else if (substr(lineCopy, RSTART, 2) == "::") { - name = substr(lineCopy, RSTART + 2, RLENGTH - 2) - - # RLENGTH = length(lineCopy) - replaceWith = MEL[name, MELLINE] - } - # Inside paragraph - else if (substr(lineCopy, RSTART, 1) == ":") { - name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - - replaceWith = " " MEL[name, MELPARAGRAPH] - RSTART -= 1 - RLENGTH += 1 - paragraphed = 1 - } - # Inside opening tag - else { - name = substr(lineCopy, RSTART + 1, RLENGTH - 1) - - replaceWith = MEL[name, MELOPEN] - pushStack("mel", name) - } - newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith - lineCopy = substr(lineCopy, RSTART + RLENGTH) - } - $0 = newLine lineCopy - if (paragraphed == 0 && length(newLine) > 0) - gsub(/(

|<\/p>)/, "") -} diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk new file mode 100644 index 0000000..248eff2 --- /dev/null +++ b/awk-edits/MEL-parser.awk @@ -0,0 +1,99 @@ +# .*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" + MELINSERT = "i" + MELPARAGRAPH = "p" + MELLINE = "l" +} + +// { + melInsideCode = 1 +} + +/<\/code>/ { + melInsideCode = 0 +} + +melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { + newLine = "" + lineCopy = $0 + paragraphed = 0 + while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { + RSTART += 5 + RLENGTH -= 5 + + # Inside closing tag + if (RLENGTH == 1) { + replaceWith = MEL[topStack("mel"), MELCLOSE] + popStack("mel") + } + # Inside insert + else if (substr(lineCopy, RSTART, 1) == ".") { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = MEL[name, MELINSERT] + } + # Inside one line TODO + else if (substr(lineCopy, RSTART, 2) == "::") { + name = substr(lineCopy, RSTART + 2, RLENGTH - 2) + + # RLENGTH = length(lineCopy) + replaceWith = MEL[name, MELLINE] + } + # Inside paragraph + else if (substr(lineCopy, RSTART, 1) == ":") { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = " " MEL[name, MELPARAGRAPH] + RSTART -= 1 + RLENGTH += 1 + paragraphed = 1 + } + # Inside opening tag + else { + name = substr(lineCopy, RSTART + 1, RLENGTH - 1) + + replaceWith = MEL[name, MELOPEN] + pushStack("mel", name) + } + newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith + lineCopy = substr(lineCopy, RSTART + RLENGTH) + } + $0 = newLine lineCopy + if (paragraphed == 0 && length(newLine) > 0) + gsub(/(

|<\/p>)/, "") +} -- cgit v1.3.1-26-gb76a From 7fc2422f038e0f56a9ac489eb4676b7b4bf2b6b1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 15:37:46 +0200 Subject: (awk-edits/MEL) Properly implemented one line tags --- awk-edits/MEL-parser.awk | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index 248eff2..6cf0514 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -35,6 +35,8 @@ BEGIN { function usesMEL() { MELOPEN = "o" MELCLOSE = "c" + MELLINEOPEN = "lo" + MELLINECLOSE = "lc" MELINSERT = "i" MELPARAGRAPH = "p" MELLINE = "l" @@ -52,6 +54,7 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { newLine = "" lineCopy = $0 paragraphed = 0 + append = "" while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { RSTART += 5 RLENGTH -= 5 @@ -67,12 +70,12 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { replaceWith = MEL[name, MELINSERT] } - # Inside one line TODO + # Inside one line else if (substr(lineCopy, RSTART, 2) == "::") { name = substr(lineCopy, RSTART + 2, RLENGTH - 2) - # RLENGTH = length(lineCopy) - replaceWith = MEL[name, MELLINE] + replaceWith = MEL[name, MELLINEOPEN] + append = append MEL[name, MELLINECLOSE] } # Inside paragraph else if (substr(lineCopy, RSTART, 1) == ":") { @@ -93,7 +96,7 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith lineCopy = substr(lineCopy, RSTART + RLENGTH) } - $0 = newLine lineCopy - if (paragraphed == 0 && length(newLine) > 0) + $0 = newLine lineCopy append + if (paragraphed == 0 && newLine != "") gsub(/(

|<\/p>)/, "") } -- cgit v1.3.1-26-gb76a From 71ecd6d8d554ff23f0161b1c0e447bede9d41377 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 15:38:11 +0200 Subject: (awk-edits/MEL-Presentation) Made file regex less generic --- awk-edits/MEL-Presentation.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk index 408ef6f..0fdfabd 100644 --- a/awk-edits/MEL-Presentation.awk +++ b/awk-edits/MEL-Presentation.awk @@ -1,4 +1,4 @@ -# .*html +# .*(slides|teaching)/.*html BEGIN { usesMEL() -- cgit v1.3.1-26-gb76a From 6d437b04c4517783e682e2309cc9e0056883c488 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 15:48:19 +0200 Subject: (awk-edits/MEL) Added error messages --- awk-edits/MEL-parser.awk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'awk-edits') diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index 6cf0514..af1e26d 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -42,6 +42,11 @@ function usesMEL() { MELLINE = "l" } +function printErr(message) { + print "ERROR by MEL-parser.awk: " message " | Found in " FILENAME " at line " FNR " & column " RSTART + length(newLine) - 5 ":\n" $0 > "/dev/stderr" + print > "/dev/stderr" +} + // { melInsideCode = 1 } @@ -62,6 +67,10 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { # Inside closing tag if (RLENGTH == 1) { replaceWith = MEL[topStack("mel"), MELCLOSE] + + if (replaceWith == "") + printErr("Missing closing tag for \"" topStack("mel") "\"") + popStack("mel") } # Inside insert @@ -69,6 +78,9 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { 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) == "::") { @@ -76,6 +88,14 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { replaceWith = MEL[name, MELLINEOPEN] append = append MEL[name, MELLINECLOSE] + + + if (replaceWith == "" && append == "") + printErr("Unknown single line tag \"" name "\"") + else if (replaceWith == "") + printErr("Missing beginning for line tag \"" name "\"") + else + printErr("Missing ending for line tag \"" name "\"") } # Inside paragraph else if (substr(lineCopy, RSTART, 1) == ":") { @@ -85,6 +105,9 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { RSTART -= 1 RLENGTH += 1 paragraphed = 1 + + if (replaceWith == "") + printErr("Unknown paragraph tag \"" name "\"") } # Inside opening tag else { @@ -92,6 +115,9 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { 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) -- cgit v1.3.1-26-gb76a From 899f51f156dbcaa2457c1ccb7f210b3664bc8dc4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 15:57:00 +0200 Subject: (awk-edits/MEL) Error messages now underline which part of the line has the error --- awk-edits/MEL-parser.awk | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index af1e26d..90234d4 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -42,9 +42,15 @@ function usesMEL() { MELLINE = "l" } -function printErr(message) { - print "ERROR by MEL-parser.awk: " message " | Found in " FILENAME " at line " FNR " & column " RSTART + length(newLine) - 5 ":\n" $0 > "/dev/stderr" - print > "/dev/stderr" +function printErr(message, column, columnPointer) { + column = RSTART + length(newLine) - 5 + print "ERROR by MEL-parser.awk: " message " | Found in " FILENAME " at line " FNR " & column " column ":" > "/dev/stderr" + columnPointer = "" + for (i = -5; i < RLENGTH; i++) + columnPointer = "^" columnPointer + for (i = 1; i < column; i++) + columnPointer = " " columnPointer + print $0 "\n" columnPointer "\n" > "/dev/stderr" } // { -- cgit v1.3.1-26-gb76a From 3ba655be5403c57db776e57f41c07caaa9061b74 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 16:18:46 +0200 Subject: (awk-edits/MEL) Fixed logic for underline --- awk-edits/MEL-parser.awk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index 90234d4..f0a8f84 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -43,13 +43,13 @@ function usesMEL() { } function printErr(message, column, columnPointer) { - column = RSTART + length(newLine) - 5 + 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 = -5; i < RLENGTH; i++) - columnPointer = "^" columnPointer for (i = 1; i < column; i++) - columnPointer = " " columnPointer + columnPointer = columnPointer " " + for (i = -5; i < RLENGTH; i++) + columnPointer = columnPointer "^" print $0 "\n" columnPointer "\n" > "/dev/stderr" } @@ -95,7 +95,6 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { replaceWith = MEL[name, MELLINEOPEN] append = append MEL[name, MELLINECLOSE] - if (replaceWith == "" && append == "") printErr("Unknown single line tag \"" name "\"") else if (replaceWith == "") @@ -108,12 +107,13 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { name = substr(lineCopy, RSTART + 1, RLENGTH - 1) replaceWith = " " MEL[name, MELPARAGRAPH] + + if (replaceWith == " ") + printErr("Unknown paragraph tag \"" name "\"") + RSTART -= 1 RLENGTH += 1 paragraphed = 1 - - if (replaceWith == "") - printErr("Unknown paragraph tag \"" name "\"") } # Inside opening tag else { -- cgit v1.3.1-26-gb76a From 6c1c7ea9ab5cdb1a37c7d75fb85b73bff76dc1ac Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 26 Feb 2024 09:09:59 +0200 Subject: (awk-edits/MEL-Presentation) Renamed vcen to middle, rows to row, sqrows to sqrow and cont to column --- awk-edits/MEL-Presentation.awk | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk index 0fdfabd..2936312 100644 --- a/awk-edits/MEL-Presentation.awk +++ b/awk-edits/MEL-Presentation.awk @@ -26,8 +26,8 @@ BEGIN { fontClass = (ind != 0) ? " font" fontSizes[ind] : "" MEL["slide" fontSizes[ind], MELOPEN] = "
" MEL["slide" fontSizes[ind], MELCLOSE] = "
" - MEL["vcen" fontSizes[ind], MELOPEN] = "
" - MEL["vcen" fontSizes[ind], MELCLOSE] = "
" + MEL["middle" fontSizes[ind], MELOPEN] = "
" + MEL["middle" fontSizes[ind], MELCLOSE] = "
" MEL["title" fontSizes[ind], MELOPEN] = "
" MEL["title" fontSizes[ind], MELCLOSE] = "
" } @@ -55,11 +55,11 @@ BEGIN { "

" ORS \ " " - MEL["rows", MELOPEN] = "
" #
(layout-row > * is td) - MEL["rows", MELCLOSE] = "" #
+ MEL["row", MELOPEN] = "
" #
(layout-row > * is td) + MEL["row", MELCLOSE] = "" #
- MEL["eqrows", MELOPEN] = "
" #
(layout-row > * is td) - MEL["eqrows", MELCLOSE] = "" + MEL["sqrow", MELOPEN] = "
" #
(layout-row > * is td) + MEL["sqrow", MELCLOSE] = "" MEL["newrow", MELINSERT] = "
" #
@@ -79,7 +79,7 @@ BEGIN { # standardPresentationTag("fright") - standardPresentationTag("cont") + standardPresentationTag("column") } function standardPresentationTag(name) { -- cgit v1.3.1-26-gb76a From 7aecc3349ae2f8d47cff60ce7ee2bf03b8432fa5 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 26 Feb 2024 09:11:29 +0200 Subject: (awk-edits/MEL-Presentations) Fixed slide ID format --- awk-edits/MEL-Presentation.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk index 2936312..43c60f9 100644 --- a/awk-edits/MEL-Presentation.awk +++ b/awk-edits/MEL-Presentation.awk @@ -88,5 +88,5 @@ function standardPresentationTag(name) { } /\[SLIDEID\]/ { - sub(/\[SLIDEID\]/, slideIndex++) + sub(/\[SLIDEID\]/, "slide-" slideIndex++) } -- cgit v1.3.1-26-gb76a From d2a45f0f1f4f55faac06132714a4b343e0446d21 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 26 Feb 2024 09:12:10 +0200 Subject: (awk-edits/MEL-Presentations) Fixed centered tag not working with font size --- awk-edits/MEL-Presentation.awk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk index 43c60f9..b179502 100644 --- a/awk-edits/MEL-Presentation.awk +++ b/awk-edits/MEL-Presentation.awk @@ -21,15 +21,17 @@ BEGIN { # Tags which can exist without specified font-size for (ind in fontSizes) { - standardPresentationTag("centered" fontSizes[ind]) - fontClass = (ind != 0) ? " font" fontSizes[ind] : "" + MEL["slide" fontSizes[ind], MELOPEN] = "
" MEL["slide" fontSizes[ind], MELCLOSE] = "
" MEL["middle" fontSizes[ind], MELOPEN] = "
" MEL["middle" fontSizes[ind], MELCLOSE] = "
" MEL["title" fontSizes[ind], MELOPEN] = "
" MEL["title" fontSizes[ind], MELCLOSE] = "
" + + MEL["centered" fontSizes[ind], MELOPEN] = "
" + MEL["centered" fontSizes[ind], MELCLOSE] = "
" } # refer to definition of fontSizes[0] -- cgit v1.3.1-26-gb76a From 8d84c03574f122fbac78e5dba083e96bc59dff76 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 26 Feb 2024 09:54:16 +0200 Subject: (awk-edits/MEL-Pres) Renamed certain CSS classes to be more verbose --- awk-edits/MEL-Presentation.awk | 18 +++++----- src/presentation.css | 76 +++++++++++++++++++++--------------------- 2 files changed, 47 insertions(+), 47 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk index b179502..cabc928 100644 --- a/awk-edits/MEL-Presentation.awk +++ b/awk-edits/MEL-Presentation.awk @@ -25,13 +25,12 @@ BEGIN { MEL["slide" fontSizes[ind], MELOPEN] = "
" MEL["slide" fontSizes[ind], MELCLOSE] = "
" - MEL["middle" fontSizes[ind], MELOPEN] = "
" + MEL["middle" fontSizes[ind], MELOPEN] = "
" MEL["middle" fontSizes[ind], MELCLOSE] = "
" - MEL["title" fontSizes[ind], MELOPEN] = "
" + MEL["title" fontSizes[ind], MELOPEN] = "
" MEL["title" fontSizes[ind], MELCLOSE] = "
" - MEL["centered" fontSizes[ind], MELOPEN] = "
" - MEL["centered" fontSizes[ind], MELCLOSE] = "
" + standardPresentationTag("centered" fontSizes[ind], "centered" fontClass) } # refer to definition of fontSizes[0] @@ -70,22 +69,23 @@ BEGIN { # for (i = 1; i <= 9; i++) { - MEL["br" i, MELINSERT] = "
" + MEL["br" i, MELINSERT] = "
" } for (i = 5; i <= 95; i++) { - standardPresentationTag("width" i "%") + standardPresentationTag("width" i "%", "width" i "per") } # # Ordinary # - standardPresentationTag("fright") + standardPresentationTag("fright", "float-right") standardPresentationTag("column") } -function standardPresentationTag(name) { - MEL[name, MELOPEN] = "
" +function standardPresentationTag(name, class) { + if (class == "") class = name + MEL[name, MELOPEN] = "
" MEL[name, MELCLOSE] = "
" } diff --git a/src/presentation.css b/src/presentation.css index cc82b04..7dbb26a 100644 --- a/src/presentation.css +++ b/src/presentation.css @@ -62,18 +62,18 @@ } .slide .h-anchor, .slide .gap, .slide .gap-small { display: none; } - .clide { display: flex; flex-direction: column; } - .clide > * { flex: 1; } + .centered-slide { display: flex; flex-direction: column; } + .centered-slide > * { flex: 1; } .centered, - .centered .width5, .centered .width10, .centered .width15, .centered .width20, - .centered .width25, .centered .width30, .centered .width35, .centered .width40, - .centered .width45, .centered .width50, .centered .width55, .centered .width60, - .centered .width65, .centered .width70, .centered .width75, .centered .width80, - .centered .width85, .centered .width90, .centered .width95 + .centered .width5per, .centered .width10per, .centered .width15per, .centered .width20per, + .centered .width25per, .centered .width30per, .centered .width35per, .centered .width40per, + .centered .width45per, .centered .width50per, .centered .width55per, .centered .width60per, + .centered .width65per, .centered .width70per, .centered .width75per, .centered .width80per, + .centered .width85per, .centered .width90per, .centered .width95per { margin-left: auto; margin-right: auto; text-align: center; } - .fright { float: right; text-align: right; } - * + .fright { margin-left: 1em; } + .float-right { float: right; text-align: right; } + * + .float-right { margin-left: 1em; } .layout-table { margin: 0; @@ -100,35 +100,35 @@ .font27 { font-size: 27px; } .font35 { font-size: 35px; } - .lineb1 { padding: 0.5em; } - .lineb2 { padding: 1.0em; } - .lineb3 { padding: 1.5em; } - .lineb4 { padding: 2.0em; } - .lineb5 { padding: 2.5em; } - .lineb6 { padding: 3.0em; } - .lineb7 { padding: 3.5em; } - .lineb8 { padding: 4.0em; } - .lineb9 { padding: 4.5em; } - - .width5 { width: 5%; } - .width10 { width: 10%; } - .width15 { width: 15%; } - .width20 { width: 20%; } - .width25 { width: 25%; } - .width30 { width: 30%; } - .width35 { width: 35%; } - .width40 { width: 40%; } - .width45 { width: 45%; } - .width50 { width: 50%; } - .width55 { width: 55%; } - .width60 { width: 60%; } - .width65 { width: 65%; } - .width70 { width: 70%; } - .width75 { width: 75%; } - .width80 { width: 80%; } - .width85 { width: 85%; } - .width90 { width: 90%; } - .width95 { width: 95%; } + .br1 { padding: 0.5em; } + .br2 { padding: 1.0em; } + .br3 { padding: 1.5em; } + .br4 { padding: 2.0em; } + .br5 { padding: 2.5em; } + .br6 { padding: 3.0em; } + .br7 { padding: 3.5em; } + .br8 { padding: 4.0em; } + .br9 { padding: 4.5em; } + + .width5per { width: 5%; } + .width10per { width: 10%; } + .width15per { width: 15%; } + .width20per { width: 20%; } + .width25per { width: 25%; } + .width30per { width: 30%; } + .width35per { width: 35%; } + .width40per { width: 40%; } + .width45per { width: 45%; } + .width50per { width: 50%; } + .width55per { width: 55%; } + .width60per { width: 60%; } + .width65per { width: 65%; } + .width70per { width: 70%; } + .width75per { width: 75%; } + .width80per { width: 80%; } + .width85per { width: 85%; } + .width90per { width: 90%; } + .width95per { width: 95%; } /* Presenting mode -- cgit v1.3.1-26-gb76a From ec0c6a69f984532992314e7c0c9a354f4fccec54 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 26 Feb 2024 12:52:50 +0200 Subject: [awk-edits] Removed old ftag scripts --- awk-edits/File-type.awk | 97 ------------------- awk-edits/Icons.awk | 30 ------ awk-edits/Presentation.awk | 233 --------------------------------------------- 3 files changed, 360 deletions(-) delete mode 100644 awk-edits/File-type.awk delete mode 100644 awk-edits/Icons.awk delete mode 100644 awk-edits/Presentation.awk (limited to 'awk-edits') 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 -- -# -#
-# Folder Info -#
-# File Data -#
-# -# or -# -# File Data -#
- -# -# == 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 , and 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
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
-# Status: 70% complete
-# 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, "" repl "") -} - -/&&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/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, - "\""") -} - -/&&gb/ { flagSub("gb", "ENG") } -/&&bg/ { flagSub("bg", "BGN") } - -function articleIconSub(name, filename) { - sub("p>&&" name, - "p class=\"special-par " name "-par\">\\&\\&" name) - gsub("&&" name, - "\""") -} - -/&&question/ { articleIconSub("question", "dialog-question.png") } -/&&warn/ { articleIconSub("warn", "dialog-warning.png") } -/&&important/ { articleIconSub("important", "dialog-important.png") } 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 `
` - # &&/examp is usually replaced by `
` - # in case ended[i] = 2, &&examp is replaced by `
` - - # 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 \ -"

" ORS \ -" " - - for (i = 1; i <= nameslength; i++) { - pat[i] = "&&" names[i] - rep[i] = "
" - - if (ended[i] == 1) { - cpat[i] = "&&/" names[i] - crep[i] = "
" - } - else if (ended[i] == 2) { - rep[i] = rep[i] "
" - } - } - - rep[ 1] = pres - rep[ 3] = "
" # flex-col + flex:1 +
- crep[3] = "
" #
+ flex:1 + /flex-col - rep[ 4] = "
" # (layout-row > * is td) - crep[4] = "" #
- rep[ 5] = "
" #
(layout-row > * is td) - rep[ 6] = "
" #
- rep[ 7] = "" # &&/font - rep[26] = "" # &&/width - - presInsideCode = 0 - slideIndex = 0 -} - -function presentationSubstitute(ind) { - gsub(/(

|<\/p>)/, "") - if ((ind == 2 || ind == 3) && index($0, pat[ind]) != 0) { # &&slide or &&clide - gsub(pat[ind], "

/ { - presInsideCode = 1 -} - -/<\/code>/ { - presInsideCode = 0 -} - -presInsideCode == 0 && /^[ \t]*(

)?&&/ { - for (i = 1; i <= nameslength; i++) { - if (index($0, names[i]) != 0) - presentationSubstitute(i) - } -} -- cgit v1.3.1-26-gb76a From 65761da843606786bbd2f38f4e22a7ea117a6644 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 28 Feb 2024 08:26:30 +0200 Subject: [awk-edits/MEL] Fixed single-line tag error logic --- awk-edits/MEL-parser.awk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'awk-edits') diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index f0a8f84..777caa1 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -95,12 +95,12 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { replaceWith = MEL[name, MELLINEOPEN] append = append MEL[name, MELLINECLOSE] - if (replaceWith == "" && append == "") - printErr("Unknown single line tag \"" name "\"") - else if (replaceWith == "") + if (replaceWith == "") printErr("Missing beginning for line tag \"" name "\"") - else + 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) == ":") { -- cgit v1.3.1-26-gb76a From a1c2d8fe71cb1585a917424bacd4aed35d389cc2 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 28 Feb 2024 10:38:40 +0200 Subject: [awk-edits/MEL-Teaching] Added special styles and single line tag for teaching articles --- awk-edits/MEL-Teaching.awk | 8 ++++++++ src/styles.csma | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 awk-edits/MEL-Teaching.awk (limited to 'awk-edits') 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] = "
<" + MEL["solution-link", MELLINECLOSE] = " >
" +} diff --git a/src/styles.csma b/src/styles.csma index 2b8f9d3..764e2ec 100644 --- a/src/styles.csma +++ b/src/styles.csma @@ -257,6 +257,7 @@ {} {} {} + {} {} @@ -344,6 +345,19 @@ } } +
{ + { + .exercise-solution { + float: right; + font-weight: bold; + } + + /* Slightly smaller than browser defaults https://stackoverflow.com/a/70720104/12036073 https://stackoverflow.com/a/47560151/12036073 */ + h2 ~ .exercise-solution { font-size: 1.4em; margin-top: 0.6em; } + h3 ~ .exercise-solution { font-size: 1.1em; margin-top: 0.8em; } +} +} +
{ { -- cgit v1.3.1-26-gb76a From c2e4d7c2c124f71c768072d8ccbe17aa8e06fa2c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 3 Apr 2024 18:57:22 +0300 Subject: [awk-edits/Pagenav] Added breadcrumbs navigation --- awk-edits/Pagenav.awk | 28 ++++++++++++++++++++++++++-- src/styles.csma | 5 ++++- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'awk-edits') 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 && /

" ORS \ +" Reading: " (int(words / 180) + 1) " min || Created: " created " || Edited: " edited "" ORS \ +" || GitLab source" ORS \ +"

" + + # Breadcrumbs element + sub(/\/[^/]*$/, "", path) + foldersLen = split(path, folders, "/") + + href = ".." + breadcrumb = " » " folders[foldersLen] "" + for (i = foldersLen-1; i > 0; i--) { + breadcrumb = " » " "" folders[i] "" breadcrumb + href = "../" href + } + breadcrumb = \ +"
" ORS \ +" " breadcrumb ORS \ +"
" + + # Pagenav element $0 = $0 ORS \ "
" ORS \ -" Reading: " (int(words / 180) + 1) " min || Created: " created " || Edited: " edited "" ORS \ -" || GitLab source" ORS \ + stats ORS \ + breadcrumb ORS \ "
" nopagenav = 1 diff --git a/src/styles.csma b/src/styles.csma index 764e2ec..29d63fe 100644 --- a/src/styles.csma +++ b/src/styles.csma @@ -320,8 +320,11 @@ font-size: 0.8em; margin: 0 0 3rem 2rem; } - #pagenav > * { white-space: nowrap; } + #pagenav strong, #pagenav a { white-space: nowrap; } #pagenav + h2, #pagenav + h3, #pagenav + h4 { margin-top: 0; } + + #pagenav-breadcrumb { font-weight: bold; } + #pagenav-breadcrumb em { font-weight: normal; } } } -- cgit v1.3.1-26-gb76a From e80e02cb52f4d7d67b257a5f72e7fbe28c5b74f9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 10 Aug 2024 15:31:25 +0300 Subject: feat!: Removed CSMA, made minor styling changes --- .gitmodules | 3 - awk-edits/Heading-anchors.awk | 2 +- csma | 1 - generate.sh | 14 +- src/_header.html | 34 +-- src/scripts/expand-navbar.js | 8 +- src/scripts/page-width.js | 4 +- src/styles.csma | 656 ------------------------------------------ src/styles.css | 498 ++++++++++++++++++++++++++++++++ 9 files changed, 524 insertions(+), 696 deletions(-) delete mode 160000 csma delete mode 100644 src/styles.csma create mode 100644 src/styles.css (limited to 'awk-edits') diff --git a/.gitmodules b/.gitmodules index b36ee4c..600c751 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "csg"] path = csg url = https://gitlab.com/Syndamia/csg.git -[submodule "csma"] - path = csma - url = https://gitlab.com/Syndamia/csma.git 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 = "
" ORS } match($0, /id="[^"]*"/) - $0 = gap $0 ORS "§" + $0 = gap $0 ORS "#" } diff --git a/csma b/csma deleted file mode 160000 index a00471f..0000000 --- a/csma +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a00471ff2e26fa5f1cb6be4d9ba3d3dbdff0a578 diff --git a/generate.sh b/generate.sh index 7240951..43023af 100755 --- a/generate.sh +++ b/generate.sh @@ -31,17 +31,7 @@ EOF /usr/bin/env dash ./csg/csg "$REPO_FOLDER/src" "$GEN_FOLDER" '& \\— Syndamia' 'https://syndamia.com' "$AWK_FOLDER" # }}} -# 2. CSMA to CSS {{{ - echo "[Stage 3] CSMA" - while read -r stylesheet - do - /usr/bin/env -S awk -f './csma/csmap.awk' "$stylesheet" > "${stylesheet:0: -4}css" - rm "$stylesheet" - done << EOF -$(find "$GEN_FOLDER" -type f -name "*.csma") -EOF -# }}} -# 3. Tiny version, strip away styles and other stuff {{{ +# 2. Tiny version, strip away styles and other stuff {{{ [ ! -d "$GEN_TINY_FOLDER" ] && mkdir "$GEN_TINY_FOLDER" [ $# -eq 0 -a "$(stat -c %U "$GEN_TINY_FOLDER")" != "www-data" ] && echo "[Warning] Running in \"production\" while $GEN_TINY_FOLDER isn't owned by www-data!" @@ -63,7 +53,7 @@ EOF done } - echo "[Stage 4] Tiny website" + echo "[Stage 3] Tiny website" if [ $# -eq 0 ]; then improveForTINY diff --git a/src/_header.html b/src/_header.html index 817318c..16c1d00 100644 --- a/src/_header.html +++ b/src/_header.html @@ -25,7 +25,7 @@
- - .no-wrap { - color: inherit; - vertical-align: baseline; - white-space: nowrap; - } - - -} - -
{ - -{ - .gap, .gap-small { - background-color: var(--body-bg); - margin: 0 -1em; - } - .gap { height: 1.5em; } - .gap-small { height: 0.5em; } -} -} - -
{ -
-{ - article > footer { - margin: 0 -1em; - padding: 0.5em; - border: 3px solid var(--accent-line-color); - border-left: none; - border-right: none; - } -} -} - -
{ - -{ - #contents-container { float: right; margin-left: 2.5em; background-color: var(--bg-color); padding-right: 0.5em; } - #contents-container > h2 { margin-top: -1rem; } -} -} - -
{ - -{ - #pagenav { - filter: opacity(64%); - font-size: 0.8em; - margin: 0 0 3rem 2rem; - } - #pagenav strong, #pagenav a { white-space: nowrap; } - #pagenav + h2, #pagenav + h3, #pagenav + h4 { margin-top: 0; } - - #pagenav-breadcrumb { font-weight: bold; } - #pagenav-breadcrumb em { font-weight: normal; } -} -} - -
{ - -{ - .special-par { - position: relative; - padding: 0.5em; - padding-left: calc(32px + 1em); - } - .question-par { border-left: 2px solid #4a85cb; } - .warn-par { border: 2px dashed #fac848; } - .important-par { border: 2px solid #f46062; } - .special-par-icon { vertical-align: middle; } - .special-par > .special-par-icon { - position: absolute; - left: 0.5em; - top: calc(50% - 16px); - } -} -} - -
{ - { - .exercise-solution { - float: right; - font-weight: bold; - } - - /* Slightly smaller than browser defaults https://stackoverflow.com/a/70720104/12036073 https://stackoverflow.com/a/47560151/12036073 */ - h2 ~ .exercise-solution { font-size: 1.4em; margin-top: 0.6em; } - h3 ~ .exercise-solution { font-size: 1.1em; margin-top: 0.8em; } -} -} - -
{ - -{ - { - #about-image { - float: right; - margin-right: 1em; - margin-top: 2em; - max-width: 7.6em; - } - } -} -} - - { - h1, h2, h3, h4, h5, h6 { - color: var(--header-color); - display: inline-block; - line-height: 1.25em; - border-bottom: 2px solid var(--border-color); - } - h1 { display: block; font-size: 1.7em; margin-block-end: 0.5em; } - - h1 + *, h1 ~ h1, h2 + a + *, h3 + a + *, h4 + a + *, h5 + a + *, h6 + a + * { - margin-top: 0; - } - .h-anchor { color: var(--fg-color); border: none; } - - /* Slightly smaller than browser defaults https://stackoverflow.com/a/70720104/12036073 */ - h2 + .h-anchor { font-size: 1.4em; } - h3 + .h-anchor { font-size: 1.1em; } -} - - { - a, a strong { - border-bottom: 1px dashed; - color: var(--a-color); - text-decoration: none; - } - sup a, dt a { border: none; } - a * { color: var(--fg-color); } - a:hover, a strong:hover { color: var(--a-hover-color); } -} - - { - i, em { color: var(--em-color); } -} - - { - strong { color: var(--strong-color); } -} - -
{ - blockquote { - border-left: .25em solid var(--blockquote-border-color); - color: var(--blockquote-color); - margin: 0; - margin-top: 0; - margin-bottom: 16px; - padding: 0 1em; - } - blockquote > :first-child { margin-top: 0; } - blockquote > :last-child { margin-bottom: 0; } -} - - { - dt, dd { - border: 2px solid var(--border-color); - border-bottom: none; - border-top: none; - padding: 0 0.5em; - } - dt { font-size: 1.2em; padding-top: 0.2em; } - dt * { vertical-align: middle; } - dd { - line-height: 1.5em; - margin-bottom: 1em; - margin-left: 0; - padding-bottom: 0.4em; - padding-left: 49px; - } -} - - { - img { - box-sizing: border-box; - max-width: 100%; - } - img, hr { border: 1px solid var(--border-color); } - dt img, .svg { box-sizing: border-box; max-height: 1em; } - .pixelated-render { image-rendering: pixelated; } - .oldschool-badge { height: 38px; } - .flag { max-width: 1.3em; } /* Compatibility with Chrome 49.0.2623.112 (for old machines) */ - - .file-type-icon { min-width: 1.3em; vertical-align: middle; } - .borderless, .oldschool-badge, .file-type-icon { border: none; } -} - - { - /* The following CSS is a modified version of sindresorhus's github-markdown-css repo: https://github.com/sindresorhus/github-markdown-css */ - code, pre { - font-family: monospace; - font-size: 85%; - } - -
 {
-    pre {
-      overflow: auto;
-      word-break: normal;
-      word-wrap: normal;
-    }
-  }
-
-   {
-    code {
-      background-color: var(--pre-bg-color);
-      margin: 0;
-      padding: 0 0.4em;
-    }
-    pre code {
-      border: 0;
-      display: inline-block;
-      font-size: 100%;
-      overflow: visible;
-      padding: 0;
-      word-wrap: normal;
-    }
-    pre > code {
-      white-space: pre-wrap;
-      word-break: break-all;
-      padding: 0.9em;
-      width: 100%;
-      box-sizing: border-box;
-    }
-
-    table code {
-      font-size: 0.7em;
-      white-space: normal;
-    }
-    dd code { font-size: 0.8em; }
-  }
-
-   {}
-  .language-terminal {
-    color: var(--terminal-fg);
-    background-color: var(--terminal-bg);
-  }
-}
-
-
{ - table { - border-spacing: 0; - border-collapse: collapse; - margin: 1em 0; - overflow: auto; - } - table td, table th { word-break: normal !important; } - table td:not(:first-of-type), table th:not(:first-of-type) { - border-left: 2px dashed var(--table-border-color); - } - table td, table th { padding: 0.5em; } - table th { - font-size: 1.1em; - font-weight: bold; - } - table td:empty { height: 1em; } - - table tr { - background-color: var(--tr-bg-color); - } - thead tr { - border-bottom: 2px dashed var(--table-border-color); - } - table tr:nth-child(2n), thead tr { - background-color: var(--alternating-row-color); - } -} - -/* Small screen support */ - -@media screen and ((max-width: 610px) or (max-height: 610px)) { - article { - border-top: none; - max-width: calc(100vw - 16px - 3px); - } - table td, table th { word-break: break-all; } - - #about-image { max-width: 4.38em; } - - #content-wrapper { flex-direction: column; } - #sidebar { - max-width: initial; - margin: 0; - } - #sidebar > * { border-right: none; } - .sidebar-hidden { position: initial; } - .sidebar-hidden > :not(#header) { display: none; } - .sidebar-hidden + .noMaxWidth { margin-top: 0; } - /* page-width.js */ - #changeWidthBtn { display: none; } -} - -/* Printing support */ - -@media print { - h2 + a img, h3 + a img, h4 + a img, h5 + a img, h6 + a img, - nav, #scrollBtn, .gap, .gap-small { - display: none !important; - } - - body { margin: 0; } - body, article { - background-color: white; - border: none !important; - } - - pre, code { white-space: pre-wrap !important; } - .language-terminal { color: var(--fg-color); background-color: var(--bg-color); } - .slide, .absolute-slide { transform: none !important; margin: 0; } -} - - { - { - #expandNavbarBtn { float: right; margin-left: 1em; } - .sidebar-hidden { min-height: auto; position: absolute; } - .sidebar-hidden > :not(#header) { display: none; } - .sidebar-hidden + .noMaxWidth { margin-top: 6em; } - } - - { - #scrollBtn { - font-size: 1.66rem; - padding: 0 0.15em; - bottom: 1rem; - right: 1rem; - z-index: 1; - transition-duration: 0.5s; - background-color: var(--bg-color); - display: none; - position: fixed; - border: 1px solid; - } - } - - { - .clicked-image { - height: 100vh; - width: 100vw; - max-width: none; - max-height: none; - padding: 1em; - background-color: var(--bg-color); - left: 0; - top: 0; - z-index: 2; - border: none; - object-fit: contain; - position: fixed; - } - .body-on-clicked-image { overflow: hidden; } - } - - { - .nodisplay { display: none; } - } -} - - - { - { - .HI-comment { color: var(--hi-comment); } - .HI-const { color: var(--hi-const); } - .HI-string { color: var(--hi-string); } - .HI-char { color: var(--hi-char); } - .HI-number { color: var(--hi-number); } - .HI-bool { color: var(--hi-bool); } - .HI-float { color: var(--hi-float); } - .HI-identifier { color: var(--hi-identifier); } - .HI-function { color: var(--hi-function); } - .HI-statement { color: var(--hi-statement); } - .HI-conditional { color: var(--hi-conditional); } - .HI-repeat { color: var(--hi-repeat); } - .HI-operator { color: var(--hi-operator); } - .HI-keyword { color: var(--hi-keyword); /* Label and Exception are keywords */ } - .HI-preproc { color: var(--hi-preproc); } - .HI-type { color: var(--hi-type); } - .HI-storageclass { color: var(--hi-storageclass); } - .HI-structure { color: var(--hi-structure); } - .HI-typedef { color: var(--hi-typedef); } - .HI-ignore { color: var(--hi-ignore); } - .HI-comment * { color: inherit; } /* If text inside a comment is matched, don't show it */ -} -} diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..ff394ac --- /dev/null +++ b/src/styles.css @@ -0,0 +1,498 @@ +:root { + --bg-color: white; + --fg-color: black; + + --body-bg: #ebe3d2; + --accent-line-color: #004080; + + --a-color: #336700; + --a-hover-color: #3ea100; + --bg-selection-color: #338fff; + --blockquote-color: #6a737d; + --blockquote-border-color: #dfe2e5; + --border-color: black; + --code-bg-color: var(--hi-bg); + --em-color: black; + --fg-selection-color: white; + --header-color: #006b8f; + --pre-bg-color: var(--hi-bg); + --strong-color: black; + --table-border-color: black; + --tr-bg-color: #fbfdff; + --alternating-row-color: #eef0f2; + + --terminal-fg: black; + --terminal-bg: white; + + /* https://github.com/morhetz/gruvbox/blob/master/autoload/gruvbox.vim */ + --hi-fg: var(--fg-color); + --hi-bg: #f5f5e2; + --hic-gray: #928374; + --hic-red: #fb4934; + --hic-green: #79740e; + --hic-blue: #076678; + --hic-yellow: #b57614; + --hic-purple: #8f3f71; + --hic-aqua: #427b58; + --hic-orange: #af3a03; + + --hi-comment: var(--hic-gray); + --hi-const: var(--hic-purple); + --hi-string: var(--hic-green); + --hi-char: var(--hic-purple); + --hi-number: var(--hic-purple); + --hi-bool: var(--hic-purple); + --hi-float: var(--hic-purple); + --hi-identifier: var(--hic-blue); + --hi-function: var(--hic-green); + --hi-statement: var(--hic-red); + --hi-conditional: var(--hic-red); + --hi-repeat: var(--hic-red); + --hi-operator: var(--hi-fg); + --hi-keyword: var(--hic-red); /* Label and Exception are keywords */ + --hi-preproc: var(--hic-aqua); + --hi-type: var(--hic-yellow); + --hi-storageclass: var(--hic-orange); + --hi-structure: var(--hic-aqua); + --hi-typedef: var(--hic-aqua); + --hi-ignore: var(--hi-fg); +} + +/*## Global ##*/ + +@font-face { + font-family: 'Tabler'; + src: url('/font/tabler-icons-subset.ttf') format('truetype'); +} + +body { + background-color: var(--body-bg); + border-color: var(--border-color); + color: var(--fg-color); + min-height: calc(100vh - 16px); + overflow-wrap: break-word; + + /* Stuff to make sure the font is rendered correctly on Safari + * https://stackoverflow.com/a/56065714/12036073 */ + font-rendering: optimizeLegibility; + font-weight: 400; + -webkit-font-kerning: normal; + -webkit-font-smoothing: antialiased; +} +body, td, th { font-size: 18px; font-family: 'Tabler', sans-serif; } +* { line-height: 1.3em; } + +/*## No-CSS compatibility ##*/ + + /* Inside _header we use , instead of
, because if your browser + * doesn't support CSS, we want most stuff to be aligned on a single line, rather than preserve + * the "vertical" layout */ +.br { display: block; } +.brt { display: block; height: 0.8em; } + /* Without CSS, certain stuff look bad or confusing, so with this I can add elements which + * add elements for helping with website usage, but which shouldn't be seen otherwise */ +.nocss-aid { display: none; } + +nav, article { background-color: var(--bg-color); } + +/*## Wrapper ##*/ + +#content-wrapper { + min-height: calc(100vh - 16px); + display: flex; + flex-direction: row; + border-right: 3px solid var(--accent-line-color); +} + +#content-wrapper.content-wrapper-vertical { border: none; flex-direction: column; } +.content-wrapper-vertical > #sidebar { max-width: initial; margin: 0; } +.content-wrapper-vertical .sidebar-section:not(#header) { display: none; } +.content-wrapper-vertical > article { margin-top: 8px; } + +/*## Wrapper > Sidebar ##*/ + +#sidebar { + background-color: var(--body-bg); + font-size: 1.2em; + margin-right: 8px; + max-width: 11.2em; +} +#sidebar a { border: none; } + +.sidebar-section { + border: 3px solid var(--accent-line-color); + box-sizing: border-box; + padding: 1rem 1rem; +} +.sidebar-section ~ .sidebar-section { margin-top: 8px; } + +/*### Wrapper > Sidebar > header ###*/ + +#header { border-right: none; + font-size: 1.5em; +} +#expandNavbarBtn { float: right; margin-left: 1em; } + +/*### Wrapper > Sidebar > index ###*/ + +#index { border-right: none; border-bottom: none; } +.index-list { + margin: 0 0 0.5em 0.3em; + padding-left: 0.5em; + display: block; + border-left: 2px solid var(--border-color); +} +.index-list-item, .index-list-item:hover { + line-height: 1.2em; + display: block; /* Compatibility with Chrome 49.0.2623.112 (for old machines) */ +} + +/*### Wrapper > Sidebar > settingsWrapper ###*/ + +#settingsWrapper { border-top: none; border-bottom: none; + font-size: 1.2em; + line-height: 1em; +} +#settingsWrapper > .setting-btn { font-size: 0.5em; } + +/*### Wrapper > Sidebar > footer ###*/ + +#footer { border-left: none; border-top: none; + font-size: 0.7em; + overflow-x: hidden; + white-space: nowrap; +} + +/*## Wrapper > Article ##*/ + +article { + border-top: 3px solid var(--accent-line-color); + box-sizing: border-box; + flex: 1; + max-width: 56em; /* Equivalent to 50em on 19px font-size */ + margin-bottom: 1em; + overflow: auto; + padding: 0 1em; + + margin-left: auto; + margin-right: auto; +} +.article-wide { + max-width: initial; + margin-left: initial; + margin-right: initial; +} + +/*### Wrapper > Article > page navigation ###*/ + +#pagenav { + filter: opacity(64%); + font-size: 0.8em; + margin: 0 0 3rem 2rem; +} +#pagenav + h2, #pagenav + h3, #pagenav + h4 { margin-top: 0; } + +/*### Wrapper > Article > contents ###*/ + +#contents-container { + float: right; + margin-left: 2.5em; + background-color: var(--bg-color); + padding-right: 0.5em; +} +#contents-container > h2 { margin-top: -1rem; } + +/*### Wrapper > Article > section gap ###*/ + +.gap, .gap-small { + background-color: var(--body-bg); + margin: 0 -1em; +} +.gap { height: 1.5em; } +.gap-small { height: 0.5em; } + +/*### Wrapper > Article > special paragraphs ###*/ + +.special-par { + position: relative; + padding: 0.5em; + padding-left: calc(32px + 1em); +} +.special-par-icon { + vertical-align: middle; + position: absolute; + left: 0.5em; + top: calc(50% - 16px); +} + +.question-par { border-left: 2px solid #4a85cb; } +.warn-par { border: 2px dashed #fac848; } +.important-par { border: 2px solid #f46062; } + +/*### Wrapper > Article > page-specific ###*/ + +/*#### Exercise solution ####*/ + +.exercise-solution { float: right; font-weight: bold; } + +/* Slightly smaller than browser defaults https://stackoverflow.com/a/70720104/12036073 https://stackoverflow.com/a/47560151/12036073 */ +h2 ~ .exercise-solution { font-size: 1.4em; margin-top: 0.6em; } +h3 ~ .exercise-solution { font-size: 1.1em; margin-top: 0.8em; } + +/*#### Face in about page ####*/ + +#about-image { + float: right; + margin: 2em 1em 0 0; + max-width: 7.6em; +} + +/*#### Markdown overrides ####*/ + +.footnotes { font-size: 0.9em; margin-top: 3em; } +a[rev="footnote"] { border: none; } + +.language-terminal { + color: var(--terminal-fg); + background-color: var(--terminal-bg); +} + +/*#### No-property ####*/ + +.nodisplay { display: none; } +.no-wrap { + color: inherit; + vertical-align: baseline; + white-space: nowrap; +} + +/*### Wrapper > Article > buttons ###*/ + +.btn:hover { cursor: pointer; } +.btn:active { transform: scale(0.9); } + +.setting-btn { + text-align: center; + display: inline-block; + line-height: 1em; + border: 1px solid var(--border-color); + padding: 0.4em; +} + +.btn, .h-anchor { + /* Thanks https://stackoverflow.com/a/4407335/12036073 */ + + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Old versions of Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; +} + +/*### Wrapper > Article > footer ###*/ + +article > footer { + margin: 0 -1em; + padding: 0.5em; + border: 3px solid var(--accent-line-color); + border-left: none; + border-right: none; +} + +/*### Wrapper > Article > h, h-anchor ###*/ + +h1, h2, h3, h4, h5, h6 { + color: var(--header-color); + display: inline-block; + line-height: 1.25em; + border-bottom: 2px solid var(--border-color); +} +h1 { display: block; font-size: 1.7em; margin-block-end: 0.5em; } + +h1 + *, h1 ~ h1, .h-anchor + * { margin-top: 0; } +.h-anchor { color: var(--fg-color); border: none; } + +/* Slightly smaller than browser defaults https://stackoverflow.com/a/70720104/12036073 */ +h2 + .h-anchor { font-size: 1.4em; } +h3 + .h-anchor { font-size: 1.1em; } + +/*### Wrapper > Article > a ###*/ + +a, a strong { + border-bottom: 1px dashed; + color: var(--a-color); + text-decoration: none; +} +a:hover, a strong:hover { color: var(--a-hover-color); } +sup a, dt a { border: none; } +a * { color: var(--fg-color); } + +/*### Wrapper > Article > i, em, strong ###*/ + +i, em { color: var(--em-color); } +strong { color: var(--strong-color); } + +/*### Wrapper > Article > blockquote ###*/ + +blockquote { + border-left: 0.25em solid var(--blockquote-border-color); + color: var(--blockquote-color); + margin: 0 0 16px 0; + padding: 0 1em; +} +blockquote > :first-child { margin-top: 0; } +blockquote > :last-child { margin-bottom: 0; } + +/*### Wrapper > Article > dt, dd ###*/ + +dt, dd { + border: 2px solid var(--border-color); + border-bottom: none; + border-top: none; + padding: 0 0.5em; +} +dt { font-size: 1.2em; padding-top: 0.2em; } +dt * { vertical-align: middle; } +dd { + line-height: 1.5em; + margin: 0 0 1em 0; + padding: 0 0 0.4em 49px; +} + +/*### Wrapper > Article > img, hr ###*/ + +img { + box-sizing: border-box; + max-width: 100%; +} +img, hr { border: 1px solid var(--border-color); } +dt img, .svg { box-sizing: border-box; max-height: 1em; } +.pixelated-render { image-rendering: pixelated; } +.oldschool-badge { height: 38px; } +.flag { max-width: 1.3em; } /* Compatibility with Chrome 49.0.2623.112 (for old machines) */ + +.file-type-icon { min-width: 1.3em; vertical-align: middle; } +.borderless, .oldschool-badge, .file-type-icon { border: none; } + +/*### Wrapper > Article > code, pre ###*/ + +/* The following CSS is a modified version of sindresorhus's github-markdown-css repo: https://github.com/sindresorhus/github-markdown-css */ +code, pre { + font-family: monospace; + font-size: 85%; +} + +pre { + overflow: auto; + word-break: normal; + word-wrap: normal; +} + +code { + background-color: var(--pre-bg-color); + margin: 0; + padding: 0 0.4em; +} +pre code { + border: 0; + display: inline-block; + font-size: 100%; + overflow: visible; + padding: 0; + word-wrap: normal; +} +pre > code { + white-space: pre-wrap; + word-break: break-all; + padding: 0.9em; + width: 100%; + box-sizing: border-box; +} + +table code { + font-size: 0.7em; + white-space: normal; +} +dd code { font-size: 0.8em; } + +.HI-comment { color: var(--hi-comment); } +.HI-const { color: var(--hi-const); } +.HI-string { color: var(--hi-string); } +.HI-char { color: var(--hi-char); } +.HI-number { color: var(--hi-number); } +.HI-bool { color: var(--hi-bool); } +.HI-float { color: var(--hi-float); } +.HI-identifier { color: var(--hi-identifier); } +.HI-function { color: var(--hi-function); } +.HI-statement { color: var(--hi-statement); } +.HI-conditional { color: var(--hi-conditional); } +.HI-repeat { color: var(--hi-repeat); } +.HI-operator { color: var(--hi-operator); } +.HI-keyword { color: var(--hi-keyword); /* Label and Exception are keywords */ } +.HI-preproc { color: var(--hi-preproc); } +.HI-type { color: var(--hi-type); } +.HI-storageclass { color: var(--hi-storageclass); } +.HI-structure { color: var(--hi-structure); } +.HI-typedef { color: var(--hi-typedef); } +.HI-ignore { color: var(--hi-ignore); } +.HI-comment * { color: inherit; } /* If text inside a comment is matched, don't show it */ + +/*### Wrapper > Article > table ###*/ + +table { + border-collapse: collapse; + margin: 1em 0; + overflow: auto; +} +td, table th { word-break: normal !important; padding: 0.5em; } +tr { background-color: var(--tr-bg-color); } +th { border: 1px solid var(--table-border-color); font-size: 1.1em; font-weight: bold; } +td { border: 1px dashed var(--table-border-color); } +td:empty { height: 1em; } + +/*## Wrapper > Scroll Button ##*/ + +#scrollBtn { + font-size: 1.66rem; + padding: 0 0.15em; + bottom: 1rem; + right: 1rem; + z-index: 1; + transition-duration: 0.5s; + background-color: var(--bg-color); + display: none; + position: fixed; + border: 1px solid; +} + +/*## Small screen support ##*/ + +@media screen and ((max-width: 610px) or (max-height: 610px)) { + article { max-width: calc(100vw - 16px - 3px); margin-top: 8px; } + table td, table th { word-break: break-all; } + + #about-image { max-width: 4.38em; } + + #content-wrapper { border: none; flex-direction: column; } + #sidebar { max-width: initial; margin: 0; } + /* page-width.js */ + #changeWidthBtn { display: none; } +} + +/*## Printing support ##*/ + +@media print { + h2 + a img, h3 + a img, h4 + a img, h5 + a img, h6 + a img, + nav, #scrollBtn, .gap, .gap-small { display: none !important; } + + body { margin: 0; } + body, article { + background-color: white; + border: none !important; + } + + pre, code { white-space: pre-wrap !important; } + .language-terminal { color: var(--fg-color); background-color: var(--bg-color); } + .slide, .absolute-slide { transform: none !important; margin: 0; } +} -- cgit v1.3.1-26-gb76a