diff --git a/hyphenate/scribblings/hyphenate.scrbl b/hyphenate/scribblings/hyphenate.scrbl index ec78d4a4..cf80a433 100644 --- a/hyphenate/scribblings/hyphenate.scrbl +++ b/hyphenate/scribblings/hyphenate.scrbl @@ -115,6 +115,8 @@ Sometimes you need @racket[hyphenatef] to prevent unintended consequences. For i (hyphenatef "Hufflepuff golfing final on Tuesday" no-ligs? #\-) ] +@margin-note{``Wouldn't it be better to exclude certain pairs of letters rather than whole words?'' Yes. But for now, not supported.} + It's possible to do fancier kinds of hyphenation restrictions that take account of context, like not hyphenating the last word of a paragraph. But @racket[hyphenatef] only operates on words. So you'll have to write some fancier code. Separate out the words eligible for hyphenation, and then send them through good old @racket[hyphenate]. @defproc[ diff --git a/hyphenate/xexpr.rkt b/hyphenate/xexpr.rkt new file mode 100644 index 00000000..a90e5efc --- /dev/null +++ b/hyphenate/xexpr.rkt @@ -0,0 +1,39 @@ +#lang racket/base +(require "main.rkt") +(require xml) + + + +#| +The following grammar describes expressions that create X-expressions: + + xexpr = string + | (list symbol (list (list symbol string) ...) xexpr ...) + | (cons symbol (list xexpr ...)) + | symbol + | valid-char? + | cdata + | misc + +|# + + +;; recursively hyphenate strings within xexpr +;; todo: add exclusion #:only [only-proc (λ(x) x)] +(define (hyphenate-xexpr x ) + (define exclusions '(style script)) ; omit these from ever being hyphenated + + (cond + ; todo: the only-proc semantics are illogical. + ; main issue: keep it out of tags like