Skip to content

Commit

Permalink
Don't insert spaces before non-alphabetic characters
Browse files Browse the repository at this point in the history
See #37.
  • Loading branch information
ruricolist committed Sep 22, 2024
1 parent ad203b7 commit fe03f8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
#:doplist
#:hash-table-keys
#:alist-hash-table
#:once-only)
#:once-only
#:first-elt)
(:import-from #:serapeum
#:fmt #:eif #:econd
#:define-do-macro #:defconst
Expand Down
6 changes: 4 additions & 2 deletions run.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@

(defmethod html :around ((string escaped-string))
(let ((string (escaped-string-value string)))
(when (string^= " " string)
(when (or (string^= " " string)
;; Don't insert spaces before punctuation.
(not (alpha-char-p (alexandria:first-elt string))))
(cancel-space)))
(call-next-method)
(values))
Expand Down Expand Up @@ -203,7 +205,7 @@
((and first-iteration?
(inline? (car *html-path*)))
(when (and (> (length word) 0)
(serapeum:whitespacep (aref word 0)))
(whitespacep (aref word 0)))
(wrap))
(write-string word html))
((> len fill)
Expand Down
6 changes: 6 additions & 0 deletions tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -844,3 +844,9 @@ bar</pre>"
(is (search ">Some"
(with-html-string
(f "http://thisisreallyreallylonglonglonglongonwegoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com"))))))

(test inline-tag-trailing-spaces
(is (equal
(spinneret:with-html-string
(:span "Click the " (:a :href "https://google.com" ) "."))
"<span>Click the <a href=\"https://google.com\"></a>.</span>")))

0 comments on commit fe03f8b

Please sign in to comment.