txt2html

Converts plaintext to HTML
git clone git://src.gearsix.net/txt2html
Log | Files | Refs | Atom | README

commit 740228f5457cee6ad38ee2c1ef63cad4ea8042d9
parent 10e94a12a87ed48e37b4686f07c7fafc91541a11
Author: gearsix <gearsix@tuta.io>
Date:   Sat, 10 Jul 2021 13:18:43 +0100

tidyup to misc files

Diffstat:
MBUGS | 4+++-
MTODO | 22+++++++++++-----------
Aast.txt | 27+++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/BUGS b/BUGS @@ -1 +1,3 @@ -[ ] for some reason the first <ol> in test.txt is parsed as a single <li>. +3. [ ] binaries compiled with musl don't work as intended (no reason for this to be compiler-bound) +2. [ ] there are a few memory leaks to fix (see valgrind output) +1. [*] for some reason the first <ol> in test.txt is parsed as a single <li>. diff --git a/TODO b/TODO @@ -1,12 +1,12 @@ [x] rename writeP -[ ] remove ASTLIMIT -[~] implement ol -[~] implement ul -[~] implement li -[~] implement h1 -[~] implement h2 -[ ] write tests -[ ] test ast against just writing straight to buffer -[ ] avoid recursion (unless needed) -[ ] test against test.txt, improve test.txt for catching edge-cases -[ ] maybe rename to NAML (not another markup language) +[ ] remove ASTLIMIT(?) +[*] implement ol +[*] implement ul +[*] implement li +[*] implement h1 +[*] implement h2 +[~] write tests +[*] avoid recursion (unless needed) +[*] test against test.txt, improve test.txt for catching edge-cases +[ ] maybe rename to naml (not another markup language) if it goes beyond txt2html +[ ] add utf-8 support (possibly more) diff --git a/ast.txt b/ast.txt @@ -0,0 +1,27 @@ + +ast +=== + +pseudo-code to help remember the parsing rules +for the ast, should try convert to to LARL when +there's time. + +\u = unicode character (note utf-x currently just using std c ascii support) +\t = horizintal tab +\n = newline + +node{ + "\n\n" = '<//>' + "\u." = '<ol>', '<li>' = {list} + "[*-] " = '<ul>', '<li>' = {list} + "\t\u" = '<pre>' + "\u\n==={=}\n" = '<h1>' + "\u\n---{-}\n" = '<h2>' + "\u[\u\n\t]\n\n" = '<p>' +} + +list{ + "\n[\n\0]" = '</li>','</ol>' + "\n\u." = '</li>','<li>' + "\n\u[^.]" = (hardbreaks) ? '<br/>' : ' ' +}