Introduction
Introduction Statistics Contact Development Disclaimer Help
apply img and anchor support written by Hiltjo Posthuma. Thanks mate! - smu - s…
git clone git://git.codemadness.org/smu
Log
Files
Refs
README
LICENSE
---
commit 913a387aff199a02aa4e2bdd39fb0455f6202fde
parent 0121dd058d5399b7d8a8e1e672a8951f3572041e
Author: Enno Boland <[email protected]>
Date: Fri, 28 Nov 2014 10:06:32 +0100
apply img and anchor support written by Hiltjo Posthuma. Thanks mate!
Diffstat:
M smu.c | 38 ++++++++++++++++++++++++++---…
M testdoc | 18 +++++++++++++++++-
2 files changed, 49 insertions(+), 7 deletions(-)
---
diff --git a/smu.c b/smu.c
@@ -234,8 +234,9 @@ dolineprefix(const char *begin, const char *end, int newblo…
int
dolink(const char *begin, const char *end, int newblock) {
- int img;
+ int img, len, sep;
const char *desc, *link, *p, *q, *descend, *linkend;
+ const char *title = NULL, *titleend = NULL;
if(*begin == '[')
img = 0;
@@ -251,24 +252,49 @@ dolink(const char *begin, const char *end, int newblock) {
return 0;
descend = p;
link = p + 2;
- if(!(p = strstr(link, ")")) || p > end)
+ if(!(q = strchr(link, ')')) || q > end)
return 0;
- linkend = p;
+ 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(*(linkend - 1)); li…
+ if(!(p = strchr(title, sep)) || q > end || p > q)
+ return 0;
+ titleend = p;
+ len = p + 2 - begin;
+ }
+ else {
+ linkend = q;
+ len = q + 1 - begin;
+ }
if(img) {
fputs("<img src=\"", stdout);
hprint(link, linkend);
fputs("\" alt=\"", stdout);
hprint(desc, descend);
- fputs("\" />", stdout);
+ fputs("\" ", stdout);
+ if(title && titleend) {
+ fputs("title=\"", stdout);
+ hprint(title, titleend);
+ fputs("\" ", stdout);
+ }
+ fputs("/>", stdout);
}
else {
fputs("<a href=\"", stdout);
hprint(link, linkend);
- fputs("\">", stdout);
+ fputs("\"", stdout);
+ if(title && titleend) {
+ fputs(" title=\"", stdout);
+ hprint(title, titleend);
+ fputs("\"", stdout);
+ }
+ fputs(">", stdout);
process(desc, descend, 0);
fputs("</a>", stdout);
}
- return p + 1 - begin;
+ return len;
}
int
diff --git a/testdoc b/testdoc
@@ -54,7 +54,23 @@ code:
links
-----
-[suckless](http://suckless.org)
+link: [suckless](http://suckless.org/)
+
+link with title: [suckless](http://suckless.org/ "software that sucks less")
+
+link with title (single quote): [suckless](http://suckless.org/ 'software that…
+
+
+images
+------
+
+image: ![](http://st.suckless.org/screenshots/20h-2012-s.png)
+
+image with alt text: ![alt text](http://st.suckless.org/screenshots/20h-2012-s…
+
+image with title: ![alt text](http://st.suckless.org/screenshots/20h-2012-s.pn…
+
+image with title (single quote): ![alt text](http://st.suckless.org/screenshot…
inline html
-----------
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.