public class JCreole
extends java.lang.Object
Assembles HTML pages built around main content built from Creole wikitext.
Applications may use CreoleScanner and CreoleParser directly for more precise control over how HTML pages are constructed, but be aware that the parser and scanner levels generate only HTML fragments. The easiest method of customizing behavior for an app would be to use the methods of this class (but not the main() method, which is intended for convience as opposed to flexibility). For heavier customization you could subclass this class, or start with a copy of the source code and modify it to fit with your application design and technologies.
This class manages 3 different Expanders.
As a consequence of what the expanders expand, if using default behavior, boilerplate text should !-reference 'pageHeaders' and 'pageContent' but nothing else. (Unless you are pre-processing the boilerplate external to JCreole). Creole may !-reference anywhere, since the earlier passes are expanded with the ignoreBang option. A Creole text !-reference means that they reference must be satisfied with either the creoleExpander or the htmlExpander and the Creole author doesn't need to be concerned with which of the two.
CreoleScanner
,
CreoleParser
Modifier and Type | Field and Description |
---|---|
protected CreoleParser |
parser |
static java.lang.String |
SYNTAX_MSG |
Constructor and Description |
---|
JCreole()
Use this when you want to work with HTML fragments externally.
|
JCreole(java.lang.String rawBoilerPlate) |
Modifier and Type | Method and Description |
---|---|
void |
addCssHrefs(java.util.List<java.lang.String> newCssHrefs) |
java.util.List<java.lang.String> |
getCssHrefs()
Returns a new list consisting of explicitly set cssHrefs + cssHrefs of
the underlying Parser.
|
java.lang.String |
getDefaultTargetWindow()
Calls the corresponding method on the underlying Parser.
|
Expander |
getFramingExpander()
Returns reference to the Framing Expander.
|
Expander |
getHtmlExpander()
Returns reference to the HTML Expander.
|
CreoleParser |
getParser()
Gets the underlying Parser, with which you can do a lot of useful stuff.
|
java.util.EnumSet<JCreolePrivilege> |
getPrivileges()
Calls the corresponding method on the underlying Parser.
|
java.lang.String |
htmlExpand(java.lang.String htmlString) |
static void |
main(java.lang.String[] sa)
Run this method with no parameters to see syntax requirements and the
available parameters.
|
java.lang.String |
parseCreole(java.io.File creoleFile)
Returns a HTML FRAGMENT from the specified Creole
Wikitext file.
|
java.lang.String |
parseCreole(java.lang.StringBuilder sb)
Returns a HTML FRAGMENT from the specified Creole
Wikitext.
|
java.lang.String |
postProcess(java.lang.String htmlFrag,
java.lang.String outputEol)
Generates clean html-expanded HTML with specified EOL type.
|
void |
setCreoleExpander(Expander creoleExpander)
Will use the specified creoleExpander when instantiating the scanner.
|
void |
setEnumerationFormats(java.lang.String enumerationFormats)
Legacy wrapper
|
void |
setEnumSymbols(java.lang.String symbolString,
boolean forSection)
Calls the corresponding method on the underlying Parser.
|
void |
setHtmlExpander(Expander htmlExpander)
Beware of this method.
|
void |
setInterWikiMapper(InterWikiMapper interWikiMapper)
Calls the corresponding method on the underlying Parser.
|
void |
setPrivileges(java.util.EnumSet<JCreolePrivilege> jcreolePrivs)
Calls the corresponding method on the underlying Parser.
|
public static final java.lang.String SYNTAX_MSG
protected CreoleParser parser
public JCreole()
public JCreole(java.lang.String rawBoilerPlate)
public Expander getFramingExpander()
public Expander getHtmlExpander()
public static void main(java.lang.String[] sa) throws java.io.IOException
Any long-running program should use the lower-level methods in this class instead (or directly use CreoleParser and CreoleScanner instances).
This method executes with all JCreole privileges.
This method sets up the following htmlExpander mappings (therefore you can reference these in both Creole and boilerplate text).
java.io.IOException
- for any I/O problem that makes it impossible to
satisfy the request.CreoleParseException
- if can not generate output, or if the run generates 0 output.
If the problem is due to input formatting, in most cases you
will get a CreoleParseException, which is a RuntimException, and
CreoleParseException has getters for locations in the source
data (though they will be offset for \r's in the provided
Creole source, if any).public java.lang.String parseCreole(java.lang.StringBuilder sb) throws java.io.IOException
CreoleParseException
- if can not generate output, or if the run generates 0 output.
If the problem is due to input formatting, in most cases you
will get a CreoleParseException, which is a RuntimException, and
CreoleParseException has getters for locations in the source
data (though they will be offset for \r's in the provided
Creole source, if any).java.io.IOException
public java.lang.String parseCreole(java.io.File creoleFile) throws java.io.IOException
if
- can not generate output, or if the run generates 0 output.
If the problem is due to input formatting, in most cases you
will get a CreoleParseException, which is a RuntimException, and
CreoleParseException has getters for locations in the source
data (though they will be offset for \r's in the provided
Creole source, if any).java.io.IOException
public java.lang.String postProcess(java.lang.String htmlFrag, java.lang.String outputEol) throws java.io.IOException
Call like
postProcess(htmlFrag, System.getProperty("line.separator")); to have output match your local platform default.Input htmlFrag doesn't need to worry about line delimiters, because it will be cleaned up as required.
If you are using no boilerplate and want \n line delimiters in output, then it is more efficient to just call htmlExpand() instead of this method.
This method implementation has dependencies on the provide boilerplates or others that follow its conventions.
outputEol
- Line delimiters for output. Null to leave as \n's.if
- can not generate output, or if the run generates 0 output.
If the problem is due to input formatting, in most cases you
will get a CreoleParseException, which is a RuntimException, and
CreoleParseException has getters for locations in the source
data (though they will be offset for \r's in the provided
Creole source, if any).java.io.IOException
public java.lang.String htmlExpand(java.lang.String htmlString)
public void setCreoleExpander(Expander creoleExpander)
public void setPrivileges(java.util.EnumSet<JCreolePrivilege> jcreolePrivs)
CreoleParser.setPrivileges(EnumSet)
public void setEnumerationFormats(java.lang.String enumerationFormats)
public void setEnumSymbols(java.lang.String symbolString, boolean forSection)
forSection
- If true apply to sections; if false apply to ordered lists.CreoleParser.setEnumSymbols(String, boolean)
public java.util.EnumSet<JCreolePrivilege> getPrivileges()
CreoleParser.getPrivileges()
public void setInterWikiMapper(InterWikiMapper interWikiMapper)
public java.lang.String getDefaultTargetWindow()
public CreoleParser getParser()
CreoleParser
public java.util.List<java.lang.String> getCssHrefs()
CreoleParser.getCssHrefs()
public void addCssHrefs(java.util.List<java.lang.String> newCssHrefs)
public void setHtmlExpander(Expander htmlExpander)