Hi Chris

> clean and strong boundaries between the tokenizer (which creates the AST)
and a renderer which traverses the AST?

Check. In TW5 there are "parser" modules that parse text to produce a parse
tree (aka AST), and then "widget" modules that know how to render each
parse tree token in the "widget tree" (this is a JS object tree that
closely matches the DOM tree).

The Markdown support works similarly. We integrate an existing parser (
https://github.com/evilstreak/markdown-js), and then massage the generated
parse tree into TW5's format (which is only ever so slightly different):

https://github.com/Jermolene/TiddlyWiki5/blob/master/plugins/tiddlywiki/markdown/wrapper.js

So, the architecture is absolutely there to parse TWC text into the
existing parse tree format, and then use the existing rendering mechanism.
(I think I mentioned before that at one point TW5 incorporated a
transliteration of the TWC parser, but at the time it was a nuisance to
maintain it).

> If you've got that then it would be possible to make a renderer which
takes a `text/x-tiddlywiki` AST which can then be used to either generate a
`text/vnd.tiddlywiki` AST _or_ `text/vnd.tiddlywiki` text.

As things stand, the first approach would be easier.

Best wishes

Jeremy




On Mon, Feb 24, 2014 at 4:22 PM, Chris Dent <[email protected]> wrote:

> Hadn't been aware of this thread so sorry for joining late. pmario pointed
> it out from another posting. This sounds like a very good line to pursue.
> It would certainly be very nice if TiddlyWiki5 could render 5 and classic.
>
> Doesn't the issue of "sub collections of rules" being weird resolve
> appropriately if there are clean and strong boundaries between the
> tokenizer (which creates the AST) and a renderer which traverses the AST?
>
> If we say a source text is `text/vnd.tiddlywiki` then it contains text
> which matches a grammar and creates tokens which are always the same: this
> is em-text, this is hyperlink. What can change is how the renderer chooses
> to generate text from the AST. We can declare a renderer which renders
> em-text but leaves hyperlink as the raw source.
>
> So the issue then becomes if you want to have `text/x-tiddlywiki` as well,
> then it needs a grammar and a tokenizer.
>
> If you've got that then it would be possible to make a renderer which
> takes a `text/x-tiddlywiki` AST which can then be used to either generate a
> `text/vnd.tiddlywiki` AST _or_ `text/vnd.tiddlywiki` text.
>
> I'm making this all sound more simple than it actually will be though.
> TiddlyWiki Classic text is notoriously difficult to get a nice tree out of.
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWikiDev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
>
> Visit this group at http://groups.google.com/group/tiddlywikidev.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Jeremy Ruston
mailto:[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to