Class ContentSplitter

java.lang.Object
com.attribyte.parser.ContentSplitter

public class ContentSplitter extends Object
Split content into a single sequence of elements.
  • 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

      public ContentSplitter convertToInlineWithBreak(String tagName, String... mapTags)
      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

      public ContentSplitter withContainerTag(@NonNull String containerTag)
      Create a copy of this content splitter with new container tag.
      Parameters:
      containerTag - The container tag.
      Returns:
      The content splitter.
    • withIgnoreTags

      public ContentSplitter withIgnoreTags(@NonNull Set<String> ignoreTags)
      Create a copy of this content splitter with different ignore tags.
      Parameters:
      ignoreTags - The set of ignore tags.
      Returns:
      The content splitter.
    • withPreserveTags

      public ContentSplitter withPreserveTags(@NonNull Set<String> preserveTags)
      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.