MarkDown via formatter / tag / field

52 views
Skip to first unread message

Tobias Beer

unread,
Oct 16, 2011, 5:45:06 PM10/16/11
to TiddlyWikiDev
Hi everyone,

especially those of you literate in the core and the text rendering
process. Sewpafly was asking [1] for an extension to ShowDown [2].

Right now my knowledge of the core unfortunately has diminished to a
degree where it would require quite some reverse engineering to
conceive of the least demanding way to implement either of...
1) a server.content-type field
2) a special markdown tag

...to trigger MarkDown rendering using ShowDown. Currently the plugin
renders showdown via pre and postfixes like so...

§§§
Some MarkDown...
§§§

Once I would have an idea to implement any of 1) or 2) above, the
other should be fairly straight forward to implement as well. Anyone
with an idea to extend the solution, please make yourself known.

Also, would a server.content-type meaningfully be specified as "text/
markdown"?!?

Cheers, Tobias.

[1] http://groups.google.com/group/tiddlywiki/browse_frm/thread/35486a62617423a8
[2] http://showdown.tiddlyspace.com/#ShowDown

PMario

unread,
Oct 17, 2011, 11:41:38 AM10/17/11
to TiddlyWikiDev
Hi Tobias,
Thx for starting the topic.

>Also, would a server.content-type meaningfully be specified as "text/
>markdown"?!?
IMO it needs to be "text/x-markdown" [1]

FND is using this type allready at his playground [2] for tweeting.
See the random number titles "field". TiddlySpace server uses this
type to create a rendered HTML version. The whole stuff seems to be an
"unpromoted feature". ...

BinaryTiddlersPlugin.js [3] contains some stuff, that renders
"server.content-type" in a "special way". Especially the
"isTextual" [4] function imo needs some refactoring. (more on this
later *)

BinaryTiddlersPlugin.js can give you a hint, how you could handle
markdown. But all of this stuff seems to be rather hacky, to me.
That's why I suggested to start a topic, here in dev group.

There should be a solution, that can deal with hopefully "all" content-
types.
=====
*)
isTextual() [4] checks, if a content-type starts with "text/" and some
other textual indicators, and renders the stuff inside an HTML <pre>
element. Which is quite nice for TS because you don't need to deal
with {{{...}}} inside the tiddler. But it introduces some
inconsistencies too.

The problem I focused is:
"text/x-tiddlywiki" is textual, but should _not_ be covered inside a
<pre> element. It needs to be rendered, since it is TiddlyWiki markup.
"text/x-markdown" is textual as well. But if a plugin is available, it
should be rendered as markdown html. -> Same problem.
=====

I use some bits of BinaryTiddlersPlugin with my CodeMirror [5] stuff.
But since it interferes with "server.content-type" I used a field
"content-type". Having two content-types, turns out to be quite
usefull. Even if it may be wrong. (That should be an other topic)

Handling "server.content-type" and or "content-type" propperly faces
some more problems:

a) BinaryTiddlersPlugin needs to check for tag: systemConfig [7] and
isLink()
b) I need to check if a tiddler contains "{{{" or "<code" [6].
Because if so, it needs special handling as well.

Problems a) and b) point out, that this mechanism, needs some
rethinking at all, because too many edge cases have to be checked.

=============
@FND and other devs.
what do you think?

-m

[1] http://en.wikipedia.org/wiki/Internet_media_type#Type_x
[2] http://fnd.tiddlyspace.com/
[3] https://github.com/tiddlyweb/tiddlywebwikiclient/blob/master/BinaryTiddlersPlugin.js
[4] https://github.com/tiddlyweb/tiddlywebwikiclient/blob/master/BinaryTiddlersPlugin.js#L31
[5] https://github.com/pmario/tw.CodeMirrorPlugin/blob/master/plugins/zCodeMirror2Plugin.js#L516
[6] https://github.com/pmario/tw.CodeMirrorPlugin/blob/master/plugins/zCodeMirror2Plugin.js#L542
[7] https://github.com/tiddlyweb/tiddlywebwikiclient/blob/master/BinaryTiddlersPlugin.js#L62

Tobias Beer

unread,
Oct 17, 2011, 1:42:21 PM10/17/11
to TiddlyWikiDev
PMario,

Thanks for sharing your insights on content-types. It seems, using a
server.content-type field does require a lot more focus on details and
dependencies than I thought and perhaps requires a general agreement
on how to proceed in this area in the context of plugins.

As for sewpafly's request, would you know of a rather quick solution
to trigger MarkDown rendering of the whole tiddler body triggered by
the presence of some MarkDownTag using ShowDown.js? Where would I have
to interrupt TiddlyWiki text rendering and pass it down to ShowDown?

I guess, I should just take an empty core and retrace the code all the
way from the view makro. ;-)

Cheers, Tobias.

PMario

unread,
Oct 17, 2011, 2:51:43 PM10/17/11
to TiddlyWikiDev
If you want to go for a hijack, I'd suggest you have a closer view
at
https://github.com/pmario/tw.CodeMirrorPlugin/blob/master/plugins/zCodeMirror2Plugin.js#L515

down to line 552
-m

Tobias Beer

unread,
Oct 18, 2011, 5:25:17 PM10/18/11
to TiddlyWikiDev
Thanks Mario,

much appreciated.
On my todo list now.

Cheers, Tobias.
Reply all
Reply to author
Forward
0 new messages