Introduction
Introduction Statistics Contact Development Disclaimer Help
add support for image dimensions and fix a crash - smu - smu - simple markup (M…
git clone git://git.codemadness.org/smu
Log
Files
Refs
README
LICENSE
---
commit 84c908fb6f3609c25ea60c57c7009490c3c77044
parent 9f36d5824c364b655100d211cf156e7c580464c4
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 11 May 2021 01:47:41 +0200
add support for image dimensions and fix a crash
input for image dimensions:
![a](b =2x3) or
![a](b =2)
input to crash:
![a](b ")
Diffstat:
M smu.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/smu.c b/smu.c
@@ -251,7 +251,9 @@ dolineprefix(const char *begin, const char *end, int newblo…
int
dolink(const char *begin, const char *end, int newblock) {
+ long width = 0, height = 0;
int img, len, sep, parens_depth = 1;
+ char *numend;
const char *desc, *link, *p, *q, *descend, *linkend;
const char *title = NULL, *titleend = NULL;
@@ -288,9 +290,14 @@ dolink(const char *begin, const char *end, int newblock) {
title = p + 1;
/* strip trailing whitespace */
for(linkend = p; linkend > link && isspace(*(linkend - 1)); li…
- for(titleend = q - 1; titleend > link && isspace(*(titleend));…
- if(*titleend != sep) {
- return 0;
+ for(titleend = title; titleend < q && *titleend != sep; titlee…
+ for(p = titleend + 1; p < end && isspace(*p); p++);
+ /* image dimensions */
+ if(*p == '=') {
+ width = strtol(++p, &numend, 10);
+ p = numend;
+ if(*numend == 'x')
+ height = strtol(++p, &numend, 10);
}
}
else {
@@ -315,6 +322,10 @@ dolink(const char *begin, const char *end, int newblock) {
hprintattr(title, titleend);
fputs("\" ", stdout);
}
+ if(width > 0)
+ printf("width=\"%ld\" ", width);
+ if(height > 0)
+ printf("height=\"%ld\" ", height);
fputs("/>", stdout);
}
else {
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.