Functions to introspect the Link_Term property for binaries (Strings) and codepoints.
Link_Term drives the link termination algorithm of UTS #58, which decides where a URL or email address appearing in flowing text ends. The values are:
:include— the character belongs inside the link.:hard— the character terminates the link immediately. This is the default, so any codepoint not listed in the data terminates a link.:soft— the character terminates the link only when what follows is a run of soft characters and then a hard character or the end of the text. This is what letsSee example.com.drop the sentence-final full stop whileexample.com/a.bkeeps its inner one.:openand:close— bracket characters, paired throughUnicode.LinkBracket. A closing bracket is included when it matches the innermost open bracket and terminates the link otherwise.
The primary API is link_term/1 which returns the value for a codepoint, or the list of values for a string.
Summary
Functions
Returns a map of aliases for Link_Term values.
Returns the count of codepoints with a given Link_Term value.
Returns the Unicode codepoint ranges for a given Link_Term value.
Returns the Unicode codepoint ranges for a given Link_Term value.
Returns a list of known Link_Term values.
Returns the Link_Term value of the given binary or codepoint.
Returns the map of Link_Term values.
Functions
Returns a map of aliases for Link_Term values.
Link_Term is defined by UTS #58 rather than the UCD, so it has no entry in
PropertyValueAliases.txt and the only aliases are the value names themselves.
Returns
- A map where the alias string is the key and the value name is the value.
Examples
iex> Unicode.LinkTerm.aliases() |> Map.get("soft")
:soft
Returns the count of codepoints with a given Link_Term value.
Arguments
link_termis anyLink_Termvalue name, as an atom or string.
Returns
A non-negative integer count of the codepoints with that value.
:errorif the value is not known.
Examples
iex> Unicode.LinkTerm.count(:open)
65
Returns the Unicode codepoint ranges for a given Link_Term value.
Arguments
link_termis anyLink_Termvalue name, as an atom or string.
Returns
{:ok, range_list}whererange_listis a list of codepoint ranges as 2-tuples.:errorif the value is not known.
Examples
iex> Unicode.LinkTerm.fetch(:open) |> elem(0)
:ok
iex> Unicode.LinkTerm.fetch(:invalid)
:error
Returns the Unicode codepoint ranges for a given Link_Term value.
Arguments
link_termis anyLink_Termvalue name, as an atom or string.
Returns
A list of codepoint ranges as 2-tuples.
nilif the value is not known.
Examples
iex> Unicode.LinkTerm.get(:invalid)
nil
Returns a list of known Link_Term values.
Note that :hard is the default value and is therefore not listed in the data, so it does not appear here even though link_term/1 returns it.
Returns
- A list of atom value names.
Examples
iex> :include in Unicode.LinkTerm.known_link_terms()
true
Returns the Link_Term value of the given binary or codepoint.
Arguments
string_or_codepointis either a binary (String) or a codepoint in the range0..0x10FFFF.
Returns
For a codepoint, a single value atom. Codepoints not listed in the data return
:hard, the UTS #58 default.For a binary, a list of the distinct values of the codepoints in the binary.
Examples
iex> Unicode.LinkTerm.link_term(?a)
:include
iex> Unicode.LinkTerm.link_term(?.)
:soft
iex> Unicode.LinkTerm.link_term(?\s)
:hard
iex> Unicode.LinkTerm.link_term(?\()
:open
Returns the map of Link_Term values.
Returns
- A map where the value name is the key and a list of codepoint ranges as 2-tuples is the value.
Examples
iex> :soft in Map.keys(Unicode.LinkTerm.link_terms())
true