From 89ef84cdbcc4c2f6e0af4154753c27385b66bc38 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sun, 18 Apr 2021 23:58:30 -0400 Subject: [PATCH] add hyperlink templating and rename some functions --- main.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 2430311..808492d 100644 --- a/main.c +++ b/main.c @@ -105,6 +105,31 @@ int fpportal(FILE* f, Lexicon* l, char* s, int head) { return 1; } +int fphref(FILE* f, char* s) { + char href[1024] = {0}; + char txt[1024] = {0}; + + char* c = s; + int i = 0; + while (i < 2) { + if (*c == '|' || !(*c)) { + i++; + c++; + continue; + } + switch (i) { + case 0: + ccat(href, *c++); + break; + case 1: + ccat(txt, *c++); + break; + } + } + fprintf(f, "%s", href, txt); + return 1; +} + int fpimg(FILE* f, char* s) { char id[1024] = {0}; char src[1024] = {0}; @@ -137,7 +162,7 @@ int fpimg(FILE* f, char* s) { return 1; } -int fpimgl(FILE* f, char* s) { +int fphimg(FILE* f, char* s) { char id[1024] = {0}; char href[1024] = {0}; char src[1024] = {0}; @@ -184,10 +209,12 @@ int fptemplate(FILE* f, Lexicon* l, char* s) { int target; if (s[0] == '/') return fpportal(f, l, s + 1, 1); + if (s[0] == '*') + return fphref(f, s + 1); if (s[0] == ':') return fpimg(f, s + 1); if (s[0] == '?') - return fpimgl(f, s + 1); + return fphimg(f, s + 1); if (s[0] == '_') return fpaudio(f, s + 1); target = findf(l, s);