slweb

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

чување d0a33298e7f655aa1abe67522ecacc634034288c
родитељ fda2fb138824bb0726f9090f728de479a6a284b0
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Mon, 23 Aug 2021 09:01:50 +0200

Add ~- -> non-breaking hyphen

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

Diffstat:
Mslweb.1.in | 4++++
Mslweb.c | 45+++++++++++++++++++++++++++++++++++++++++++--
измењених датотека: 2, додавања: 47(+), брисања: 2(-)

diff --git a/slweb.1.in b/slweb.1.in @@ -429,6 +429,10 @@ will produce: .CDE . .IP \[bu] 4 +.BR "Non\-breaking hyphen" . +Tilde followed by a hyphen (\fC~-\fP) will insert \fC&#8209;\fP in the output. +. +.IP \[bu] 4 .BR "Non\-breaking space" . Two consecutive tildes (\fC~~\fP) will produce \fC&nbsp;\fP in the output. . diff --git a/slweb.c b/slweb.c @@ -2441,13 +2441,13 @@ do_line: if (strlen((char*)pline) > 1 && *(pline + 1) == '~') { + u8* entity = (u8*)"&nbsp;"; /* Handle ~~ within footnotes, headings and link text * specially */ if (ANY(state, ST_INLINE_FOOTNOTE | ST_HEADING | ST_FOOTNOTE_TEXT | ST_LINK)) { - u8* entity = (u8*)"&nbsp;"; size_t entity_len = strlen((char*)entity); size_t token_len = 0; @@ -2474,7 +2474,48 @@ do_line: if (!read_yaml_macros_and_links && !(ANY(state, ST_PRE | ST_CODE | ST_HEADING))) - print_output(output, "&nbsp;"); + print_output(output, entity); + } + + pline += 2; + colno += 2; + } + else if (strlen((char*)pline) > 1 && *(pline + 1) == '-') + { + u8* entity = (u8*)"&#8209;"; + /* Handle ~- within footnotes, headings and link text + * specially */ + if (ANY(state, + ST_INLINE_FOOTNOTE | ST_HEADING + | ST_FOOTNOTE_TEXT | ST_LINK)) + { + size_t entity_len = strlen((char*)entity); + size_t token_len = 0; + + *ptoken = 0; + token_len = strlen((char*)token); + + if (token_len + entity_len < BUFSIZE) + { + strncat((char*)token, (char*)entity, + BUFSIZE - token_len - 1); + ptoken += entity_len; + } + } + else + { + /* Output existing text up to ~~ */ + process_text_token(output, line, link_prefix, + first_line_in_doc, previous_line_blank, + processed_start_of_line, + read_yaml_macros_and_links, list_para, + &token, &ptoken, &token_size, TRUE); + processed_start_of_line = TRUE; + + if (!read_yaml_macros_and_links + && !(ANY(state, + ST_PRE | ST_CODE | ST_HEADING))) + print_output(output, entity); } pline += 2;