If this can be done it would be a huge benefit, and I'd like to help out in any way I can. However, please don't commit any code to trunk for this one yet unless it is completely isolated from existing Wiki code. The 0.6.0 release has already dragged on for a long time, and ripping out the parser at this point would push the release out even further. I suspect that this is obvious, especially since you've already created a separate branch, but I wanted to make sure. -- Ryan 26-Jul-2007 11:55 PDT
Moved from the Feedback page:
I play a bit with your Jamwiki parser. (See Image:wikiparser.tar.gz) It might match some of your ideas behind "Non-embedded parser" in your TODO list.
Important thing: My goal was to make the parser small(!) so:
The usage might be something like :
import org.jamwiki.parser.ParserDocument; import org.jamwiki.parser.ParserInput; import org.jamwiki.parser.jflex.JFlexParser;
public static void main(String[] args) {
String text = ">>> the text to parse <<<";
ParserInput pi = new ParserInput();
pi.setLocale(new Locale("de"));
ParserDocument pd = new ParserDocument();
JFlexParser p = new JFlexParser(pi);
try { pd = p.parseHTML(text); } catch (Exception e) {}
String output = pd.getContent();
}
So, is it useful for you? Do you have any comments? (my work is still not finished)
Bost
PS: From time to time I code something for an open source search machine www.yacy.net We have a little wiki system and we're looking for a better wiki than the actual (and MediaWiki compatible). That's why I played with your code...
Copied from Tech:Parser integration:
To use the parser in a more flexible way I suggest to modifie the way the datahandler is used. By still using the DataHandler Interface but passing an instance to the ParserInput. In this way I was successful in using the parser in our project for different settings and with dynamic URL's and even dynamic image url's. After the modification there was no more need for the WikiBase singleton through the different places in the code as the code used at runtime the datahandler instance.
-- 130.60.112.109 28-Jul-2007 11:26 PDT
Copied from the Feedback page:
Hi, thanks for the great project! I was tring to use the parser stuff with the html rendering engine in an other project. But I failed as the configuration is made singleton style by calling the WikiBase.getDataHandler() stuff. This works nice if you just use one parser per VM but in my case where we have completely dynamic URL's as we use a component framework and even image URL's are on a per user base for security reasons. It would be nice to have either a possibility to configure each parser instance by setting the stuff above with the ParserInput object or a hook for image and dynamic url's.
At least I think it would be very important for the bliki project which should be usable for external frameworks as well.
Thanks for an answer and keep going the good work!
guido
Actually, I'm not so sure it is useful to isolate the parser. What people really want is to gain access to the JamWiki API in order to develop extensions/plugins.
At this point, I think we need a separate API, but for the whole Jamwiki engine, not only the parser.
The org.jamwiki.parser package contains the interfaces and objects necessary to implement ANY parser for JAMWiki. The two currently implemented parsers are:
org.jamwiki.parser.jflexorg.jamwiki.parser.blikiIn my view the steps needed to achieve "parser isolation" would be to first make the org.jamwiki.parser.jflex its own project which could be distributed as a separate JAR. Initially this would offer little or no advantage aside from splitting the code out. The second step would be to begin simplifying and eliminating dependencies of this parser project from the rest of the JAMWiki code base. I'm not sure that this could ever be done completely - templates will always need some way to look up their code, for example - but I do think it might be possible to limit those dependencies by modifying the org.jamwiki.parser code to pass as much as possible along to the actual parser implementations.
org.jamwiki.parser.jflex is its own project (jamwiki-parser-jflex)org.jamwiki.parser.bliki depends on org.jamwiki.parser.jflex. I thought there was two independant implementations (of course, I could make biliki depend on parser-jflex, but that does not male sense. I'm proabably missing something here.jamwiki-core which holds all the code (except the servlets that remain in jamwiki). The simple reason is that a project cannot depend on a war, it can only use a jar.jamwiki contains only servlets and a dependency to jamwiki-corejamwiki-parser-api project, that contains the full API of the parser. Each parser should depend and implement this jamwiki-parser-api. Also, the jamwiki-core will depend on jamwiki-parser-api. To do this, a couple of interfaces will proabbly need to be extracted from the classes of jamwiki-core.I may not be fully understanding the end goal, so let me know if I'm on the wrong track or not making sense - I hit my head a lot as a kid, so I get confused frequently :-P -- Ryan 30-Jul-2007 21:15 PDT