slweb

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

чување 3285b51cd9aeaf098e8f91876ab73625c8bb75e6
родитељ 4a8cbbd91529901f8b241ab23ee83abb302545cf
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed, 16 Dec 2020 20:08:49 +0100

Updated example in index.slw and fixed extra lines on YAML boundaries

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

Diffstat:
Mindex.html | 4++--
Mindex.slw | 1+
Mslweb.c | 25++++++++++++++++++-------
измењених датотека: 3, додавања: 21(+), брисања: 9(-)

diff --git a/index.html b/index.html @@ -9,7 +9,6 @@ <link rel="stylesheet" href="index.css" /> </head> <body> - <main> <h1>slweb</h1> @@ -31,6 +30,7 @@ $ make && sudo make install <p>Given the file <code>index.slw</code> in the current directory:</p> <pre> +--- site-name: Test website site-desc: My first website in slweb --- @@ -103,7 +103,7 @@ this program. If not, see &lt;https://www.gnu.org/licenses/&gt;. </p> <div id="git-log"> Previous commit: -index.slw 1b15c44 2020-12-16 18:48:23 +0100 (Страхиња Радић) (HEAD -> wip-20201216, origin/wip-20201216) +index.slw 4a8cbbd 2020-12-16 19:37:35 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD, wip-20201216) </div><!--git-log--> diff --git a/index.slw b/index.slw @@ -24,6 +24,7 @@ See the [`examples/`][1] directory in this repository. Given the file `index.slw` in the current directory: ``` +--- site-name: Test website site-desc: My first website in slweb --- diff --git a/slweb.c b/slweb.c @@ -427,6 +427,8 @@ slweb_parse(uint8_t* buffer, FILE* output, UBYTE heading_level = 0; BOOL end_tag = FALSE; BOOL first_line_in_doc = TRUE; + BOOL skip_change_first_line_in_doc = FALSE; + BOOL skip_eol = FALSE; BOOL previous_line_blank = FALSE; BOOL processed_start_of_line = FALSE; @@ -477,6 +479,7 @@ slweb_parse(uint8_t* buffer, FILE* output, lineno++; colno = 1; processed_start_of_line = FALSE; + skip_eol = FALSE; while (pline && *pline) { @@ -490,10 +493,8 @@ slweb_parse(uint8_t* buffer, FILE* output, { state ^= ST_YAML; - if (state & ST_YAML) - first_line_in_doc = FALSE; - else - first_line_in_doc = TRUE; + skip_change_first_line_in_doc = TRUE; + skip_eol = TRUE; pline += 3; colno += 3; @@ -1089,15 +1090,25 @@ slweb_parse(uint8_t* buffer, FILE* output, u8_strcpy(pvars->value, token); } - if (!read_yaml_macros_and_links && !(state & (ST_YAML | ST_YAML_VAL | ST_LINK_SECOND_ARG))) + if (!skip_eol) { - fprintf(output, "\n"); + if (!read_yaml_macros_and_links + && !(state & (ST_YAML | ST_YAML_VAL + | ST_LINK_SECOND_ARG))) + { + fprintf(output, "\n"); + } } *token = '\0'; ptoken = token; - first_line_in_doc = FALSE; + if (!skip_change_first_line_in_doc + && !(state & ST_YAML)) + first_line_in_doc = FALSE; + + skip_change_first_line_in_doc = FALSE; + ; if (line_len == 0) previous_line_blank = TRUE;