Package com.attribyte.parser
Class ContentSplitter
java.lang.Object
com.attribyte.parser.ContentSplitter
Split content into a single sequence of elements.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToInlineWithBreak(String tagName, String... mapTags) Create a mapping function that converts a tag to an inline tag followed by a break.org.jsoup.select.Elementssplit(org.jsoup.nodes.Element elem) Split into elements.withContainerTag(@NonNull String containerTag) Create a copy of this content splitter with new container tag.withIgnoreTags(@NonNull Set<String> ignoreTags) Create a copy of this content splitter with different ignore tags.withMapTags(@NonNull Map<String, Function<org.jsoup.nodes.Element, List<org.jsoup.nodes.Node>>> mapTags) Create a copy of this content splitter with different map tag functions.withPreserveTags(@NonNull Set<String> preserveTags) Create a copy of this content splitter with different preserve tags.
-
Constructor Details
-
ContentSplitter
public ContentSplitter(@NonNull String containerTag, @Nullable Set<String> ignoreTags, @Nullable Set<String> preserveTags, @Nullable Map<String, Function<org.jsoup.nodes.Element, List<org.jsoup.nodes.Node>>> mapTags) Create a content splitter.- Parameters:
containerTag- The tag for each split element.ignoreTags- Tags to ignore.preserveTags- Tags to preserve as-is.mapTags- Function that maps the tag to a list of nodes in the output.
-
-
Method Details
-
convertToInlineWithBreak
Create a mapping function that converts a tag to an inline tag followed by a break.- Parameters:
tagName- The replacement tag name.- Returns:
- The nodes.
-
split
public org.jsoup.select.Elements split(org.jsoup.nodes.Element elem) Split into elements.- Parameters:
elem- The element to split.- Returns:
- The split elements.
-
withContainerTag
Create a copy of this content splitter with new container tag.- Parameters:
containerTag- The container tag.- Returns:
- The content splitter.
-
withIgnoreTags
Create a copy of this content splitter with different ignore tags.- Parameters:
ignoreTags- The set of ignore tags.- Returns:
- The content splitter.
-
withPreserveTags
Create a copy of this content splitter with different preserve tags.- Parameters:
preserveTags- The set of preserve tags.- Returns:
- The content splitter.
-
withMapTags
public ContentSplitter withMapTags(@NonNull Map<String, Function<org.jsoup.nodes.Element, List<org.jsoup.nodes.Node>>> mapTags) Create a copy of this content splitter with different map tag functions.- Parameters:
mapTags- The mapping function map.- Returns:
- The content splitter.
-