diff --git a/main.c b/main.c
index a6cd917..2430311 100644
--- a/main.c
+++ b/main.c
@@ -54,7 +54,7 @@ char *scsw(char *s, char a, char b) { int i = 0; char c; while((c = s[i])) s[i++
char *scat(char *dst, const char *src) { char *ptr = dst + slen(dst); while(*src) *ptr++ = *src++; *ptr = '\0'; return dst; } /* string cat */
int ssin(char *s, char *ss) { int a = 0, b = 0; while(s[a]) { if(s[a] == ss[b]) { if(!ss[b + 1]) return a - b; b++; } else b = 0; a++; } return -1; } /* string substring index */
char *ccat(char *dst, char c) { int len = slen(dst); dst[len] = c; dst[len + 1] = '\0'; return dst; }
-
+int clin(char *str, char c) {int i = -1; int j = 0; while(str[j] != '\0'){if(str[j] == c) i = j;j++;}return i;} /* find last occurence of character in string */
/* clang-format on */
int fpinject(FILE* f, Lexicon* l, char* filepath);
@@ -96,7 +96,7 @@ int fpportal(FILE* f, Lexicon* l, char* s, int head) {
if (head)
fprintf(
f,
- "
",
+ "",
scsw(filename, ' ', '_'),
filename,
s);
@@ -105,10 +105,91 @@ int fpportal(FILE* f, Lexicon* l, char* s, int head) {
return 1;
}
+int fpimg(FILE* f, char* s) {
+ char id[1024] = {0};
+ char src[1024] = {0};
+ char alt[1024] = {0};
+
+ char* c = s;
+ int i = 0;
+ while (i < 3) {
+ if (*c == '|' || !(*c)) {
+ i++;
+ c++;
+ continue;
+ }
+ switch (i) {
+ case 0:
+ ccat(id, *c++);
+ break;
+ case 1:
+ ccat(src, *c++);
+ break;
+ case 2:
+ ccat(alt, *c++);
+ break;
+ }
+ }
+
+ fprintf(f, "\n", id, src);
+ fprintf(f, "\n", src, alt);
+ fputs("", f);
+ return 1;
+}
+
+int fpimgl(FILE* f, char* s) {
+ char id[1024] = {0};
+ char href[1024] = {0};
+ char src[1024] = {0};
+ char alt[1024] = {0};
+
+ char* c = s;
+ int i = 0;
+ while (i < 4) {
+ if (*c == '|' || !(*c)) {
+ i++;
+ c++;
+ continue;
+ }
+ switch (i) {
+ case 0:
+ ccat(id, *c++);
+ break;
+ case 1:
+ ccat(href, *c++);
+ break;
+ case 2:
+ ccat(src, *c++);
+ break;
+ case 3:
+ ccat(alt, *c++);
+ break;
+ }
+ }
+
+ fprintf(f, "\n", id, href);
+ fprintf(f, "\n", src, alt);
+ fputs("", f);
+ return 1;
+}
+
+int fpaudio(FILE* f, char* s) {
+ fputs("", f);
+ return 1;
+}
+
int fptemplate(FILE* f, Lexicon* l, char* s) {
int target;
if (s[0] == '/')
return fpportal(f, l, s + 1, 1);
+ if (s[0] == ':')
+ return fpimg(f, s + 1);
+ if (s[0] == '?')
+ return fpimgl(f, s + 1);
+ if (s[0] == '_')
+ return fpaudio(f, s + 1);
target = findf(l, s);
if (target < 0)
return error("Missing link", s);
@@ -170,7 +251,7 @@ FILE* build(FILE* f, Lexicon* l, char* name, char* srcpath) {
f,
""
"" NAME " — %s",
- name);
+ ismetanav(name) ? "home" : name);
fputs("", f);
fputs("", f);
/* header */