From ce088cbf9c3a73e9f9ed3012d31dd6e989d86052 Mon Sep 17 00:00:00 2001 From: wrmr Date: Sun, 3 Nov 2024 12:12:20 -0500 Subject: file:// plaintext reading complete, add nav_next/nav_prev --- parse.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 parse.c (limited to 'parse.c') diff --git a/parse.c b/parse.c new file mode 100644 index 0000000..a1a68d8 --- /dev/null +++ b/parse.c @@ -0,0 +1,23 @@ +#include "parse.h" + +int parse_doc(enum doc_type type, struct doc *d, const buf_t *b) { + switch (type) { + case DOC_PLAIN: + doc_init(d); + for (size_t i = 0; i < b->sz; i++) { + char c = b->buf[i]; + if (c == '\n') { + doc_new_line(d); + } else { + doc_add_textn(d, &c, 1); + } + } + goto ok; + default: + goto err; + } +ok: + return 0; +err: + return -1; +} -- cgit 1.4.1-2-gfad0