add cjk-splitter pass
This commit is contained in:
parent
b9403f2858
commit
a7080a47b3
2 changed files with 24 additions and 2 deletions
21
expander.rkt
21
expander.rkt
|
|
@ -69,12 +69,33 @@
|
||||||
["body" . ,remove-newline-between-cjk-aux])))
|
["body" . ,remove-newline-between-cjk-aux])))
|
||||||
|
|
||||||
|
|
||||||
|
(define [splitter-cjk-aux cont]
|
||||||
|
(display (list-ref cont 1))
|
||||||
|
(define [splitter-cjk-unit x]
|
||||||
|
(define tmp (regexp-match* #rx"[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\U00020000-\U0002EBEF\u3000-\u303F·,。!?:」』》】]〕』〗〉}「『《〔[【『〖〈{…—]" x #:gap-select? #t))
|
||||||
|
(filter (lambda (x) [not (equal? x "")]) tmp))
|
||||||
|
(define [splitter-cjk-proc res rem]
|
||||||
|
(cond
|
||||||
|
[(eq? rem '()) (reverse res)]
|
||||||
|
[(string? [car rem]) [splitter-cjk-proc [append (reverse (splitter-cjk-unit [car rem])) res] (cdr rem)]]
|
||||||
|
[else [splitter-cjk-proc [cons (car rem) res] (cdr rem)]]
|
||||||
|
))
|
||||||
|
(list-set cont 1 (splitter-cjk-proc '() (list-ref cont 1))))
|
||||||
|
|
||||||
|
(define splitter-cjk (make-hash `(["lang" . "zh"]
|
||||||
|
["body" . ,splitter-cjk-aux])))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define-syntax append-plugin!
|
(define-syntax append-plugin!
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
[(_ ls plugin) (set! ls (reverse (cons plugin (reverse ls))))]))
|
[(_ ls plugin) (set! ls (reverse (cons plugin (reverse ls))))]))
|
||||||
|
|
||||||
[append-plugin! plugin-list two-newlines-into-par]
|
[append-plugin! plugin-list two-newlines-into-par]
|
||||||
[append-plugin! plugin-list remove-newline-between-cjk]
|
[append-plugin! plugin-list remove-newline-between-cjk]
|
||||||
|
[append-plugin! plugin-list splitter-cjk]
|
||||||
|
|
||||||
(define (main-text txt)
|
(define (main-text txt)
|
||||||
(begin
|
(begin
|
||||||
|
|
|
||||||
5
test1.ug
5
test1.ug
|
|
@ -1,8 +1,9 @@
|
||||||
#lang uahgi-ng
|
#lang uahgi2
|
||||||
{@display|`10.3}
|
{@display|`10.3}
|
||||||
{@dict?|@main-config}
|
{@dict?|@main-config}
|
||||||
|
{@set-main-config|lang|{@list|zh}}
|
||||||
{@set-main-config|paper-width|`2480}
|
{@set-main-config|paper-width|`2480}
|
||||||
{@display|{@dict-ref|@main-config|paper-width}}
|
{@display|{@dict-ref|@main-config|paper-width}}
|
||||||
{@main-text|
|
{@main-text|
|
||||||
天地人123我為貓}
|
{@hd2|我是貓 I'm a cat}天地人123我為貓}
|
||||||
{@display|@main-frame}
|
{@display|@main-frame}
|
||||||
Loading…
Reference in a new issue