First version of Markdown export plugin

@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?

Can this export from TiddlyWiki5 server version?

GitHub - oeyoews/tiddlywiki-markdown-importer-cli: tiddlywiki importer/exporter with markdown This repository may be what you want.

You mean something like this?

I just want to say that I really appreciate the Markdown export plugin. It (combined with good old Pandoc) has been much better for sharing individual tiddlers than the static HTML export.

Michael,

Thanks for reawakening this thread, This related thread was raised TW text formatting for common social media. How? - #5 by TW_Tones

This solution by @cdaven does this conversion from the rendered HTML version that may be fed into Pandoc. However it takes the extra step and converts this to Markdown which is also a Pandoc format available for conversion.

I also made a copy html to clipboard in the past.

The advantages of markdown export includes;

  • It is the method used here in talk.tiddlywiki
  • It is more common than tiddlywiki script (I would like to change this)

However in retrospect I would ask if @cdaven could consider one simple addition to his plugin and that is to provide an additional button, on tiddlers, that copies the markdown format, it currently generates to the clipboard (rather than export). This would allow;

  • Quick per tiddler conversions without needing to access the file system
  • Ease of conversion, then save in a Markdown tiddler in the same or other wiki (using the markdown plugin).
  • Make use of for publishing etc…

@cdaven I just noticed this plugin is hosted on TiddlyWiki version 5.2.3 and unfortunately this includes the bug that can stop the plugin been dragged and dropped, from Chrome to Firefox and possible elsewhere. If it could be updated to a 5.x would help people acquire you plugin more easily.

Hi @cdaven , your plugin is great! Thank you!

I notice some strange substitutions with katex, i export this code to markdown:

<$latex text="
\begin{aligned}
&h > 2 \times C \rightarrow \text{Sapata muito rígida ou bloco}\\ 
\frac{2}{3} \times C \le &h \le 2 \times C \rightarrow \text{Sapata rígida}\\ 
\frac{C}{2} \le &h < \frac{2}{3} \times C \rightarrow \text{Sapata semi-rígida}\\ 
&h < \frac{C}{2} \rightarrow \text{Sapata flexível} 
\end{aligned}">
</$latex>

And get this result:

$
\begin{aligned}
&amp;h &gt; 2 \times C \rightarrow \text{Sapata muito rígida ou bloco}\\ 
\frac{2}{3} \times C \le &amp;h \le 2 \times C \rightarrow \text{Sapata rígida}\\ 
\frac{C}{2} \le &amp;h &lt; \frac{2}{3} \times C \rightarrow \text{Sapata semi-rígida}\\ 
&amp;h &lt; \frac{C}{2} \rightarrow \text{Sapata flexível} 
\end{aligned}$

I notice the symbols < or > are substituted by &lt and &lt, i can change this using the correct code in latex \lt or \gt, but the symbol & is needed to align the equation, so maybe the & symbol don’t need to be substituted or parsed (i dont know what i talking about :sweat_smile:)

Second, i think the <$latex text=" needed to be show as:

$$
\begin{aligned}
&amp;h \gt 2 \times C \rightarrow \text{Sapata muito rígida ou bloco}\\ 
\frac{2}{3} \times C \le &amp;h \le 2 \times C \rightarrow \text{Sapata rígida}\\ 
\frac{C}{2} \le &amp;h \lt \frac{2}{3} \times C \rightarrow \text{Sapata semi-rígida}\\ 
&amp;h \lt \frac{C}{2} \rightarrow \text{Sapata flexível} 
\end{aligned}
$$
1 Like

Look at my answer at the Willing to export "Tiddlers" into a web site template engine like Grav - #6 by Offray thread. I’m using my own Brea instead of Jekill for static site publishing, but the part I’m talking about regarding using, in the future, TW on Bun, takes inspiration of @cdaven’s work to smooth the publication workflow.

1 Like