From fc27aeb9c81b33d8dec51a26083d2f5302eb1afb Mon Sep 17 00:00:00 2001 From: Tan Kian-ting Date: Tue, 7 Oct 2025 02:41:00 +0800 Subject: [PATCH] add test plugin --- expander.rkt | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/expander.rkt b/expander.rkt index 72810e0..8a53e9a 100644 --- a/expander.rkt +++ b/expander.rkt @@ -4,6 +4,7 @@ (define main-config (make-hash '(["paper-width". 2480] ["paper-height". 3508] + ["lang" . #f] ["font-family" . "FreeSerif"] ["font-family-CJK" . "Noto Sans CJK TC"] ["font-size" . 14] @@ -25,7 +26,12 @@ (dict-set! main-config attr val)) (define (main-text txt) - (dict-set! main-frame "content" txt)) + (begin + (dict-set! main-frame "content" txt) + (for/list ([p plugin-list]) + [if (memq (dict-ref p "lang") (dict-ref main-config "lang")) + [let ([tmp ((dict-ref p "body") (dict-ref main-frame "content"))]) + (dict-set! main-frame "content" tmp)] #f]))) (define-syntax text-series (syntax-rules () @@ -33,10 +39,24 @@ ; delete the beginning newline (if (eq? (caar `(x ...)) "\n") `('text ,(cdar `(x ...))) - `('text ,(caar `(x ...)) ,(cdar `(x ...)))))])) - + `('text ,(caar `(x ...)) ,(cdar `(x ...))))])) + + + (define plugin-list '()) + +(define plugin-test (make-hash `(["lang" . "zh"] + ["body" . ,(lambda (x) "result:foo")]))) + +(set! plugin-list (reverse (cons plugin-test (reverse plugin-list)))) + + + + + + (provide text-series main-text main-frame main-config set-main-config set! (all-from-out racket/base) (all-from-out racket/dict) #%module-begin #%app #%datum #%expression #%top) - - ) + + + ) \ No newline at end of file