From bdbce0100ec999229d1910411d1fe6f27b7d4ada Mon Sep 17 00:00:00 2001 From: surdeus Date: Sun, 28 Jul 2024 18:16:41 +0500 Subject: [PATCH] feat: updated tpp. --- build.sh => build | 0 go.mod | 2 +- go.sum | 2 ++ handler.go | 12 +++++++++--- install.sh => install | 0 run-tht.sh => run-tht | 0 6 files changed, 12 insertions(+), 4 deletions(-) rename build.sh => build (100%) rename install.sh => install (100%) rename run-tht.sh => run-tht (100%) diff --git a/build.sh b/build similarity index 100% rename from build.sh rename to build diff --git a/go.mod b/go.mod index 82075b6..403e25d 100644 --- a/go.mod +++ b/go.mod @@ -7,5 +7,5 @@ require ( github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2 surdeus.su/core/cli v0.1.2 surdeus.su/core/xgo v0.8.0 - surdeus.su/util/tpp v0.3.3 + surdeus.su/util/tpp v0.4.0 ) diff --git a/go.sum b/go.sum index 5bd0e07..50fff03 100644 --- a/go.sum +++ b/go.sum @@ -18,3 +18,5 @@ surdeus.su/util/tpp v0.3.2 h1:ebcnEcY+4tgB4a6trs4GBd2CJjrZJaPKh3i5RKQf8/U= surdeus.su/util/tpp v0.3.2/go.mod h1:rXOVXwvdc7FxRGK/Smy03AXLQiet4N+2imFesic9Vzw= surdeus.su/util/tpp v0.3.3 h1:GEyOlt4M1jE9q9HSPAds9X85qEc/FUpD/M90vlROgLw= surdeus.su/util/tpp v0.3.3/go.mod h1:rXOVXwvdc7FxRGK/Smy03AXLQiet4N+2imFesic9Vzw= +surdeus.su/util/tpp v0.4.0 h1:GKmduh2AHdaTEZZptCH1yFfAcYiSTX8MvXTzIam8HpM= +surdeus.su/util/tpp v0.4.0/go.mod h1:rXOVXwvdc7FxRGK/Smy03AXLQiet4N+2imFesic9Vzw= diff --git a/handler.go b/handler.go index 61ed64f..38d7636 100644 --- a/handler.go +++ b/handler.go @@ -84,9 +84,16 @@ func DefaultPP(mod string) *tpp.Preprocessor { }).SetPreCode(func(ctx context.Context) []byte { return []byte(` + __os__ := import("os") + markdown := func(...args) { - pp.write_raw(__markdown__(args...)) + return pp.write_raw(__markdown__(args...)) } + + markdown_file := func(file_path){ + return pp.write_raw(__markdown(__os__.read_file(file_path))) + } + __http__ := immutable({ request : __http_request__ }) @@ -188,9 +195,8 @@ func (h *Handler) ServeHTTP( w.Header().Set("Content-Type", contentType) processedData := fileData if shouldProcess { - processedData, err = h.pp.Process( + _, processedData, err = h.pp.Process( ctx, - true, filePathTpp, fileData, ) diff --git a/install.sh b/install similarity index 100% rename from install.sh rename to install diff --git a/run-tht.sh b/run-tht similarity index 100% rename from run-tht.sh rename to run-tht