add hyperlink templating and rename some functions

This commit is contained in:
Iris Lightshard 2021-04-18 23:58:30 -04:00
parent b369ba3a62
commit 89ef84cdbc
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

31
main.c
View file

@ -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, "<a href='%s'>%s</a>", 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);