MultilineStrings

MultilineStrings.indentMethod
indent(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.

source
MultilineStrings.multilineMethod
multiline(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 processed

  • indicators::AbstractString: A terse string representing the style and chomp. Indicators can be either in letter-form or in YAML-form:

    • fs / >-: folded and strip
    • fc / >: folded and clip
    • fk / >+: folded and keep
    • ls / |-: literal and strip
    • lc / |: literal and clip
    • lk / |": literal and keep

See https://yaml-multiline.info for more details.

source
MultilineStrings.multilineMethod
multiline(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)
source
MultilineStrings.@m_strMacro
@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"
source