Yesterday I decided to try something that's been batted around for a
while[1]: Using node.js[2], jsdom[3] and the TiddlyWiki core
JavaScript[4] to create a formatter/wikifier for TiddlyWiki wikitext,
without a browser.
I got the basics working fairly quickly (one afternoon). It was both
far easier and far harder than I expected, for reasons introduced
below.
The code can be found on github:
https://github.com/cdent/twikifier
All it does right now is assemble enough Javascript into a single file
that can be run by node to take a static string and turn it into HTML.
I very much welcome comments and contributions. If you want to make
some changes, please fork it and make pull requests.
Take Note, this is not for the faint of heart and the thing you get
when you've made it work is not (yet) useful for anything.
The README.md in the repo explains some of the issues I discovered in
the processing, but here are some additional notes:
What made it fast to get rolling? node.js and it's package manager, npm,
made getting the CommonJS requirements dead simple. jsdom and jquery are
packaged for node. Since TiddlyWiki's wikifier builds dom elements on
the fly, in a provided place, it is necessary to provide a working
Document to the wikifier. The node side of that stuff was painless,
and it should be for other people, as long as they are in a POSIX
(Unix, Linux, Mac) environment.
The slower going parts were working out the parts of TiddlyWiki that
were required, their dependencies, and their entry points. An
important goal I set for myself was to just use TiddlyWiki code, not
duplicate it. twikifier is made by assembling the pieces of the core.
First I had to work out where to enter the system (the wikify method
from Wikifier.js) and then work out its parameters, and then each of
the other files that were need to make things run. This was _hard_
because there are lots and lots of globals, some that cause runtime
only problems. Some of this complexity is described in the README.
The next step would be to create some tests for each of the default
macros. It is very likely most of these won't work as they need access
to the store, so a possible step following would be to create code that
interacts with a bag or recipe in a TiddlyWeb store as if it were a
TiddlyWiki.
I'm not sure where this work is going to go, but I believe that it
could, with effort, result in a nice alternative HTML generator for
TiddlyWeb while at the same time helping to improve the
maintainability and reusability of the TiddlyWiki code.
[1] It's been discussed that server-side creation of HTML, in
Tiddly{Web,Space} could be improved by directly using the existing
TiddlyWiki wikifier.
[2] http://nodejs.org/
[3] https://github.com/tmpvar/jsdom
[4] http://svn.tiddlywiki.org/Trunk/core/js/
--
Chris Dent http://burningchrome.com/
[...]
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywikidev?hl=en.