slweb

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

чување 2062af37b945b459009d542aaba861af63cf7608
родитељ 5a2340fc7629557897a0883c6c06edffdd133eab
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat, 23 Jan 2021 13:21:37 +0100

Added horizontal rule; updated manpage

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

Diffstat:
MTODO | 6+++---
Mindex.html | 2+-
Mslweb.1.in | 25+++++++++++++++++--------
Mslweb.c | 22++++++++++++++++++++--
измењених датотека: 4, додавања: 41(+), брисања: 14(-)

diff --git a/TODO b/TODO @@ -4,12 +4,12 @@ [ ] keep-macros variable: when present in an included file, macros from child process get added to the parent - [~] Add footnote support + [x] Add footnote support [x] Add initial support - [ ] Test + [x] Test [x] Add documentation - [ ] Add horizontal rule support + [x] Add horizontal rule support [ ] Add additional ways to activate lists (*, o) - Two spaces min instead of four for indent? diff --git a/index.html b/index.html @@ -134,7 +134,7 @@ this program. If not, see &lt;<a href="https://www.gnu.org/licenses">https://www <div id="git-log"> Previous commit: -index.slw d6e8016 2021-01-21 22:49:28 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD) +index.slw 5a2340f 2021-01-22 22:54:10 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD) </div><!--git-log--> diff --git a/slweb.1.in b/slweb.1.in @@ -176,7 +176,7 @@ paragraph. .RE . .IP -The horizontal rule and the list of footnotes is printed only once, before the +The horizontal rule and the list of footnotes is output only once, before the end of .SM HTML document body. Rule and the list of footnotes can be surrounded by a div with @@ -189,9 +189,8 @@ to \[lq]1\[rq] (see . .IP Inline and regular footnotes can be used at the same time, but they don't share -the numbering. This doesn't affect footnote link functionality, but it does -affect footnote presentation, as some footnote numbers will overlap. As a -result, whenever +the numbering. This doesn't affect functionality, but it does affect +presentation, as some footnote numbers will overlap. As a result, whenever .B slweb encounters both footnote types in the same document, a warning will be issued to .IR stderr . @@ -203,6 +202,16 @@ A line starting with \fC#\fP followed by space will be put inside hash signs. . .IP \[bu] +.BR "Horizontal rules" . +Three dashes at the start of the line will produce a \fC<hr />\fP in the output. +As this Markdown feature clashes with +.SM YAML +block boundaries, it will work only if +.SM YAML +block is present in the input and before the three dashes for the horizontal +rule. Any text following the three dashes on the same line will be ignored. +. +.IP \[bu] .BR Images . Similar to links (see .BR Links ), @@ -297,8 +306,8 @@ outside of the \fC<span></span>\fP: . .IP \- .BR "Regular links" . -Everything said about the inline links applies to regular links, with the -exception that instead of the parenthesized +Everything said about inline links applies to regular links, with the exception +that instead of the parenthesized .SM URL, link text inside brackets will be followed by link id (different than the \[lq]\fCid\fP\[rq] @@ -310,9 +319,9 @@ separate definition of that link id is needed, usually near the end of input. For example: . .CDS 8 -Here's a link to [my website][mysite]. +Here's a link to [my website][mw]. -[mysite]: https://mysite.com +[mw]: https://mysite.com .CDE . .IP diff --git a/slweb.c b/slweb.c @@ -18,7 +18,6 @@ */ #include "defs.h" -#include <sys/types.h> static size_t lineno = 0; static size_t colno = 1; @@ -1418,6 +1417,13 @@ process_footnote(uint8_t* token, BOOL footnote_definition, BOOL footnote_output, } int +process_horizontal_rule(FILE* output) +{ + print_output(output, "<hr />\n"); + return 0; +} + +int process_text_token(uint8_t* line, BOOL first_line_in_doc, BOOL previous_line_blank, BOOL processed_start_of_line, @@ -1567,6 +1573,7 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only, BOOL add_image_links = TRUE; BOOL add_footnote_div = FALSE; BOOL list_para = FALSE; + BOOL yaml_parsed = FALSE; size_t pline_len = 0; if (!buffer) @@ -1682,10 +1689,21 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only, && u8_strlen(pline) > 2 && startswith((char*)pline, "---")) { + skip_eol = TRUE; + + if (yaml_parsed) + { + process_horizontal_rule(output); + pline = NULL; + break; + } + state ^= ST_YAML; + if (!(state & ST_YAML)) + yaml_parsed = TRUE; + skip_change_first_line_in_doc = TRUE; - skip_eol = TRUE; pline += 3; colno += 3;