slweb

Једноставни генератор статичких веб страна
git clone https://git.sr.ht/~strahinja/slweb
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 9983a63355bbde62cc5c44678e5d195e3f35ba58
родитељ 500007b445fbc752f99b2e413831f9318e410a9e
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat, 23 Sep 2023 21:56:23 +0200

Introduce break marks

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

Diffstat:
M.gitignore | 1+
MTODO | 2+-
Mslweb.1.in | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mslweb.c | 46++++++++++++++++++++++++++++++++++++++++++++--
измењених датотека: 4, додавања: 141(+), брисања: 3(-)

diff --git a/.gitignore b/.gitignore @@ -12,6 +12,7 @@ *.ps *.swp *.did +cscope.out nohup.out *.gz *.xz diff --git a/TODO b/TODO @@ -1,7 +1,7 @@ TODO ==== -[ ] Investigate: sometimes <p> is inserted (with incorrect closing tag) in <dd> +[x] Investigate: sometimes <p> is inserted (with incorrect closing tag) in <dd> for no reason (https://strahinja.srht.site/galeb/booting.html) < > Add <abbr>? diff --git a/slweb.1.in b/slweb.1.in @@ -121,6 +121,96 @@ underlines__\fR will be put inside \fC<strong></strong>\fR. \fC***More than two*** of the ___same symbol___\fR should be avoided. . .IP \[bu] +.BR "Break marks" . +To address combinations of lists and \[lq]raw\[rq] tags, which are problematic +to mix together, +.B slweb +supports explicitly marking a raw tag with a \[lq]break mark\[rq]. +This currently means that when such a tag is introduced, any running list item +and list will be closed prior to outputting the custom tag. +Tags with break marks are introduced by prepending the exclamation mark to the +tag name. +For example, without a break mark, the input: +. +.CDS 8 +- Some list +{break-here} +.CDE +. +.IP +produces the following output: +. +.CDS 8 +<ul><li><p>Some list +<break-here></p></li></ul> +.CDE +. +.IP +When changed to: +. +.CDS 8 +- Some list +{!break-here} +.CDE +. +.IP +.B slweb +will output: +. +.CDS 8 +<ul><li><p>Some list +</p></li></ul> +<break-here> +.CDE +. +.IP +Same for end tags: +. +.CDS 8 +{dl}{dt}{p}Introduction{/dt} +{dd} +- One +- Two +{/dd}{/dl} +.CDE +. +.IP +produces: +. +.CDS 8 +<dl><dt><p>Introduction</dt> +<dd> +<ul><li><p>One +</p></li> +<li><p>Two +</dd></dl></p></li></ul> +.CDE +. +.IP +while +. +.CDS 8 +{dl}{dt}{p}Introduction{/dt} +{dd} +- One +- Two +{/!dd}{/dl} +.CDE +. +.IP +produces: +. +.CDS 8 +<dl><dt><p>Introduction</dt> +<dd> +<ul><li><p>One +</p></li> +<li><p>Two +</p></li></ul> +</dd></dl> +.CDE +. +.IP \[bu] .BR "Footnotes (regular and inline)" . Two-part regular footnotes can be added in a manner similar to links (see .BR Links ). @@ -1186,6 +1276,11 @@ will produce </tag> .CDE . +.IP +Also see +.B Break marks +above. +. .SH AUTHOR . Strahinya Radich, diff --git a/slweb.c b/slweb.c @@ -2929,6 +2929,7 @@ slweb_parse(FILE* output, const char* source_filename, const u8* buffer, u8* link_macro = NULL; UBYTE heading_level = 0; ULONG heading_count = 0; + int break_mark = 0; int end_tag = 0; int first_line_in_doc = 1; int skip_change_first_line_in_doc = 0; @@ -3960,6 +3961,36 @@ do_line: { state &= ~ST_TAG; + if (break_mark) + { + if (IN(state, ST_PARA_OPEN)) + { + if (!read_yaml_macros_and_links) + { + print_output(output, "</p>\n"); + output_firstcol = 1; + } + state &= ~ST_PARA_OPEN; + } + if (IN(state, ST_LIST)) + { + state &= ~ST_LIST; + if (!read_yaml_macros_and_links) + { + process_list_item_end(output); + process_list_end(output); + } + } + else if (IN(state, ST_NUMLIST)) + { + state &= ~ST_NUMLIST; + if (!read_yaml_macros_and_links) + { + process_list_item_end(output); + process_numlist_end(output); + } + } + } if (!strcmp((char*)token, "made-by")) madeby_present = 1; else @@ -3972,7 +4003,9 @@ do_line: end_tag); RESET_TOKEN(token, ptoken, token_size); - end_tag = 0; + break_mark = 0; + end_tag = 0; + previous_line_block = 0; } pline++; @@ -4273,7 +4306,16 @@ do_line: break; } - if (strlen((char*)pline) > 1 && *(pline + 1) == '[') + if ((IN(state, ST_TAG)) && pline != line + && (*(pline - 1) == '{' + || (end_tag && pline != line + 1 + && *(pline - 1) == '/' + && *(pline - 2) == '{'))) + { + break_mark = 1; + pline++; + } + else if (strlen((char*)pline) > 1 && *(pline + 1) == '[') { /* Output existing text up to ! */ *ptoken = 0;