md

cat markdown files with syntax highlighting
git clone https://noulin.net/git/md.git
Log | Files | Refs | README | LICENSE

commit 82132b41ac7d21bad90deb1a6d36e789e5e451ba
parent ae7673caff28e69d0f446ec57badf53e2bd7e9d0
Author: Remy Noulin <loader2x@gmail.com>
Date:   Sun,  4 Dec 2022 19:34:56 +0100

show header levels

md.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

Diffstat:
Mmd.c | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/md.c b/md.c @@ -148,7 +148,7 @@ leave_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata) } if (r->ol == MD_BLOCK_OL) { char *s = intToS(r->olCount); - pushG(&s, ". "); + pErrorNULL(pushG(&s, ". ")); prependG(r->current, s); free(s); r->olCount++; @@ -165,7 +165,10 @@ leave_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata) //puts(BLU "</hN>" RST); r->h = 0; pushG(r->out, ""); - prependG(r->current, "# "); + prependG(r->current, " "); + loop(((MD_BLOCK_H_DETAIL*)detail)->level) { + prependG(r->current, "#"); + } colorG(r->current, BLD YLW); pushG(r->out, r->current); pushG(r->out,""); @@ -184,7 +187,7 @@ leave_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata) } if (r->ol == MD_BLOCK_OL) { char *s = intToS(r->olCount); - pushG(&s, ". "); + pErrorNULL(pushG(&s, ". ")); prependG(r->current, s); free(s); r->olCount++; @@ -192,7 +195,7 @@ leave_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata) r->li = 0; } ADD_BLOCKQUOTE - pushG(r->out, r->current); + pErrorNULL(pushG(r->out, r->current)); rallocG(r->current, ""); break; /* case MD_BLOCK_TABLE: RENDER_LITERAL(r, "</table>\n"); break; */ @@ -344,9 +347,7 @@ md_highlight(const char *md_source) { return NULL; } - outt result; - - memset(&result, 0, sizeof(result)); + outt result = init0Var; result.out = allocG(rtSmallArrayt); result.current = allocG("");