Package org.apache.wiki.parser
Class JSPWikiMarkupParser
java.lang.Object
org.apache.wiki.parser.MarkupParser
org.apache.wiki.parser.JSPWikiMarkupParser
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final int
The token is a plain character.protected static final int
protected static final int
The token is a wikimarkup element.protected static final int
protected static final int
protected static final int
The token is to be ignored.protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
Fields inherited from class org.apache.wiki.parser.MarkupParser
CLASS_ATTACHMENT, CLASS_EDITPAGE, CLASS_EXTERNAL, CLASS_FOOTNOTE, CLASS_FOOTNOTE_REF, CLASS_INTERWIKI, CLASS_TYPES, CLASS_WIKIPAGE, HASHLINK, m_attachmentLinkMutatorChain, m_context, m_engine, m_externalLinkMutatorChain, m_headingListenerChain, m_in, m_inlineImagePatterns, m_inlineImages, m_linkMutators, m_linkParsingOperations, m_localLinkMutatorChain, m_parseAccessRules, OUTLINK, OUTLINK_IMAGE, PROP_ALLOWHTML, PROP_CAMELCASELINKS, PROP_PLAINURIS, PROP_RUNPLUGINS, PROP_USEATTACHMENTIMAGE, PROP_USEOUTLINKIMAGE, PROP_USERELNOFOLLOW, PUSHBACK_BUFFER_SIZE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
callMutatorChain
(Collection<StringTransmutator> list, String text) Calls a transmutator chain.org.jdom2.Element
makeHeading
(int level, String title, Heading hd) Returns XHTML for the heading.protected String
makeHeadingAnchor
(String baseName, String title, Heading hd) Modifies the "hd" parameter to contain proper values.parse()
Parses the entire document from the Reader given in the constructor or set byMarkupParser.setInputReader(Reader)
.protected int
parseToken
(int ch) 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.Methods inherited from class org.apache.wiki.parser.MarkupParser
addAttachmentLinkHook, addExternalLinkHook, addHeadingListener, addLinkTransmutator, addLocalLinkHook, cleanLink, disableAccessRules, enableImageInlining, getInlineImagePatterns, getPosition, initInlineImagePatterns, isImageInlining, isParseAccessRules, makeError, nextToken, pushBack, setInputReader, wikifyLink
-
Field Details
-
READ
- See Also:
-
EDIT
- See Also:
-
EMPTY
- See Also:
-
LOCAL
- See Also:
-
LOCALREF
- See Also:
-
IMAGE
- See Also:
-
EXTERNAL
- See Also:
-
INTERWIKI
- See Also:
-
IMAGELINK
- See Also:
-
IMAGEWIKILINK
- See Also:
-
ATTACHMENT
- See Also:
-
CHARACTER
The token is a plain character.- See Also:
-
ELEMENT
The token is a wikimarkup element.- See Also:
-
IGNORE
The token is to be ignored.- See Also:
-
-
Constructor Details
-
JSPWikiMarkupParser
Creates a markup parser.- Parameters:
context
- The WikiContext which controls the parsingin
- Where the data is read from.
-
-
Method Details
-
callMutatorChain
Calls a transmutator chain.- Parameters:
list
- Chain to calltext
- Text that should be passed to the mutate() method of each of the mutators in the chain.- Returns:
- The result of the mutation.
-
makeHeadingAnchor
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
Returns XHTML for the heading.- Parameters:
level
- The level of the heading. @see Headingtitle
- the title for the headinghd
- a List to which heading should be added- Returns:
- An Element containing the heading
-
parseToken
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
orIGNORE
.- Throws:
IOException
- If parsing fails.
-
parse
Parses the entire document from the Reader given in the constructor or set byMarkupParser.setInputReader(Reader)
.- Specified by:
parse
in classMarkupParser
- Returns:
- A WikiDocument, ready to be passed to the renderer.
- Throws:
IOException
- If parsing cannot be accomplished.
-