From 6be9f69cf36a7ddc9a7c2868b77dd5db4a3a05c1 Mon Sep 17 00:00:00 2001 From: saturn Date: Thu, 30 Jun 2022 02:41:39 -0500 Subject: [PATCH] Fix bug when hyphenating a base-string. --- src/clean-html.lisp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/clean-html.lisp b/src/clean-html.lisp index c7f996e8..c8b89196 100644 --- a/src/clean-html.lisp +++ b/src/clean-html.lisp @@ -84,19 +84,19 @@ (defun hyphenate-string (string) (let ((hyphenation-list (cl-typesetting::hyphenate-string string))) - (declare (type (and string (not base-string)) string) - (type list hyphenation-list)) + (declare (type list hyphenation-list)) (if hyphenation-list - (let ((new-string (make-array (+ (length string) (length hyphenation-list)) :element-type 'character :fill-pointer 0))) - (loop for char across string - for orig-offset of-type fixnum from 0 - with current-hyphenation = hyphenation-list - do (when (and current-hyphenation (= orig-offset (the fixnum (first current-hyphenation)))) - (vector-push #\SOFT_HYPHEN new-string) - (setf current-hyphenation (rest current-hyphenation))) - do (vector-push char new-string)) - (values new-string hyphenation-list)) - (values string nil)))) + (let ((string (coerce string '(simple-array character 1))) + (new-string (make-array (+ (length string) (length hyphenation-list)) :element-type 'character :fill-pointer 0))) + (loop for char across string + for orig-offset of-type fixnum from 0 + with current-hyphenation = hyphenation-list + do (when (and current-hyphenation (= orig-offset (the fixnum (first current-hyphenation)))) + (vector-push #\SOFT_HYPHEN new-string) + (setf current-hyphenation (rest current-hyphenation))) + do (vector-push char new-string)) + (values (coerce new-string '(simple-array character 1)) hyphenation-list)) + (values string nil)))) (defun clean-text-to-html (text &key (hyphenation t)) (handler-bind -- 2.11.4.GIT