com.ecyrd.jspwiki.parser
Class MarkupParser

java.lang.Object
  extended by com.ecyrd.jspwiki.parser.MarkupParser
Direct Known Subclasses:
JSPWikiMarkupParser

public abstract class MarkupParser
extends Object

Provides an abstract class for the parser instances.

Since:
2.4
Author:
Janne Jalkanen

Field Summary
protected  ArrayList m_attachmentLinkMutatorChain
           
protected  WikiContext m_context
           
protected  WikiEngine m_engine
           
protected  ArrayList m_externalLinkMutatorChain
           
protected  ArrayList m_headingListenerChain
           
protected  PushbackReader m_in
           
protected  boolean m_inlineImages
           
protected  ArrayList m_linkMutators
           
protected  ArrayList m_localLinkMutatorChain
          Optionally stores internal wikilinks
protected  boolean m_parseAccessRules
           
static String PROP_ALLOWHTML
          If set to "true", allows using raw HTML within Wiki text.
static String PROP_RUNPLUGINS
          If set to "true", enables plugins during parsing
protected static String PUNCTUATION_CHARS_ALLOWED
          Lists all punctuation characters allowed in WikiMarkup.
protected static int PUSHBACK_BUFFER_SIZE
          Allow this many characters to be pushed back in the stream.
 
Constructor Summary
protected MarkupParser(WikiContext context, Reader in)
           
 
Method Summary
 void addAttachmentLinkHook(StringTransmutator mutator)
          Adds a hook for processing attachment links.
 void addExternalLinkHook(StringTransmutator mutator)
          Adds a hook for processing external links.
 void addHeadingListener(HeadingListener listener)
           
 void addLinkTransmutator(StringTransmutator mutator)
          Adds a hook for processing link texts.
 void addLocalLinkHook(StringTransmutator mutator)
          Adds a hook for processing local links.
static String cleanLink(String link)
          Cleans a Wiki name.
 void disableAccessRules()
           
 void enableImageInlining(boolean toggle)
          Use this to turn on or off image inlining.
abstract  WikiDocument parse()
          Parses the document.
 Reader setInputReader(Reader in)
          Replaces the current input character stream with a new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUSHBACK_BUFFER_SIZE

protected static final int PUSHBACK_BUFFER_SIZE
Allow this many characters to be pushed back in the stream. In effect, this limits the size of a single line.

See Also:
Constant Field Values

m_in

protected PushbackReader m_in

m_engine

protected WikiEngine m_engine

m_context

protected WikiContext m_context

m_localLinkMutatorChain

protected ArrayList m_localLinkMutatorChain
Optionally stores internal wikilinks


m_externalLinkMutatorChain

protected ArrayList m_externalLinkMutatorChain

m_attachmentLinkMutatorChain

protected ArrayList m_attachmentLinkMutatorChain

m_headingListenerChain

protected ArrayList m_headingListenerChain

m_linkMutators

protected ArrayList m_linkMutators

m_inlineImages

protected boolean m_inlineImages

m_parseAccessRules

protected boolean m_parseAccessRules

PROP_ALLOWHTML

public static final String PROP_ALLOWHTML
If set to "true", allows using raw HTML within Wiki text. Be warned, this is a VERY dangerous option to set - never turn this on in a publicly allowable Wiki, unless you are absolutely certain of what you're doing.

See Also:
Constant Field Values

PROP_RUNPLUGINS

public static final String PROP_RUNPLUGINS
If set to "true", enables plugins during parsing

See Also:
Constant Field Values

PUNCTUATION_CHARS_ALLOWED

protected static final String PUNCTUATION_CHARS_ALLOWED
Lists all punctuation characters allowed in WikiMarkup. These will not be cleaned away.

See Also:
Constant Field Values
Constructor Detail

MarkupParser

protected MarkupParser(WikiContext context,
                       Reader in)
Method Detail

setInputReader

public Reader setInputReader(Reader in)
Replaces the current input character stream with a new one.

Parameters:
in - New source for input. If null, this method does nothing.
Returns:
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.

Parameters:
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.

Parameters:
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.

Parameters:
mutator - The hook to call. Null is safe.

addAttachmentLinkHook

public void addAttachmentLinkHook(StringTransmutator mutator)
Adds a hook for processing attachment links.

Parameters:
mutator - The hook to call. Null is safe.

addHeadingListener

public void addHeadingListener(HeadingListener listener)

disableAccessRules

public void disableAccessRules()

enableImageInlining

public void enableImageInlining(boolean toggle)
Use this to turn on or off image inlining.

Parameters:
toggle - If true, images are inlined (as per set in jspwiki.properties) If false, then images won't be inlined; instead, they will be treated as standard hyperlinks.
Since:
2.2.9

parse

public abstract WikiDocument parse()
                            throws IOException
Parses the document.

Returns:
the parsed document, as a WikiDocument
Throws:
IOException

cleanLink

public static String cleanLink(String link)
Cleans a Wiki name.

[ This is a link ] -> ThisIsALink

Parameters:
link - Link to be cleared. Null is safe, and causes this to return null.
Returns:
A cleaned link.
Since:
2.0