Package org.apache.wiki.parser
Class MarkupParser
java.lang.Object
org.apache.wiki.parser.MarkupParser
- Direct Known Subclasses:
- JSPWikiMarkupParser,- MarkdownParser
public abstract class MarkupParser extends java.lang.Object
Provides an abstract class for the parser instances.
- Since:
- 2.4
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringCLASS_ATTACHMENTThe value for anchor element class attributes when used for attachments.static java.lang.StringCLASS_EDITPAGEThe value for anchor element class attributes when used for edit page links.static java.lang.StringCLASS_EXTERNALThe value for anchor element class attributes when used for external links.static java.lang.StringCLASS_FOOTNOTEThe value for anchor element class attributes when used for footnote links.static java.lang.StringCLASS_FOOTNOTE_REFThe value for anchor element class attributes when used for footnote links.static java.lang.StringCLASS_INTERWIKIThe value for anchor element class attributes when used for interwiki page links.static java.lang.String[]CLASS_TYPESstatic java.lang.StringCLASS_WIKIPAGEThe value for anchor element class attributes when used for wiki page (normal) links.static java.lang.StringHASHLINKprotected java.util.ArrayList<StringTransmutator>m_attachmentLinkMutatorChainprotected Contextm_contextprotected Enginem_engineprotected java.util.ArrayList<StringTransmutator>m_externalLinkMutatorChainprotected java.util.ArrayList<HeadingListener>m_headingListenerChainprotected java.io.PushbackReaderm_inprotected java.util.List<org.apache.oro.text.regex.Pattern>m_inlineImagePatternsKeeps image regexp Patternsprotected booleanm_inlineImagesprotected java.util.ArrayList<StringTransmutator>m_linkMutatorsprotected LinkParsingOperationsm_linkParsingOperationsprotected java.util.ArrayList<StringTransmutator>m_localLinkMutatorChainOptionally stores internal wikilinksprotected booleanm_parseAccessRulesstatic java.lang.StringOUTLINKOutlink css class.static java.lang.StringOUTLINK_IMAGEName of the outlink image; relative path to the JSPWiki directory.static java.lang.StringPROP_ALLOWHTMLIf set to "true", allows using raw HTML within Wiki text.static java.lang.StringPROP_CAMELCASELINKSIf true, consider CamelCase hyperlinks as well.static java.lang.StringPROP_PLAINURISIf true, all hyperlinks are translated as well, regardless whether they are surrounded by brackets.static java.lang.StringPROP_RUNPLUGINSIf set to "true", enables plugins during parsingstatic java.lang.StringPROP_USEATTACHMENTIMAGEIf true, all outward attachment info links have a small link image appended.static java.lang.StringPROP_USEOUTLINKIMAGEIf true, all outward links (external links) have a small link image appended.static java.lang.StringPROP_USERELNOFOLLOWIf set to "true", all external links are tagged with 'rel="nofollow"'protected static intPUSHBACK_BUFFER_SIZEAllow this many characters to be pushed back in the stream.
- 
Constructor SummaryConstructors Modifier Constructor Description protectedMarkupParser(Context context, java.io.Reader in)Constructs a MarkupParser.
- 
Method SummaryModifier and Type Method Description voidaddAttachmentLinkHook(StringTransmutator mutator)Adds a hook for processing attachment links.voidaddExternalLinkHook(StringTransmutator mutator)Adds a hook for processing external links.voidaddHeadingListener(HeadingListener listener)Adds a HeadingListener to the parser chain.voidaddLinkTransmutator(StringTransmutator mutator)Adds a hook for processing link texts.voidaddLocalLinkHook(StringTransmutator mutator)Adds a hook for processing local links.static java.lang.StringcleanLink(java.lang.String link)Cleans a Wiki name.voiddisableAccessRules()Disables access rule parsing.voidenableImageInlining(boolean toggle)Use this to turn on or off image inlining.java.util.List<org.apache.oro.text.regex.Pattern>getInlineImagePatterns()intgetPosition()Return the current position in the reader stream.protected voidinitInlineImagePatterns()booleanisImageInlining()booleanisParseAccessRules()static org.jdom2.ElementmakeError(java.lang.String error)Writes HTML for error message.protected intnextToken()Returns the next token in the stream.abstract WikiDocumentparse()Parses the document.protected voidpushBack(int c)Push back any character to the current input.java.io.ReadersetInputReader(java.io.Reader in)Replaces the current input character stream with a new one.static java.lang.StringwikifyLink(java.lang.String link)Cleans away extra legacy characters.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- 
Field Details- 
PUSHBACK_BUFFER_SIZEAllow 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
- 
m_engine
- 
m_context
- 
m_localLinkMutatorChainOptionally stores internal wikilinks
- 
m_externalLinkMutatorChain
- 
m_attachmentLinkMutatorChain
- 
m_linkMutators
- 
m_headingListenerChain
- 
m_inlineImages
- 
m_parseAccessRules
- 
m_inlineImagePatternsKeeps image regexp Patterns
- 
m_linkParsingOperations
- 
PROP_ALLOWHTMLIf 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_RUNPLUGINSIf set to "true", enables plugins during parsing- See Also:
- Constant Field Values
 
- 
PROP_USEOUTLINKIMAGEIf true, all outward links (external links) have a small link image appended.- See Also:
- Constant Field Values
 
- 
PROP_USERELNOFOLLOWIf set to "true", all external links are tagged with 'rel="nofollow"'- See Also:
- Constant Field Values
 
- 
PROP_CAMELCASELINKSIf true, consider CamelCase hyperlinks as well.- See Also:
- Constant Field Values
 
- 
PROP_PLAINURISIf true, all hyperlinks are translated as well, regardless whether they are surrounded by brackets.- See Also:
- Constant Field Values
 
- 
PROP_USEATTACHMENTIMAGEIf true, all outward attachment info links have a small link image appended.- See Also:
- Constant Field Values
 
- 
HASHLINK- See Also:
- Constant Field Values
 
- 
OUTLINK_IMAGEName of the outlink image; relative path to the JSPWiki directory.- See Also:
- Constant Field Values
 
- 
OUTLINKOutlink css class.- See Also:
- Constant Field Values
 
- 
CLASS_WIKIPAGEThe value for anchor element class attributes when used for wiki page (normal) links. The value is "wikipage".- See Also:
- Constant Field Values
 
- 
CLASS_EDITPAGEThe value for anchor element class attributes when used for edit page links. The value is "createpage".- See Also:
- Constant Field Values
 
- 
CLASS_INTERWIKIThe value for anchor element class attributes when used for interwiki page links. The value is "interwiki".- See Also:
- Constant Field Values
 
- 
CLASS_FOOTNOTEThe value for anchor element class attributes when used for footnote links. The value is "footnote".- See Also:
- Constant Field Values
 
- 
CLASS_FOOTNOTE_REFThe value for anchor element class attributes when used for footnote links. The value is "footnote".- See Also:
- Constant Field Values
 
- 
CLASS_EXTERNALThe value for anchor element class attributes when used for external links. The value is "external".- See Also:
- Constant Field Values
 
- 
CLASS_ATTACHMENTThe value for anchor element class attributes when used for attachments. The value is "attachment".- See Also:
- Constant Field Values
 
- 
CLASS_TYPES
 
- 
- 
Constructor Details- 
MarkupParserConstructs a MarkupParser. The subclass must call this constructor to set up the necessary bits and pieces.- Parameters:
- context- The WikiContext.
- in- The reader from which we are reading the bytes from.
 
 
- 
- 
Method Details- 
setInputReaderReplaces 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
 
- 
addLinkTransmutatorAdds 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.
 
- 
addLocalLinkHookAdds 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.
 
- 
addExternalLinkHookAdds 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.
 
- 
addAttachmentLinkHookAdds a hook for processing attachment links.- Parameters:
- mutator- The hook to call. Null is safe.
 
- 
addHeadingListenerAdds a HeadingListener to the parser chain. It will be called whenever a parsed header is found.- Parameters:
- listener- The listener to add.
 
- 
disableAccessRulesDisables access rule parsing.
- 
isParseAccessRules
- 
enableImageInliningUse 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
 
- 
isImageInlining
- 
initInlineImagePatterns
- 
getInlineImagePatterns
- 
parseParses the document.- Returns:
- the parsed document, as a WikiDocument
- Throws:
- java.io.IOException- If something goes wrong.
 
- 
getPositionReturn the current position in the reader stream. The value will be -1 prior to reading.- Returns:
- the reader position as an int.
 
- 
nextTokenReturns the next token in the stream. This is the most called method in the entire parser, so it needs to be lean and mean.- Returns:
- The next token in the stream; or, if the stream is ended, -1.
- Throws:
- java.io.IOException- If something bad happens
- java.lang.NullPointerException- If you have not yet created an input document.
 
- 
pushBackPush back any character to the current input. Does not push back a read EOF, though.- Parameters:
- c- Character to push back.
- Throws:
- java.io.IOException- In case the character cannot be pushed back.
 
- 
makeErrorWrites HTML for error message. Does not add it to the document, you have to do it yourself.- Parameters:
- error- The error string.
- Returns:
- An Element containing the error.
 
- 
cleanLinkCleans a Wiki name. The functionality of this method was changed in 2.6 so that the list of allowed characters is much larger. UsewikifyLink(String)to get the legacy behaviour.[ This is a link ] -> This is a link - Parameters:
- link- Link to be cleared. Null is safe, and causes this to return null.
- Returns:
- A cleaned link.
- Since:
- 2.0
 
- 
wikifyLinkCleans away extra legacy characters. This method functions exactly like pre-2.6 cleanLink()[ 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.6
 
 
-