Functions to introspect the Link_Bracket property.
Link_Bracket maps a closing bracket to the opening bracket it pairs with, as defined by UTS #58. The link termination algorithm uses it to decide whether a closing bracket encountered inside a candidate link matches the innermost unclosed opening bracket — if it does the bracket is part of the link, and if it does not the link ends before it.
This is a codepoint-valued mapping rather than a set of ranges, so it does not implement Unicode.Property.Behaviour. It is also distinct from the UCD's Bidi_Paired_Bracket: the two overlap but are scoped to different problems and are not interchangeable.
Summary
Functions
Returns the map of closing codepoints to their opening codepoints.
Returns the number of bracket pairs.
Returns the opening bracket paired with a closing bracket.
Returns the opening bracket paired with a closing bracket.
Returns whether a closing bracket pairs with a given opening bracket.
Functions
Returns the map of closing codepoints to their opening codepoints.
Returns
- A map with the closing codepoint as the key and the opening codepoint as the value.
Examples
iex> Unicode.LinkBracket.brackets() |> Map.get(?\))
40
Returns the number of bracket pairs.
Returns
- A non-negative integer count.
Examples
iex> Unicode.LinkBracket.count()
65
Returns the opening bracket paired with a closing bracket.
Arguments
codepointis a codepoint in the range0..0x10FFFF.
Returns
{:ok, opening_codepoint}if the codepoint is a closing bracket, or:errorif it is not.
Examples
iex> Unicode.LinkBracket.fetch(?\))
{:ok, 40}
iex> Unicode.LinkBracket.fetch(?a)
:error
Returns the opening bracket paired with a closing bracket.
Arguments
codepointis a codepoint in the range0..0x10FFFF.
Returns
The opening codepoint if the codepoint is a closing bracket, or
nilif it is not.
Examples
iex> Unicode.LinkBracket.get(?\])
91
iex> Unicode.LinkBracket.get(?a)
nil
Returns whether a closing bracket pairs with a given opening bracket.
Arguments
closingis a codepoint in the range0..0x10FFFF.openingis a codepoint in the range0..0x10FFFF.
Returns
trueifclosingis a closing bracket whose pair isopening, otherwisefalse.
Examples
iex> Unicode.LinkBracket.pair?(?\), ?\()
true
iex> Unicode.LinkBracket.pair?(?\), ?\[)
false