eval: basic done

This commit is contained in:
_N3m0 2024-01-04 19:58:12 +01:00
parent 8619caa1b6
commit 3603776303
4 changed files with 17 additions and 1 deletions

13
eval.c
View File

@ -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();

1
eval.h
View File

@ -8,6 +8,7 @@ typedef struct PageState {
int x;
int y;
int beginLine;
int inList;
} PageState;
void evaluate(Token* token);

View File

@ -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){

View File

@ -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,