Class JSPWikiMarkupParser


  • public class JSPWikiMarkupParser
    extends MarkupParser
    Parses JSPWiki-style markup into a WikiDocument DOM tree. This class is the heart and soul of JSPWiki : make sure you test properly anything that is added, or else it breaks down horribly.
    Since:
    2.4
    • Constructor Detail

      • JSPWikiMarkupParser

        public JSPWikiMarkupParser​(Context context,
                                   java.io.Reader in)
        Creates a markup parser.
        Parameters:
        context - The WikiContext which controls the parsing
        in - Where the data is read from.
    • Method Detail

      • callMutatorChain

        protected java.lang.String callMutatorChain​(java.util.Collection<StringTransmutator> list,
                                                    java.lang.String text)
        Calls a transmutator chain.
        Parameters:
        list - Chain to call
        text - Text that should be passed to the mutate() method of each of the mutators in the chain.
        Returns:
        The result of the mutation.
      • makeHeadingAnchor

        protected java.lang.String makeHeadingAnchor​(java.lang.String baseName,
                                                     java.lang.String title,
                                                     Heading hd)
        Modifies the "hd" parameter to contain proper values. Because an "id" tag may only contain [a-zA-Z0-9:_-], we'll replace the % after url encoding with '_'.

        Counts also duplicate headings (= headings with similar name), and attaches a counter.

      • makeHeading

        public org.jdom2.Element makeHeading​(int level,
                                             java.lang.String title,
                                             Heading hd)
        Returns XHTML for the heading.
        Parameters:
        level - The level of the heading. @see Heading
        title - the title for the heading
        hd - a List to which heading should be added
        Returns:
        An Element containing the heading
      • parseToken

        protected int parseToken​(int ch)
                          throws java.io.IOException
        Return CHARACTER, if you think this was a plain character; ELEMENT, if you think this was a wiki markup element, and IGNORE, if you think we should ignore this altogether.

        To add your own MarkupParser, you can override this method, but it is recommended that you call super.parseToken() as well to gain advantage of JSPWiki's own markup. You can call it at the start of your own parseToken() or end - it does not matter.

        Parameters:
        ch - The character under investigation
        Returns:
        ELEMENT, CHARACTER or IGNORE.
        Throws:
        java.io.IOException - If parsing fails.
      • parse

        public WikiDocument parse()
                           throws java.io.IOException
        Parses the entire document from the Reader given in the constructor or set by MarkupParser.setInputReader(Reader).
        Specified by:
        parse in class MarkupParser
        Returns:
        A WikiDocument, ready to be passed to the renderer.
        Throws:
        java.io.IOException - If parsing cannot be accomplished.