smu-noxz

[fork] simple markup - markdown like syntax
git clone git://git.noxz.tech/smu-noxz
Log | Files | Refs | LICENSE

commit 57b72a10e33dbfe501c6b12c47ee5dfd46ac9a02
parent 0d5c6e340c134c2ee58e0e8715a7cbaae7895ad0
Author: Chris Noxz <chris@noxz.tech>
Date:   Thu, 19 Sep 2019 14:09:41 +0200

Add support for setting base-url to links with '-b'

Diffstat:
A.gitignore | 2++
Msmu.c | 11+++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +smu +smu.o diff --git a/smu.c b/smu.c @@ -40,6 +40,7 @@ static Parser parsers[] = { dounderline, docomment, dolineprefix, dolist, doparagraph, dogtlt, dosurround, dolink, doshortlink, dohtml, doamp, doreplace }; static int nohtml = 0; +static char base_url[2048]; static Tag lineprefix[] = { { " ", 0, "<pre><code>", "</code></pre>" }, @@ -267,8 +268,15 @@ dolink(const char *begin, const char *end, int newblock) { linkend = q; len = q + 1 - begin; } + if(img) { fputs("<img src=\"", stdout); + if (strlen(base_url) + && *link != '/' + && (strstr(link, "://") == NULL + || strstr(link, "://") - link > linkend - link)) { + fputs(base_url, stdout); + } hprint(link, linkend); fputs("\" alt=\"", stdout); hprint(desc, descend); @@ -588,12 +596,15 @@ main(int argc, char *argv[]) { int s, i; unsigned long len, bsize; FILE *source = stdin; + base_url[0] = '\0'; for(i = 1; i < argc; i++) { if(!strcmp("-v", argv[i])) eprint("simple markup %s (C) Enno Boland\n",VERSION); else if(!strcmp("-n", argv[i])) nohtml = 1; + else if(!strcmp("-b", argv[i])) + strncpy(base_url, argv[(i++) + 1], 2048); else if(argv[i][0] != '-') break; else if(!strcmp("--", argv[i])) {