MultilineStrings
MultilineStrings.indent
— Methodindent(str::AbstractString, n::Int)
Indent each non-blank line by n
spaces.
Examples
julia> indent("a\nb", 4)
" a\n b"
julia> indent(" a\n \n b", 2)
" a\n \n b"
See also Base.unindent
and Base.indentation
.
MultilineStrings.multiline
— Methodmultiline(str, indicators) -> AbstractString
Manipulate a multiline string according to the provided style and chomp encoded in the indicators
string.
Arguments
str::AbstractString
: The multiline string to be processedindicators::AbstractString
: A terse string representing the style and chomp. Indicators can be either in letter-form or in YAML-form:fs
/>-
: folded and stripfc
/>
: folded and clipfk
/>+
: folded and keepls
/|-
: literal and striplc
/|
: literal and cliplk
/|"
: literal and keep
See https://yaml-multiline.info for more details.
MultilineStrings.multiline
— Methodmultiline(str; style=:folded, chomp=:strip) -> AbstractString
Manipulate a multiline string according to the provided style
and chomp
. Works similarly to YAML multiline strings (also known as block scalars).
Arguments
str::AbstractString
: The multiline string to be processed
Keywords
style::Symbol
: Replace newlines with spaces (:folded
) or keep newlines (:literal
)chomp::Symbol
: No newlines at the end (:strip
), single newline at the end (:clip
), or keep all newlines from the end (:keep
)
MultilineStrings.@m_str
— Macro@m_str -> String
Manipulate a multiline string literal according to a style and chomp indicator (provided after the ending quote):
- Style indicator:
f
replace newlines with spaces (folded, default)l
keep newlines (literal)
- Chomp indicator:
s
no newlines at the end (strip, default)c
single newline at the end (clip)k
keep all newlines from the end (keep)
If both a style and chomp indicator is provided the style indicator must be specified first.
Note string interpolation is still respected any newlines added from interpolation will be also be processed.
See https://yaml-multiline.info for more details.
Examples
julia> m"""
A string written
over multiple lines
"""
"A string written over multiple lines"