-
-
Save shrdlu68/beeed6385d9a323eebfdee5437c41dd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun add-text-padding (str &key padding newline) | |
"Add padding to text STR. Every line except for the first one, will be | |
prefixed with PADDING spaces. If NEWLINE is non-NIL, newline character will | |
be prepended to the text making it start on the next line with padding | |
applied to every single line." | |
(with-output-to-string (out-stream) | |
(with-input-from-string (in-stream str) | |
(loop initially (format out-stream "~A~:[~;~%~]" (read-line in-stream nil nil) newline) | |
for line = (read-line in-stream nil nil) | |
while line | |
do (format out-stream "~v@{ ~}~A~:[~;~%~]" padding line newline))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment