generation update: added 'testing' rule to Makefile, removed scripts/common.awk, and fixed scripts/html.awk.

This commit is contained in:
Abdullah Islam 2023-05-11 15:38:25 +06:00
parent bff659d14d
commit eb67e2ab1d
3 changed files with 21 additions and 26 deletions

View File

@ -11,7 +11,12 @@ all: subdirs \
html/feed.atom \
test:
something
mawk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- testing/example.gmi > testing/script_output.html
diff testing/expected_output.html testing/script_output.html
htmlvalidator testing/script_output.html
mawk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- testing/example.gmi > testing/script_output.gmi
diff testing/expected_output.gmi testing/script_output.gmi
clean:
rm -rf html/* gmi/*
@ -20,19 +25,19 @@ subdirs:
find src -mindepth 1 -type d -printf '%P\0' | xargs -0 -I{} mkdir -p gmi/{} html/{}
html/%.html: src/%.gmi scripts/html.awk
mawk -f scripts/common.awk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- $< > $@
mawk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- $< > $@
gmi/%.gmi: src/%.gmi scripts/gemini.awk
mawk -f scripts/common.awk -f ~/projects/awk_functions/lib.awk -f scripts/gemini.awk -- $< > $@
mawk -f ~/projects/awk_functions/lib.awk -f scripts/gemini.awk -- $< > $@
gmi/sitemap.gmi: $(SITEMAP_INDEX_FILES) scripts/sitemap_gmi.awk
mawk -f scripts/common.awk -f ~/projects/awk_functions/lib.awk -f scripts/sitemap_gmi.awk -- $(SITEMAP_INDEX_FILES) > $@
mawk -f ~/projects/awk_functions/lib.awk -f scripts/sitemap_gmi.awk -- $(SITEMAP_INDEX_FILES) > $@
html/sitemap.html: $(SITEMAP_INDEX_FILES) scripts/sitemap_html.awk
mawk -f scripts/common.awk -f ~/projects/awk_functions/lib.awk -f scripts/sitemap_html.awk -- $(SITEMAP_INDEX_FILES) > $@
mawk -f ~/projects/awk_functions/lib.awk -f scripts/sitemap_html.awk -- $(SITEMAP_INDEX_FILES) > $@
gmi/feed.atom: src/feed.ass scripts/feed.awk
mawk -f scripts/common.awk -f ~/projects/awk_functions/lib.awk -f scripts/feed.awk -- $< > $@
mawk -f ~/projects/awk_functions/lib.awk -f scripts/feed.awk -- $< > $@
html/feed.atom: src/feed.ass scripts/feed.awk
mawk -f scripts/common.awk -f ~/projects/awk_functions/lib.awk -f scripts/feed.awk -- $< > $@
mawk -f ~/projects/awk_functions/lib.awk -f scripts/feed.awk -- $< > $@

View File

@ -1,11 +0,0 @@
function scanLink(text, link, description) {
match(text, "^=>([ ]*)([^ ]*)")
link = substr(text, 3, RSTART + RLENGTH - 3)
description = substr(text, RSTART + RLENGTH)
sub("^([ ]*)", "", link)
sub("^([ ]*)", "", description)
return (RSTART == 0)
}

View File

@ -35,7 +35,7 @@ BEGIN {
/^=>/ {
match($0, "^=>([ ]*)([^ ]*)")
link = substr($0, 3, RSTART + RLENGTH - 3)
link = substr($0, 3, RLENGTH - 2)
description = substr($0, RSTART + RLENGTH)
sub("^([ ]*)", "", link)
@ -116,22 +116,23 @@ BEGIN {
gsub("'", "\&apos;")
gsub("\"", "\&quot;")
articleBody = articleBody "<p>" $0 "</p>\n"
articleBody = articleBody sprintf("<p>%s</p>\n", $0)
}
END {
if (length(subHeadings) > 1) {
tocText = "<details id='toc'> <summary>Table of content</summary> <nav> <ol>\n"
tocText = "\n\
<details id='toc'>\n\
<summary>Table of content</summary>\n\
<ol>\n"
for (i = 1; i < length(subHeadings); i++) {
for (i = 1; i < length(subHeadings); i++)
tocText = tocText sprintf("<li><a href='#%s'>%s</a></li>\n", toFilename(subHeadings[i]), subHeadings[i])
}
tocText = tocText "</ol> </nav> </details>\n"
tocText = tocText "</ol> </details>\n"
}
if (FILENAME == "-")
navbarText = ""
if (FILENAME == "-") navbarText = ""
else
navbarText = sprintf("<nav id='navbar'>\n\
<a href='%s'>home</a> | \