Interface WikiTextElement

All Known Implementing Classes:
Article, Bold, CategoryLink, CategoryList, CategoryList.Category, ExternalLink, HorizontalRule, IndentedBlock, Italic, LineBreak, ListItem, NodeAttribute, Redirect, Section, Text, UnnamedExternalLink, WikiLink, WikiLinkNamespaceComponent, WikiLinkTarget, WikiTextList, WikiTextNode, WikiTextParentNode, XMLContainerElement, XMLStandaloneElement

public interface WikiTextElement
The main interface for all AST nodes. Tree is constructed in these steps:
  1. Construct the AST nodes from the parse tree by walking the parse tree in a depth-first search and building the AST from the bottom up.
  2. Pass context from the root down, mutating elements as needed.
  3. Render the tree from the bottom up, passing context back up as needed. (eg. page categories)

Context passing should happen only once in each direction to avoid complexity. Passing context downwards should be done as little as possible.

All nodes should extend from `WikiTextParentNode` or `WikiTextLeafNode` as they do most of the passing and rendering heavy lifting for you.

  • Method Summary

    Modifier and Type
    Method
    Description
    default Set<String>
    Category links are leaf nodes but we want to include them as attributes of an article.
  • Method Details

    • getCategories

      default Set<String> getCategories()
      Category links are leaf nodes but we want to include them as attributes of an article. This gives us three cases to consider:
      1. Leaf nodes that are category links. We want to pass these up to the parent nodes. This is handled in Category objects.
      2. Other leaf nodes. These aren't categories and should return nothing. This is the default case in the WikiTextNode interface.
      3. Parent nodes. These aren't categories by themselves, and should return the union of the categories of their children. This is handled in WikiTextParent nodes
      Returns:
      A set of categories as strings.