◊(Local Yarn Code "Diff")

Differences From Artifact [178b993f]:

To Artifact [c0de1d26]:


145
146
147
148
149
150
151



152

153
154
155
156
157
158



159
160

161
162

163
164

165
166
167
168
169
170
171
145
146
147
148
149
150
151
152
153
154

155
156
157
158



159
160
161
162

163
164

165
166

167
168
169
170
171
172
173
174







+
+
+
-
+



-
-
-
+
+
+

-
+

-
+

-
+







         [pre-title (cond [(string>? title "") `(p [[class "verse-heading"]] ,title)]
                          [else ""])])
    `(div [[class "poem"]] ,pre-title (pre ,pre-attrs ,@elems))))

(define (html-magick . elems)
  (txexpr
   'div '([class "antique"])
   (decode-elements
    elems
    #:string-proc
   (decode-elements elems #:string-proc (λ (s) (regexp-replace* #px"(?<!f)s(?![fkb\\s]|$)" s "ſ")))))
    (λ (s) (regexp-replace* #px"(?<!f)s(?![fkb\\s”,;.’:\\!\\?]|$)" s "ſ")))))

(module+ test
  (require rackunit)
  ; round s at the end of a word
  (check-equal? (html-magick "is") '(div [[class "antique"]] "is"))
  ; round s before/after f
  ; always round s at the end of a word
  (check-equal? (html-magick "mirrors? yes, it is") '(div [[class "antique"]] "mirrors? yes, it is"))
  ; always round s before/after f
  (check-equal? (html-magick "offset, satisfaction") '(div [[class "antique"]] "offset, ſatisfaction"))
  ; long s before hyphen
  ; always LONG s before hyphen
  (check-equal? (html-magick "Shafts-bury") '(div [[class "antique"]] "Shaftſ-bury"))
  ; round s before k or b (17th-century rules)
  ; always round s before k or b (17th-century rules)
  (check-equal? (html-magick "ask, husband") '(div [[class "antique"]] "ask, husband"))
  ; long s everywhere else
  ; always LONG s everywhere else
  (check-equal? (html-magick "song, substitutes") '(div [[class "antique"]] "ſong, ſubſtitutes")) 

  ;; Nested elements
  (check-equal?
   (html-magick '(root "This is " (a [[href "class"]] (b "song, substitutes"))))
   '(div [[class "antique"]] (root "This is " (a [[href "class"]] (b "ſong, ſubſtitutes"))))))