Class MarkupParser

Direct Known Subclasses:
JSPWikiMarkupParser, MarkdownParser

public abstract class MarkupParser
extends java.lang.Object
Provides an abstract class for the parser instances.
  • Field Details

  • Constructor Details

    • MarkupParser

      protected MarkupParser​(Context context, in)
      Constructs a MarkupParser. The subclass must call this constructor to set up the necessary bits and pieces.
      context - The WikiContext.
      in - The reader from which we are reading the bytes from.
  • Method Details

    • setInputReader

      public setInputReader​( in)
      Replaces the current input character stream with a new one.
      in - New source for input. If null, this method does nothing.
      the old stream
    • addLinkTransmutator

      public void addLinkTransmutator​(StringTransmutator mutator)
      Adds a hook for processing link texts. This hook is called when the link text is written into the output stream, and you may use it to modify the text. It does not affect the actual link, only the user-visible text.
      mutator - The hook to call. Null is safe.
    • addLocalLinkHook

      public void addLocalLinkHook​(StringTransmutator mutator)
      Adds a hook for processing local links. The engine transforms both non-existing and existing page links.
      mutator - The hook to call. Null is safe.
    • addExternalLinkHook

      public void addExternalLinkHook​(StringTransmutator mutator)
      Adds a hook for processing external links. This includes all http:// ftp://, etc. links, including inlined images.
      mutator - The hook to call. Null is safe.
    • addAttachmentLinkHook

      public void addAttachmentLinkHook​(StringTransmutator mutator)
      Adds a hook for processing attachment links.
      mutator - The hook to call. Null is safe.
    • addHeadingListener

      public void addHeadingListener​(HeadingListener listener)
      Adds a HeadingListener to the parser chain. It will be called whenever a parsed header is found.
      listener - The listener to add.
    • disableAccessRules

      public void disableAccessRules()
      Disables access rule parsing.
    • isParseAccessRules

      public boolean isParseAccessRules()
    • enableImageInlining

      public void enableImageInlining​(boolean toggle)
      Use this to turn on or off image inlining.
      toggle - If true, images are inlined (as per set in If false, then images won't be inlined; instead, they will be treated as standard hyperlinks.
    • isImageInlining

      public boolean isImageInlining()
    • initInlineImagePatterns

      protected final void initInlineImagePatterns()
    • getInlineImagePatterns

      public java.util.List<org.apache.oro.text.regex.Pattern> getInlineImagePatterns()
    • parse

      public abstract WikiDocument parse() throws
      Parses the document.
      the parsed document, as a WikiDocument
      Throws: - If something goes wrong.
    • getPosition

      public int getPosition()
      Return the current position in the reader stream. The value will be -1 prior to reading.
      the reader position as an int.
    • nextToken

      protected final int nextToken() throws, java.lang.NullPointerException
      Returns the next token in the stream. This is the most called method in the entire parser, so it needs to be lean and mean.
      The next token in the stream; or, if the stream is ended, -1.
      Throws: - If something bad happens
      java.lang.NullPointerException - If you have not yet created an input document.
    • pushBack

      protected void pushBack​(int c) throws
      Push back any character to the current input. Does not push back a read EOF, though.
      c - Character to push back.
      Throws: - In case the character cannot be pushed back.
    • makeError

      public static org.jdom2.Element makeError​(java.lang.String error)
      Writes HTML for error message. Does not add it to the document, you have to do it yourself.
      error - The error string.
      An Element containing the error.
    • cleanLink

      public static java.lang.String cleanLink​(java.lang.String link)
      Cleans a Wiki name. The functionality of this method was changed in 2.6 so that the list of allowed characters is much larger. Use wikifyLink(String) to get the legacy behaviour.

      [ This is a link ] -> This is a link

      link - Link to be cleared. Null is safe, and causes this to return null.
      A cleaned link.
    • wikifyLink

      public static java.lang.String wikifyLink​(java.lang.String link)
      Cleans away extra legacy characters. This method functions exactly like pre-2.6 cleanLink()

      [ This is a link ] -> ThisIsALink

      link - Link to be cleared. Null is safe, and causes this to return null.
      A cleaned link.