[Jamwiki-devel] Custom Tag discussion
Brought to you by:
wrh2
From: <jam...@li...> - 2012-01-20 16:03:03
|
Wow! Quick and very good job. Sorry I didn't get any mail from the mailing list :-/ Otherwise I would respond sooner. So this is my few comments as you requested. First of all you are correct this implementation is good enough to provide everything I am looking for now. However by doing some thing slightly different you can make feature even more flexible and powerful. In general I prefer to avoid hardcoded string. In this case "<__NOPARSE>". Another solution would eliminate need to alter step 1. Also no hardcoded tag would free it to be used in other places and minimize the confusion around the tag which MUST NOT BE USED! The error message would be something like "The tag <__NOPARSE> has no real usage in the Wiki text, but can not be used for any purpose anyway". Parser should remove the Custom Tag and replace it (tag and content) with text, returned from the method call. I don't know JFlex enough to say how difficult it would be, but if you can include Custom Tag parsing in all steps (every time calling different method) the system would be most flexible. Template parsing would allow to define new syntax for templates. Same true for metadata parsing and to HTML conversion. The Custom Tag class should be able to insert the same custom tag in its output. To allow this the call to the parse...() methods should include additional parameter for the tag name. Default implementation (which can be used to override just 1 of these methods) would echo into output the input text included into custom tag. Only parse2Html(...) will include text without tag. A bit faster implementation of this base class would return empty strings. In this case the default behavior would make parser to skip custom tags in later steps, and would require developer to override all methods up to one s/he actually needs. So my proposed methods would be like: public class CustomTagBase { public String parseTemplate(String tag, String text) { return keepTag(tag, text);} public String parseMetadata(String tag, String text) { return keepTag(tag, text);} public String parse2Html(String tag, String text) { return text;} protected final String keepTag(String tag, String text) { return "<"+tag+">"+text+"</"+tag+">";} } Can this be done in time for v.1.2? This would be great. I can send to you the default implementation of the Custom Tag implementing class. Also I am working on some useful implementations for this feature. Sent from my iPad |