tiny refac

main
Matthew Butterick 6 years ago
parent 2fc1e9b65c
commit b41dc3b021

@ -187,15 +187,21 @@
(for-each (λ (ee) (add-exception-word word-cache ee)) extra-exceptions)
(define word-pattern #px"\\w+") ;; more restrictive than exception-word
(define (replacer word . words)
(if (not (omit-word? word))
(string-join (word->hyphenation-points word word-cache pattern-cache min-length min-left-length min-right-length) (joiner->string joiner))
word))
(if (omit-word? word)
word
(string-join (word->hyphenation-points word
word-cache
pattern-cache
min-length
min-left-length
min-right-length)
(joiner->string joiner))))
(define (insert-hyphens text) (regexp-replace* word-pattern text replacer))
(define result (apply-proc insert-hyphens x omit-string? omit-txexpr? joiner))
(begin0
(apply-proc insert-hyphens x omit-string? omit-txexpr? joiner)
;; deleting from the main cache is cheaper than having to do two cache lookups for every word
;; (missing words will just be regenerated later)
(for-each (λ (ee) (remove-exception-word word-cache ee)) extra-exceptions)
result)
(for-each (λ (ee) (remove-exception-word word-cache ee)) extra-exceptions)))
(define (unhyphenate x [joiner default-joiner]

Loading…
Cancel
Save