Button that converts markdown to wikitext#9462
Conversation
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Confirmed: linonetwo has already signed the Contributor License Agreement (see contributing.md) |
📊 Build Size Comparison:
|
| Branch | Size |
|---|---|
| Base (master) | 2447.2 KB |
| PR | 2449.2 KB |
Diff: ⬆️ Increase: +2.0 KB
✅ Change Note Status
All change notes are properly formatted and validated!
📝 $:/changenotes/5.5.0/#9462
Type: feature | Category: widget
Release: 5.5.0
Add button and import option to convert Markdown tiddlers to WikiText
🔗 #9462
👥 Contributors: linonetwo
📖 Change Note Guidelines
Change notes help track and communicate changes effectively. See the full documentation for details.
There was a problem hiding this comment.
Pull request overview
This PR adds markdown-to-wikitext conversion functionality to the wikitext-serialize plugin, implementing a comprehensive system for converting markdown content to TiddlyWiki wikitext format. The conversion is available through multiple interfaces including a JavaScript API, toolbar button, and import dialog option.
Key changes include:
- Core markdown-to-wikiast conversion engine with modular handler architecture
- Support for common markdown elements (headings, formatting, lists, links, images, tables, code blocks, blockquotes)
- UI components for manual and automatic conversion
- Comprehensive test suite with multiple test cases
- Enhanced quoteblock serialization for nested quotes
Reviewed changes
Copilot reviewed 52 out of 53 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/tiddlywiki/wikitext-serialize/markdown/mdast-to-wikiast.js | Main conversion engine implementing markdown-it tokens to wikitext AST transformation |
| plugins/tiddlywiki/wikitext-serialize/markdown/mdast-to-wikiast/*.js | Individual handlers for each markdown element type (headings, lists, links, etc.) |
| plugins/tiddlywiki/wikitext-serialize/markdown/action-convert-markdown.js | Action widget for manual markdown conversion via toolbar button |
| plugins/tiddlywiki/wikitext-serialize/markdown/convert-markdown-on-import.js | Hook for automatic markdown conversion during import |
| plugins/tiddlywiki/wikitext-serialize/markdown/ui/*.tid | UI components for toolbar button and import options |
| plugins/tiddlywiki/wikitext-serialize/rules/quoteblock.js | Enhanced quoteblock serializer with nested quote support |
| plugins/tiddlywiki/wikitext-serialize/rules/parameters.js | Defensive check for orderedAttributes |
| plugins/tiddlywiki/wikitext-serialize/rules/html.js | Defensive check for orderedAttributes |
| editions/test/tiddlers/tests/data/markdown-to-wikitext/*.tid | Test cases for markdown conversion |
| editions/test/tiddlers/tests/test-markdown-to-wikitext.js | Test runner for markdown conversion |
| core/ui/ViewTemplate/title.tid | Conditional rendering support for toolbar buttons |
| core/ui/ImportListing.tid | Import options rendering in import dialog |
Comments suppressed due to low confidence (5)
plugins/tiddlywiki/wikitext-serialize/markdown/mdast-to-wikiast/text.js:1
- The handler assumes token.content exists, but text tokens from markdown-it may have token.value instead of token.content depending on the token type. This should check both properties or validate the token structure.
plugins/tiddlywiki/wikitext-serialize/markdown/mdast-to-wikiast/table.js:1 - The alignment parsing logic is duplicated in both th_open and td_open handlers. Extract this to a shared helper function to improve maintainability.
plugins/tiddlywiki/wikitext-serialize/markdown/mdast-to-wikiast/table.js:1 - The alignment parsing logic is duplicated in both th_open and td_open handlers. Extract this to a shared helper function to improve maintainability.
plugins/tiddlywiki/wikitext-serialize/rules/quoteblock.js:1 - The deeply nested property access makes this line difficult to read and maintain. Consider using optional chaining (tree.attributes?.class?.value) or breaking into multiple lines with intermediate variables.
plugins/tiddlywiki/wikitext-serialize/markdown/mdast-to-wikiast/heading.js:1 - The variable 'level' is computed but never used. Either remove this line or add a comment explaining why it's extracted but not utilized.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 53 out of 54 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,88 @@ | |||
| /*\ | |||
| title: $:/plugins/tiddlywiki/wikitext-serialize/markdown/action-convert-markdown.js | |||
There was a problem hiding this comment.
I think converting markdown to tw wikitext should be in another plugin. Wikitext serialize should only provide APIs.
There was a problem hiding this comment.
@Jermolene said in #9415 that I can put them together, see if he will change his mind when he see change set is so large.
There was a problem hiding this comment.
@Jermolene Code is bloating, and it includes a new button in UI, so maybe not suitable in wikitext-serialize plugin, how about put them into markdown plugin? Or just a standalone plugin, as user is intended not using markdown feature.
Thanks @linonetwo, I think it's pretty good – all great artists copy. |
IMO the icon indicates a conversion in 2 directions according to the arrow heads. - Is this intended or should it be 2 icons with a arrow in 1 direction. I could create the SVGs if you want. |
@pmario you are right, please help if you could. One directional icon will also make M↓ icon larger, easier to read. And bi-directional conversion is totally possible, but I don't want to impl that right now because we still regarding wikitext as the basic of tiddlywiki. Even add this feature, I will make 2 separate icons so user could hide one of them from toolbar. |
|
I like that, also making it top-bottom which is more friendly to i18n (some languages are read right-to-left). I would suggest having Motovun Jack/his head (like the TiddlyDesktop logo), instead of |
I do like it.
I think that will be too close to the GitHub logo, if it is so little. IMO "Ti" is good. I did experiment a bit, but I did not really like too much. |
|
I did a bit of experimenting myself - just with simple Inkscape clipping.
SVG: The SVG is definitely not integration-appropriate, it is just a visual proof of concept. If you choose to follow this path, it's important that the head does not touch the edge (would look out of place versus other buttons), so we cannot use Jack's full body. |
|
Thanks @linonetwo. Having Jack in the icon would have been nice, but it does not look practical. I’d suggest “TW” instead of “Ti” because that is already established as a 2-letter abbreviation for TiddlyWiki. |
@superuser-does That looks like Jim Carrey "The Mask" instead, haha |
Perhaps it could be simplified very slightly by making the TW box also be white on black, avoiding the borders |
|
Not bad, and IMO you can go either way with it (solid or blank background). I would comment that the typeface for TW strikes me as incogruent with the rest of TW's style. I don't have the ability to execute this but I would suggest these ways to refine it further:
For the second part, you can type it out in Inkscape and then click Path > Object to Path. This would probably bloat the SVG in other ways (even when storing as Plain SVG) so I will leave it to the experts here on how to get the size down. It's worth consider if the arrow's wings could be restored, by thinning the stroke. This could be looked at last, after all changes to the two logos have been made. These are small tweaks though and I think you have landed on a sensible button to represent it! |
|
@superuser-does It is not font, SVG icon usually don't depend on font. It is draw point by point, very difficult, so usually I just use icon from https://morosanuae.github.io/tw-icons/ |
Yes. My suggestion was to enter it in text in an SVG editor like Inkscape with that font installed & set. Then use the Object to Path tool, which will convert your text object to SVG paths, based on the currently loaded font. |
|
I had a bit of free time and did the steps I discussed above to put both Changes:
Here is the button as I did in Inkscape with a bit of boilerplate removed (and paths converted): I then got Gemini Pro 3.1 to bake it into the path, so it looks like a cutout - cutting down on code while also making it more TW-appropriate: Caveats:
Finally, here is this turned into a TID file: All these steps involved some manual edits, including some helpful ID names. This is how it looks in context: And up close: I hope this is okay to integrate, bearing the caveat above in mind. |
|
Thank you, I've updated it.
|











Demo: https://deploy-preview-9462--tiddlywiki-previews.netlify.app/
before merge, revert change in
editions/tw5.com/tiddlywiki.infonew action widget that handles children action widget for notification
handle multiple import options
editor buttons
closes #9415 and deprecates https://github.com/tiddly-gittly/md-to-tid