Record Class MarkdownLink
java.lang.Object
java.lang.Record
com.google.common.labs.markdown.MarkdownLink
Represents a markdown link in the format of
[label](url).
This class offers a light-weight parser to quickly extract
markdown links from a markdown text or file.
While roughly equivalent to
import com.google.mu.util.StringFormat;
new StringFormat("[{label}]({url})")
.scan(markdown, MarkdownLink::new);
The parser properly handles escaping inside and outside of the link; nesting within the link
label and link url; and won't mistakenly extract link-like syntax from backtick-quoted code
or code blocks (recognizing code blocks quoted by single backtick, double, triple or any number
of consecutive backticks).- Since:
- 10.3
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMarkdownLink(String label, String url) Creates an instance of aMarkdownLinkrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.label()Returns the value of thelabelrecord component.static MarkdownLinkParseslinkinto aMarkdownLink.static Stream<MarkdownLink> Scansmarkdownand lazily extracts all markdown links.static Stream<MarkdownLink> Scansmarkdownand lazily extracts all markdown links.final StringtoString()Returns a string representation of this record class.url()Returns the value of theurlrecord component.
-
Field Details
-
PARSER
Parser for aMarkdownLink.Prefer using
of(java.lang.String)for parsing a single link andscan(String)for extracting multiple links. This constant is meant to be composed in larger parsers.
-
-
Constructor Details
-
MarkdownLink
-
-
Method Details
-
of
Parseslinkinto aMarkdownLink.- Throws:
NullPointerException- iflinkis nullIllegalArgumentException- if parsing failed
-
scan
Scansmarkdownand lazily extracts all markdown links.- Throws:
NullPointerException- ifmarkdownis null
-
scan
Scansmarkdownand lazily extracts all markdown links.- Throws:
NullPointerException- ifmarkdownis null
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
label
Returns the value of thelabelrecord component.- Returns:
- the value of the
labelrecord component
-
url
Returns the value of theurlrecord component.- Returns:
- the value of the
urlrecord component
-