std.string.prose

escape-dollars

added in 3.0

(escape-dollars s)

for regex purposes, escape dollar signs in strings

(escape-dollars “$”) => string?

escape-escapes

added in 3.0

(escape-escapes s)

makes sure that newlines are printable

(escape-escapes "
") => "\ "

escape-newlines

added in 3.0

(escape-newlines s)

makes sure that newlines are printable

(escape-newlines "
") => "
"

escape-quotes

added in 3.0

(escape-quotes s)

makes sure that quotes are printable in string form

(escape-quotes “"hello"”) => “\“hello\””

filter-empty-lines

added in 3.0

(filter-empty-lines s)

filter empty line

(filter-empty-lines (common/join “\n” [“a” " " " " “b”])) => “a\nb”

has-quotes?

added in 3.0

(has-quotes? s)

checks if a string has quotes

(has-quotes? “"hello"”) => true

indent

added in 4.0

(indent block n & [{:keys [custom], :or {custom ""}}])

indents a block of string

(indent (write-lines “a” “b” “c”) 2) => “a\n b\n c”

indent-rest

added in 4.0

(indent-rest block n & [{:keys [custom], :or {custom ""}}])

indents the rest of the boiy

(indent-rest (write-lines “a” “b” “c”) 2) => “a\n b\n c”

join-lines

added in 4.0

(join-lines arr)

join non empty elements in array

(join-lines "" “hello” “world”) => “helloworld”

layout-lines

added in 4.0

(layout-lines tokens)(layout-lines tokens max)

layout tokens in lines depending on max length

(layout-lines “hello” “world” “again” “a” “b” 8) => “hello\nworld\nagain a\nb”

lines

added in 3.0

(lines s)

transforms string to seperated newlines

(lines “abc\ndef”) => ’(std.string.prose/| “abc” “def”)

multi-line?

added in 4.0

(multi-line? s)

check that a string has newlines

single-line

added in 3.0

(single-line s)

replace newlines with spaces

single-line?

added in 4.0

(single-line? s)

check that a string does not have newlines

spaces

added in 4.0

(spaces n)

create n spaces

(spaces 4) => ""

strip-quotes

added in 3.0

(strip-quotes s)

gets rid of quotes in a string

(strip-quotes “"hello"”) => “hello”

whitespace?

added in 3.0

(whitespace? s)

checks if the string is all whitespace

(whitespace? " ") => true

write-line

added in 4.0

(write-line v)

writes a line based on data structure

write-lines

added in 4.0

(write-lines lines)

writes a block of string

|

added in 3.0

(| & args)

shortcut for join lines

(| “abc” “def”) => “abc\ndef”