From 36037763033dbf0896fd8c1b865d096f9d8b4419 Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Thu, 4 Jan 2024 19:58:12 +0100 Subject: [PATCH] eval: basic done --- eval.c | 13 +++++++++++++ eval.h | 1 + lexer.c | 2 ++ lexer.h | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index 2c8433a..5a7512d 100644 --- a/eval.c +++ b/eval.c @@ -3,6 +3,8 @@ #include "lexer.h" #include "form.h" +// TODO: BLOCKQUOTE OL PROGRESS CODE TABLE + #define PAGE_WIDTH 80 #define EXPAND_LIT(x) x, sizeof(x) @@ -45,8 +47,15 @@ void evaluate(Token* token){ printf(FC_nBOLD); break_line(); } + else if (token->type == UL){ + state.inList = 1; + } + else if (token->type == UL){ + state.inList = 0; + } else if (token->type == LI) { + break_line(); print_text(EXPAND_LIT("- ")); } else if (token->type == END_LI) @@ -92,6 +101,10 @@ void evaluate(Token* token){ printf(FC_nUDL); print_text(EXPAND_LIT(" ")); } + else if (token->type == P) + { + if (!state.inList) break_line(); + } else if (token->type == END_P) { break_line(); diff --git a/eval.h b/eval.h index 2234287..32e4bf1 100644 --- a/eval.h +++ b/eval.h @@ -8,6 +8,7 @@ typedef struct PageState { int x; int y; int beginLine; + int inList; } PageState; void evaluate(Token* token); diff --git a/lexer.c b/lexer.c index 21947d2..619206e 100644 --- a/lexer.c +++ b/lexer.c @@ -245,6 +245,8 @@ TokenType token_by_name(const char name[HTML_BALISE_LEN]){ return HR; } else if (strncmp(name, "br", HTML_BALISE_LEN) == 0){ return BR; + } else if (strncmp(name, "p", HTML_BALISE_LEN) == 0){ + return P; } else if (strncmp(name, "/p", HTML_BALISE_LEN) == 0){ return END_P; } else if (strncmp(name, "a", HTML_BALISE_LEN) == 0){ diff --git a/lexer.h b/lexer.h index 130c66c..2b06dde 100644 --- a/lexer.h +++ b/lexer.h @@ -18,7 +18,7 @@ typedef enum TokenType { IMG, END_IMG, BLOCKQUOTE, END_BLOCKQUOTE, CODE, END_CODE, - HR, BR, END_P, + HR, BR, P, END_P, PROGRESS, END_PROGRESS, STRONG, B, I, EM, END_STRONG, END_B, END_I, END_EM,