slweb

Једноставни генератор статичких веб страна
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 22af0e44ed5cbf6174b930f8943c1eb63f17441d
родитељ 416b173d8d433cc41829973a115f777a89625e01
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sun, 14 May 2023 22:17:55 +0200

Make {made-by} a boolean toggle at the end of the document instead of a direct
div output

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MTODO | 4++--
Mdefs.h | 2+-
Mslweb.1.in | 5+++--
Mslweb.c | 52+++++++++++++++++++++++++++++++++-------------------
измењених датотека: 4, додавања: 39(+), брисања: 24(-)

diff --git a/TODO b/TODO @@ -1,9 +1,9 @@ TODO ==== -[ ] Make {made-by} a boolean toggle instead of a direct div insert +[x] Make {made-by} a boolean toggle instead of a direct div insert -[ ] Output #made-by after footnotes +[x] Output #made-by after footnotes < > Add <abbr>? diff --git a/defs.h b/defs.h @@ -22,7 +22,7 @@ #include "version.h" #include "utf8.h" -#define COPYRIGHTYEAR "2020, 2021, 2022, 2023" +#define COPYRIGHTYEAR "2020-2023" #define MADEBY_URL "https://strahinja.srht.site/slweb/" #define BUFSIZE 1024 diff --git a/slweb.1.in b/slweb.1.in @@ -529,8 +529,9 @@ variables (see . .IP \[bu] 4 .BR "Brand \[lq]watermark\[rq]" . -Directive \fC{made-by}\fP is converted into a div with the id \fCmade-by\fP -containing the \[lq]watermark\[rq] text and a link to the +Directive \fC{made\-by}\fP results in a div to be output at the end of the +document, with the id \fCmade\-by\fP containing the \[lq]watermark\[rq] text and +a link to the .B slweb home page. . diff --git a/slweb.c b/slweb.c @@ -1922,18 +1922,6 @@ process_tag(FILE* output, const u8* token, const u8* link_prefix, { process_git_log(output); } - else if (!strcmp((char*)token, "made-by") - && !read_yaml_macros_and_links) /* {made-by} */ - { - print_output(output, - "<div id=\"made-by\"><p><small>\n" - "Generated by <a href=\"%s\">" - "slweb</a>\n" - "© %s Strahinya Radich.\n" - "</small></p></div><!--made-by-->\n", - MADEBY_URL, COPYRIGHTYEAR); - output_firstcol = 1; - } else if (startswith((char*)token, "csv")) /* {csv} */ process_csv(output, token, read_yaml_macros_and_links, end_tag); else if (startswith((char*)token, "tsv")) /* {csv} */ @@ -2052,6 +2040,19 @@ process_kbd(FILE* output, const int end_tag) } int +process_madeby(FILE* output) +{ + print_output(output, + "<div id=\"made-by\"><p><small>\n" + "Generated by <a href=\"%s\">" + "slweb</a>\n" + "© %s Strahinya Radich.\n" + "</small></p></div><!--made-by-->\n", + MADEBY_URL, COPYRIGHTYEAR); + return 0; +} + +int process_strike(FILE* output, const int end_tag) { print_output(output, "<%ss>", end_tag ? "/" : ""); @@ -2767,6 +2768,7 @@ slweb_parse(FILE* output, const char* source_filename, const u8* buffer, int list_para = 0; int footnote_at_line_start = 0; size_t pline_len = 0; + int madeby_present = 0; if (!buffer) exit(error(1, (u8*)"Empty buffer")); @@ -3713,8 +3715,12 @@ do_line: { state &= ~ST_TAG; - process_tag(output, token, link_prefix, - read_yaml_macros_and_links, &skip_eol, end_tag); + if (!strcmp((char*)token, "made-by")) + madeby_present = 1; + else + process_tag(output, token, link_prefix, + read_yaml_macros_and_links, &skip_eol, + end_tag); RESET_TOKEN(token, ptoken, token_size); end_tag = 0; @@ -4936,12 +4942,20 @@ done_line: if (pbuffer && *pbuffer) goto do_buffer; done_buffer: - if (!read_yaml_macros_and_links - && (footnote_count > 0 || inline_footnote_count > 0)) - end_footnotes(output, add_footnote_div); + if (!read_yaml_macros_and_links) + { + if (footnote_count > 0 || inline_footnote_count > 0) + end_footnotes(output, add_footnote_div); - if (!read_yaml_macros_and_links && !body_only) - end_body_and_html(output); + if (madeby_present) + { + process_madeby(output); + output_firstcol = 1; + } + + if (!body_only) + end_body_and_html(output); + } free(link_text); free(link_macro);