чување 664e26f67317b5989c0aa5e4758d9f00d4e8c8c4
родитељ 401a550ec9451f0ad3d2f75c67dacbcf9c39b133
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Tue, 10 Aug 2021 13:44:53 +0200
Fix: macro-form of links now properly handles <span> again; updated manpage
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 5, додавања: 41(+), брисања: 1(-)
diff --git a/.gitignore b/.gitignore
@@ -16,6 +16,7 @@ nohup.out
*.gz
slweb
slweb.1
+slweb.session
compile_commands.json
examples/*/*.html
date
diff --git a/examples/links/index.slw b/examples/links/index.slw
@@ -16,6 +16,10 @@ You can also create and style a [=icon (link with icon)][2]
You can also make a [local link][3].
+Link with span: [(Span)][1].
+
+Link without span: [Without span (with parentheses)](https://example.com).
+
[1]: https://strahinja.org
[2]: https://materialdesignicons.com
[3]: ../../index.html
diff --git a/index.html b/index.html
@@ -153,7 +153,7 @@ this program. If not, see <<a href="https://www.gnu.org/licenses">https://www
<div id="git-log">
Previous commit:
-index.slw 796d167 2021-08-10 09:16:12 +0200 (Страхиња Радић) (HEAD -> master)
+index.slw 401a550 2021-08-10 09:19:31 +0200 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD)
</div><!--git-log-->
diff --git a/slweb.1.in b/slweb.1.in
@@ -325,6 +325,12 @@ outside of the \fC<span></span>\fP:
<span>Link title</span></a>
.CDE
.
+.IP
+Exception is the form \fC[Some text (parenthesized)](https://somelink)\fP, which
+won't output \fC<span>\fP tags, and will simply include the parentheses in the
+output instead. This form doesn't apply to macro-form \fC[=macro Some
+(text)](http://link)\fP, which will always output \fC<span>\fP tags.
+.
.IP \-
.BR "Regular links" .
Everything said about inline links applies to regular links, with the exception
diff --git a/slweb.c b/slweb.c
@@ -3425,6 +3425,35 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
break;
+ case '(':
+ if (ANY(state, ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
+ | ST_FOOTNOTE_TEXT | ST_HEADING
+ | ST_INLINE_FOOTNOTE | ST_LINK_SECOND_ARG_END
+ | ST_MACRO_BODY | ST_PRE))
+ CHECKCOPY(token, ptoken, token_size, pline)
+ else if (*link_macro && (state & ST_LINK))
+ {
+ uint8_t* tag = (uint8_t*)"<span>";
+ size_t tag_len = u8_strlen(tag);
+ size_t token_len = 0;
+
+ *ptoken = 0;
+ token_len = u8_strlen(token);
+
+ if (token_len + tag_len < BUFSIZE)
+ {
+ u8_strncat(token, tag, BUFSIZE-token_len-1);
+ ptoken += tag_len;
+ }
+
+ state |= ST_LINK_SPAN;
+ pline++;
+ }
+ else
+ CHECKCOPY(token, ptoken, token_size, pline)
+ colno++;
+ break;
+
case ')':
if (ANY(state, ST_DISPLAY_FORMULA | ST_FORMULA
| ST_LINK_SECOND_ARG_END))