Created
August 16, 2010 19:56
-
-
Save bpsm/527621 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
(ns libpsm.string | |
(:require [clojure.string :as str])) | |
(let [triml-with-pipe (comp #(str/replace-first % "|" "") | |
str/triml)] | |
(defn mstr* | |
"Multiline string with explicit left margin." | |
[s] | |
(str/join "\n" (map triml-with-pipe | |
(str/split-lines s))))) | |
(defmacro mstr | |
"Multiline string with explicit left margin, maked by |. | |
Each line is trimmed of leading whitespace, up to and including | |
a leading | character." | |
[s] | |
(if (string? s) | |
(mstr* s) | |
`(mstr* ~s))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment