Hi,
I've just finished writing the main interfaces/classes of the new
rendering mechanism
(see
http://dev.xwiki.org/xwiki/bin/view/Design/NewRenderingArchitecture)
.
At this stage I'm eager to get feedback from the community. Here's a
quick explanation of how it works:
Main interfaces:
* Parser:
String getSyntaxId();
Document parse(Reader source) throws ParseException;
* Listener:
void beginBold();
void endBold();
void beginItalic();
void endItalic();
void beginParagraph();
void endParagraph();
void beginList(ListType listType);
void endList(ListType listType);
void beginListItem();
void endListItem();
void beginSection(SectionLevel level);
void endSection(SectionLevel level);
void beginXMLElement(String name, Map<String, String> attributes);
void endXMLElement(String name, Map<String, String> attributes);
void onLineBreak();
void onLink(String text);
void onMacro(String name, Map<String, String> parameters, String
content);
void onWord(String word);
void onSpace();
void onSpecialSymbol(SpecialSymbol symbol);
* Document: top level element for the AST representing a document in
memory. All elements below are Block(s)
* Macro: execution of MacroBlock(s)
int getPriority();
List<Block> execute(Map<String, String> parameters, String
content, final Document document)
throws MacroExecutionException;
* MacroFactory:
Macro getMacro(String macroName, Syntax syntax) throws
MacroNotFoundException;
* Transformation: ability to make transformation on the AST
int getPriority();
void transform(Document document, Syntax syntax) throws
TransformationException;
Here's some pseudo code that shows the whole process:
Parser parser = componentManager.lookup(Parser.ROLE, "xwiki/2.0");
Document document = parser.parse(sourceReader);
TransformationManager txManager =
componentManager.lookup(TransformationManager.ROLE);
txManager.performTransformations(document, new
Syntax(SyntaxType.XWIKI, "2.0"));
XHTMLRenderer renderer = new XHTMLRenderer(writer);
document.traverse(renderer);
Existing implementations:
=========================
* DefaultMacroFactory
* XHTMLMacro
* XHTMLRenderer (Renderer = Listener)
* XWikiSyntaxRenderer
* DefaultTransformationManager
* MacroTransformation (to execute Macros in the right priority)
* DoxiaConfluenceParser
* WikiModelXWikiParser
Next immediate steps:
=====================
* introduce cache component (in a separate module) for caching the AST
* add syntax metadata to current Document class
* Implement following macros:
- TOC Macro
- Include Macro
- Velocity Macro
- Groovy Macro
* Continue Doxia bridge
* Continue listener event implementation (there are some missing)
* Continue Confluence to XWiki conversion
Feedback most welcome.
Thanks
-Vincent