Introduction
Introduction Statistics Contact Development Disclaimer Help
image: allow title or dimensions and allow them in any order - smu - smu - simp…
git clone git://git.codemadness.org/smu
Log
Files
Refs
README
LICENSE
---
commit 1fa74fe8b249d88a0db4bbd96a7f144fcf0c3a6c
parent 30baf9de128f6bf13470f2356cac768e0a8f95d5
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 11 May 2021 17:33:18 +0200
image: allow title or dimensions and allow them in any order
Diffstat:
M smu.c | 56 ++++++++++++++++++-----------…
1 file changed, 32 insertions(+), 24 deletions(-)
---
diff --git a/smu.c b/smu.c
@@ -292,33 +292,41 @@ dolink(const char *begin, const char *end, int newblock)
q++;
}
- if ((p = strpbrk(link, "\"'")) && p < end && q > p) {
- sep = p[0]; /* separator: can be " or ' */
- title = p + 1;
- /* strip trailing whitespace */
- for (linkend = p; linkend > link && isspace((unsigned char)*(l…
- ;
- for (titleend = title; titleend < q && *titleend != sep; title…
- ;
- for (p = titleend + 1; p < end && isspace((unsigned char)*p); …
- ;
- /* image dimensions */
- if (*p == '=') {
- width = strtol(++p, &numend, 10);
- p = numend;
- if (*numend == 'x')
- height = strtol(++p, &numend, 10);
- }
- } else {
- /* strip trailing whitespace */
- for (linkend = q; linkend > link && isspace((unsigned char)*(l…
- ;
- }
-
- /* Links can be given in angular brackets */
+ linkend = q;
if (*link == '<' && *(linkend - 1) == '>') {
link++;
linkend--;
+ } else {
+ /* trim leading spaces */
+ for (p = link; p < end && isspace((unsigned char)*p); p++)
+ ;
+ for (link = p; p < end; p++) {
+ if (isspace((unsigned char)*p)) {
+ linkend = p;
+ break;
+ }
+ }
+ for (; p < end; p++) {
+ if (isspace((unsigned char)*p))
+ continue;
+ if (*p == '=') {
+ /* image dimensions */
+ width = strtol(++p, &numend, 10);
+ p = numend;
+ if (*numend == 'x')
+ height = strtol(++p, &numend, 10);
+ } else if (*p == '\'' || *p == '"') {
+ /* separator: can be " or ' */
+ sep = *p;
+ title = ++p;
+ if ((titleend = strchr(title, sep))) {
+ if (titleend >= end)
+ titleend = end;
+ else
+ p = titleend;
+ }
+ }
+ }
}
len = q + 1 - begin;
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.