Packages
earmark_parser
1.4.16-pre1
1.4.46
1.4.45
1.4.44
1.4.43
1.4.42
1.4.41
1.4.40
1.4.39
1.4.38
1.4.37
1.4.36
1.4.35
1.4.34
1.4.33
1.4.32
1.4.31
1.4.30
1.4.29
1.4.28
1.4.27
1.4.26
1.4.25
1.4.24
1.4.23
1.4.22
1.4.21
1.4.20
1.4.20-pre
1.4.19
1.4.18
1.4.17
1.4.16
1.4.16-pre2
1.4.16-pre1
1.4.16-pre
1.4.15
1.4.13
1.4.12
1.4.11
1.4.10
1.4.9
1.4.8
AST parser and generator for Markdown
Current section
Files
Jump to
Current section
Files
lib/earmark_parser/helpers/string_helpers.ex
defmodule EarmarkParser.Helpers.StringHelpers do
@moduledoc false
@doc """
Remove the leading part of a string
"""
def behead(str, ignore) when is_integer(ignore) do
String.slice(str, ignore..-1)
end
def behead(str, leading_string) do
behead(str, String.length(leading_string))
end
@doc """
Remove leading spaces up to size
"""
def behead_indent(str, size) do
String.replace(str, ~r<\A\s{0,#{size}}>, "")
end
@doc """
Returns a tuple with the prefix and the beheaded string
iex> behead_tuple("prefixpostfix", "prefix")
{"prefix", "postfix"}
"""
def behead_tuple(str, lead) do
{lead, behead(str, lead)}
end
def betail(str, length)
def betail(str, length) do
str
|> String.slice(0, max(0,String.length(str) - length))
end
end
# SPDX-License-Identifier: Apache-2.0