aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compromyse.xyz/posts/a.html2
-rw-r--r--include/lexer.h7
-rw-r--r--src/engine.c1
-rw-r--r--src/lexer.c8
-rw-r--r--src/template.c5
5 files changed, 18 insertions, 5 deletions
diff --git a/compromyse.xyz/posts/a.html b/compromyse.xyz/posts/a.html
index 79d75da..8237d7f 100644
--- a/compromyse.xyz/posts/a.html
+++ b/compromyse.xyz/posts/a.html
@@ -1,4 +1,4 @@
-title: A.html
+title = A.html
---
<p>a.html</p>
diff --git a/include/lexer.h b/include/lexer.h
index 4621f6f..f7cb6d2 100644
--- a/include/lexer.h
+++ b/include/lexer.h
@@ -38,7 +38,12 @@ typedef struct {
char *content;
} eachdo_operands_t;
-list_t *lex(char *buffer);
+typedef struct {
+ list_t *matches;
+ list_t *directives;
+} lex_t;
+
+lex_t *lex(char *buffer);
directive_t *find_directive(char *content, key_match_t *match);
key_match_t *find_next_key(char *buffer, size_t skip);
char *find_contentfor_value(list_t *content_headers, char *key);
diff --git a/src/engine.c b/src/engine.c
index a494b71..a334e2c 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -1,6 +1,7 @@
#include "util.h"
#define _GNU_SOURCE
+#include <config.h>
#include <copy.h>
#include <engine.h>
#include <filehandler.h>
diff --git a/src/lexer.c b/src/lexer.c
index 0ac6c6a..a1f893f 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -9,10 +9,12 @@
#include <string.h>
#include <util.h>
-list_t *
+lex_t *
lex(char *buffer)
{
+ lex_t *out = malloc(sizeof(lex_t));
list_t *directives = list_create(sizeof(directive_t));
+ list_t *matches = list_create(sizeof(key_match_t));
size_t current_offset = 0;
while (true) {
@@ -50,7 +52,9 @@ lex(char *buffer)
list_add(directives, raw_directive);
}
- return directives;
+ out->directives = directives;
+ out->matches = matches;
+ return out;
}
key_match_t *
diff --git a/src/template.c b/src/template.c
index b3536cc..ed6d9e0 100644
--- a/src/template.c
+++ b/src/template.c
@@ -28,8 +28,11 @@ template_create(void)
fclose(base);
ingest(&buffer);
- template->components = lex(buffer);
+ lex_t *lexed = lex(buffer);
+ template->components = lexed->directives;
+ list_delete(lexed->matches);
+ free(lexed);
free(buffer);
return template;
}