First version of Markdown export plugin

Hello,

I have just finished my first plugin, which lets you export tiddlers to Markdown: cdaven's TiddlyWiki Demo

Let me know if there are any problems or suggestions for improvements.

17 Likes

Nicely done, I quite like that the tiddler fields are included in the front matter in the Markdown file.

1 Like

Hello cdaven,

A nice and useful plugin for interoperability with other tools and sharing content.

Do you have any reverse workflow: a way to import a (pandoc) markdown document inside TiddlyWiki in native TiddlyWiki5 format (not a markdown tiddler)?
I would be interested to have this capability inside TiddlyWiki or by using Pandoc.

As a side note perhaps you can mention in your " Wait, which Markdown?" section that you can also convert the generated pandoc markdown file to CommonMark or Github flavored markdown with pandoc.

Kind regards,

Eskha

No, I haven’t looked at that. I imported my Markdown documents as Markdown tiddlers, and am manually converting them occasionally. It would be nice to convert them automatically, all at once, but I don’t know where I would start developing such a plugin.

Yes, thank you. I will do that.

Starting off with a BANG! I have been looking for something like this, without exaggeration, for YEARS.

This is IMO where TW adoption really takes off. I am finding TW perfect for creating and editing posts which can, now very easily with this plugin, be exported in formats compatible with template languages like liquid or nunjucks - which are used by a lot of people.

Thank you so much for this contribution. I hope it gets the attention it deserves this is a very powerful tool.

1 Like

Very interesting, did you implement a mdast-util-from-wikiast?

I have a https://github.com/tiddly-gittly/md-to-tid that implements mdast-util-to-wikitext, and makes MD to Tid Wikitext possible. And there is a markdown-transformer in CPL.

Would you mind making a JSON release in your github release, and join the CPL?

1 Like

Yes, I have seen this request many times, which is why I was so shocked how easy it was to implement. It’s almost like the people who knew how to do this didn’t want it done… :scream:

I let TiddlyWiki parse and render everything into a “render tree”, which is more or less a DOM tree. So in practice, I’m generating Markdown from HTML, not from WikiText. This way, most custom widgets and macros should work without any customization from me.

I don’t know what that means, but I will publish the source code to GitHub soon.

1 Like

@cdaven Hi, I just hope you can publish a JSON plugin to the release like Release v0.3.0 · tiddly-gittly/slate-write · GitHub and the name of json should be constant, so we can use same URL to get latest plugin everytime you have an update.

You can try automate this process using https://github.com/tiddly-gittly/TiddlyWiki-TS-Plugin-Template

Well… we have plenty of plugin to write… for me, after my md-to-tid, I start writing WYSIWYG editor.

1 Like

It is far more likely that it has never been of particular interest to anyone that might be equipped to do so, and there hasn’t been much interest from the wider community either when the opportunity has presented itself.

When I posted the first demo of my typewriter plugin a couple of years ago I offered to create a Markdown converter if there was interest, since there was considerable overlap, but there were no takers.

Similarly @fastfreddy has a Markdown converter in his Streams-Fusion plugin but I haven’t seen any particular community interested expressed in having that as a standalone component either.

The only reasonable option for me now is to remove the markdown bits from Streams-fusion and use this awesome plugin for it instead. I’ll work on a routine to detect the presence of this plugin and adjust my export options accordingly.

This is incredible. Thank you!

How difficult would it be to make it work with “export all”, or the “Export tiddlers” with “filter” tab in AdvancedSearch ([tw] Exporting a list of tiddlers)?

It already works, but you get everything in one massive Markdown file with no delimiters.

Let me know if you have suggestions for how this can be improved.

Neither work for me! Exporting individual tiddlers to markdown work, but not “export all” or through the “filter” tab. Both download a “tiddlers.md” with no content. The same holds whether exported from a Tiddlywiki hosted on Tiddlyhost or stored locally. I am working on Windows, and Firefox. Thank you in advance! J

Please, go here and create a bug report: Issues · cdaven/tiddlywiki-stuff · GitHub

Open the browser’s developer console ( Control+Shift+J or Command+Option+J) and copy any messages written there during the export to the issue.

FYI, @anthrospeak’s issue seems to have been resolved in the update that I released last night.

I also did two additions:

  1. Just below the front matter in the Markdown, a note that says <!-- Exported from TiddlyWiki at 08:17, 3rd June 2022 --> is inserted. (HTML comments are ignored by Markdown parsers.) This note can be customized by editing the tiddler $:/plugins/cdaven/markdown-export/exportNote.
  2. When exporting multiple tiddlers, they are now separated by a \newpage LaTeX-style page-break. Pandoc will insert a real page-break there when exporting to Word or PDF.

Unfortunately, every tiddler still gets its own front matter section, which is not supported by Markdown or Pandoc. I see two different use cases, with different solutions:

  1. Either you export many tiddlers to the same Markdown file, and then split them at the \newpage marker into multiple files. In this case, you want front matter in every tiddler.
  2. You export many tiddlers to the same Markdown file, and want to keep it that way. Maybe export to PDF or print. In this case, you don’t want the front matter, since there can only be one per file.

I’m not sure how to handle this with settings or arguments to the macro, since you may want to do it differently every time. Any suggestions?

1 Like

Could this be combined with static publishing?

I am just starting to go down the route of figuring out how to change the HTML static publishing to output Markdown instead.

Is this something you’ve considered for the plugin?

My use case is use TW as my “CMS” and then combining it with my existing Jekyll blog archive to publish one site.

If you have version 0.3.0, you can do this:

tiddlywiki <folder> --render <tiddler> '[encodeuricomponent[]addsuffix[.md]]' 'text/plain' '$:/plugins/cdaven/markdown-export/md-tiddler'

See the documentation for --render here: https://tiddlywiki.com/#RenderCommand

3 Likes

I only just realised that this export tool exports standard wikitext to Markdown, and uses the pandoc markdown standard. So theoretically we can make use of the “Pandoc a universal document converter” from and to many formats.

I still think if someone in the know could initiate a project to add to/from tiddlywiki to the converters for Wiki markup formats would be great, though when using widgets we may need to use the rendered html5.

1 Like

@cdaven
Can there be an additional option like a Realtime Markdown Convertor tiddler

  1. At the top of this convertor tiddler, there shall be a tiddler selector with search box (where we can type the tiddler name) or select widget option to select the tiddler converted to be markdown.
  2. Once the tiddler is selected, a side by side editor opens up below the selector showing the wikitext format on the left side and markdown format on the right side.
  3. At the bottom, there shall be a export as md or copy to clipboard buttons.

Is it doable?