diff options
| Commit | 3552c3e6cb666ac3f063652862e3b287cd30c904 (patch) | |
|---|---|---|
| Author | 2023-10-23 15:34:14 +0300 | |
| Committer | 2023-10-23 15:34:14 +0300 | |
| Files | edde566ff9d0d35643cf1f86c9ffef5287000c9a /awk-edits | |
| syndamia.com-3552c3e6cb666ac3f063652862e3b287cd30c904.tar syndamia.com-3552c3e6cb666ac3f063652862e3b287cd30c904.tar.gz syndamia.com-3552c3e6cb666ac3f063652862e3b287cd30c904.zip | ||
| Parent | 15b153225ef24e37348220505aa0e8aa221f415b (diff) | |
[generate] Reworked to use csg, updated awk scripts with csg in mind and updated info in _header
10 files changed, 16 insertions, 110 deletions
| -rw-r--r-- | awk-edits/File-type.awk | 1 | ||||
| -rw-r--r-- | awk-edits/Flags.awk | 1 | ||||
| -rw-r--r-- | awk-edits/Group-contents.awk | 1 | ||||
| -rw-r--r-- | awk-edits/Header-description.awk | 52 | ||||
| -rw-r--r-- | awk-edits/Header-title.awk | 28 | ||||
| -rw-r--r-- | awk-edits/Heading-anchors.awk | 1 | ||||
| -rw-r--r-- | awk-edits/Pagenav.awk | 31 | ||||
| -rw-r--r-- | awk-edits/Presentation.awk | 9 | ||||
| -rw-r--r-- | awk-edits/Svg-height-attrib.awk | 1 | ||||
| -rw-r--r-- | awk-edits/Syntax-highlighting.awk | 1 |
diff --git a/awk-edits/File-type.awk b/awk-edits/File-type.awk index f283fa0..32e22b9 100644 --- a/awk-edits/File-type.awk +++ b/awk-edits/File-type.awk @@ -1,3 +1,4 @@ +# .*(misc|preserved).*html # # == About == # diff --git a/awk-edits/Flags.awk b/awk-edits/Flags.awk index 719d82c..aad1343 100644 --- a/awk-edits/Flags.awk +++ b/awk-edits/Flags.awk @@ -1,3 +1,4 @@ +# .*html # # == About == # diff --git a/awk-edits/Group-contents.awk b/awk-edits/Group-contents.awk index 7f930b6..43fa460 100644 --- a/awk-edits/Group-contents.awk +++ b/awk-edits/Group-contents.awk @@ -1,3 +1,4 @@ +# .*(blog|slides|teaching|tutorials|misc)/.*/.*html # # == About == # diff --git a/awk-edits/Header-description.awk b/awk-edits/Header-description.awk deleted file mode 100644 index f7c6ff4..0000000 --- a/awk-edits/Header-description.awk +++ /dev/null @@ -1,52 +0,0 @@ -# -# == About == -# -# Every page has a description and og:description meta tags. These descriptions are -# generated from the text inside paragraphs of the current page. -# The value for those meta tags is "[DESCRIPTION]" and it gets replaced with -# either all of the text on the page, or only the first 200 characters. - -function appToDesc(l) { - l = substr(l, parstar, length(l) - parstar + 1 - parend); - gsub("<[^>]*>", "", l); gsub("’", "'", l); gsub(/&[^;]*;/, "", l); - - if (desc == "") desc = l; - else desc = desc " " l; - - if (length(desc) >= 200) { - desc = substr(desc, 1, 197) "..."; - return 1; - } - return 0; -} - -BEGIN { - parcont = 0; # continue, we have found a <p> but not a </p> - parstar = 1; # we found a <p> - parends = 0; # we found a </p> - - # Loop over the whole file, extract all text in first couple of paragraphs, - # store it in desc (but no more than 200 characters will be saved) - while(getline < ARGV[1]) { - start = index($0, "<h2") - if (start && substr($0, start, 16) != "<h2 id=\"contents") - break; - - if (index($0, "<p>")) - parstar = 4; - if (index($0, "</p>")) - parends = 3; - - if (parcont || parstar == 4) { - if (appToDesc($0)) break; - parcont = parends == 0; - parstar = 1; - parends = 0; - } - } - close(ARGV[1]); # FILENAME isn't set during BEGIN -} - -/\[DESCRIPTION\]/ { - sub(/\[DESCRIPTION\]/, desc); -} diff --git a/awk-edits/Header-title.awk b/awk-edits/Header-title.awk deleted file mode 100644 index 42fafa7..0000000 --- a/awk-edits/Header-title.awk +++ /dev/null @@ -1,28 +0,0 @@ -# -# == About == -# -# Every page has a og:title meta tag, which has to be generated from the page -# itself. The title tag is automatically filled in by ssg. -# The value for the meta tag is "[TITLE]" and it gets replaced with all text -# inside first h1 header tag. - -BEGIN { - h1Index = 0; - - # When this loop finishes, $0 will have the first line containing an h1 header - # tag, and h1Index will have it's starting position - while (h1Index == 0 && getline < ARGV[1]) - h1Index = index($0, "<h1"); - close(ARGV[1]); # FILENAME isn't set during BEGIN - - # Removes the opening tag - gsub(/<h1[^>]*>/, ""); - # Remove all HTML character codes, since they're in the form "&...;" and the & - # will be treated as the character for replacement in gsub - gsub(/&[^;]*;/, ""); - title = substr($0, h1Index, index($0, "</h1") - h1Index); -} - -/\[TITLE\]/ { - gsub(/\[TITLE\]/, title); -} diff --git a/awk-edits/Heading-anchors.awk b/awk-edits/Heading-anchors.awk index 29c35fe..e3846f9 100644 --- a/awk-edits/Heading-anchors.awk +++ b/awk-edits/Heading-anchors.awk @@ -1,3 +1,4 @@ +# .*html # # == About == # diff --git a/awk-edits/Pagenav.awk b/awk-edits/Pagenav.awk index 13c3fee..1d523be 100644 --- a/awk-edits/Pagenav.awk +++ b/awk-edits/Pagenav.awk @@ -1,3 +1,4 @@ +# .*(blog|slides|teaching|tutorials|misc)/.*/.*html # # == About == # @@ -13,33 +14,13 @@ # # Split into Pagenav.awk and post-pagenav.awk -BEGIN { - fileCheck = ARGV[1]; # FILENAME isn't available in BEGIN - - elem = ""; - if (match(fileCheck, /(blog|slides|teaching|tutorials|misc)\/.*\//)) { - dateCreate = ""; - dateEdited = ""; - FS = "\t" - while ((getline < "./timestamps.txt") > 0) { - if ($1 == fileCheck) { - dateCreate = $2; - dateEdited = $3; - break; - } - } - FS = " " # gawk only? - - start = index(fileCheck, "website") + 8; - elem = ORS \ +nopagenav == 0 && /<h1/ { + match(FILENAME, /(blog|slides|teaching|tutorials|misc)\/.*\//) + $0 = $0 ORS \ "<div id=\"pagenav\">" ORS \ -" <strong>Created: " dateCreate "</strong> || <strong>Edited: " dateEdited "</strong>" ORS \ -" || <a href=\"https://gitlab.com/Syndamia/syndamiadotcom/-/blob/master/src/" substr(fileCheck, start, length(fileCheck) - start - 3) "md\"><strong>GitLab source</strong></a>" ORS \ +" <strong>Created: " created "</strong> || <strong>Edited: " edited "</strong>" ORS \ +" || <a href=\"https://gitlab.com/Syndamia/syndamiadotcom/-/blob/master/src/" substr(FILENAME, start, length(FILENAME) - start - 3) "md\"><strong>GitLab source</strong></a>" ORS \ "</div>" - } -} -/<h1/ && nopagenav == 0 { - $0 = $0 elem nopagenav = 1 } diff --git a/awk-edits/Presentation.awk b/awk-edits/Presentation.awk index 9fd64e3..4d3826a 100644 --- a/awk-edits/Presentation.awk +++ b/awk-edits/Presentation.awk @@ -1,3 +1,4 @@ +# .*(slides|teaching)/.*html # # == About == # @@ -87,8 +88,6 @@ # Refer to src/talks/demo/index.md BEGIN { - nopresentation=!(substr(ARGV[1], "slides") || substr(ARGV[1], "teaching")) # FILENAME isn't available yet - # 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) @@ -218,15 +217,15 @@ function presentationSubstitute(ind) { gsub(cpat[ind], crep[ind]) } -nopresentation == 0 && /<code>/ { +/<code>/ { presInsideCode = 1 } -nopresentation == 0 && /<\/code>/ { +/<\/code>/ { presInsideCode = 0 } -nopresentation == 0 && presInsideCode == 0 && /^[ \t]*(<p>)?&&/ { +presInsideCode == 0 && /^[ \t]*(<p>)?&&/ { for (i = 1; i <= nameslength; i++) { if (index($0, names[i]) != 0) presentationSubstitute(i) diff --git a/awk-edits/Svg-height-attrib.awk b/awk-edits/Svg-height-attrib.awk index e6dc07f..9e49769 100644 --- a/awk-edits/Svg-height-attrib.awk +++ b/awk-edits/Svg-height-attrib.awk @@ -1,3 +1,4 @@ +# .*html # # == About # diff --git a/awk-edits/Syntax-highlighting.awk b/awk-edits/Syntax-highlighting.awk index 08589cf..577ecb3 100644 --- a/awk-edits/Syntax-highlighting.awk +++ b/awk-edits/Syntax-highlighting.awk @@ -1,3 +1,4 @@ +# .*(blog|slides|teaching|tutorials|misc)/.*/.*html # # == About == # |