TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.98k stars 1.18k forks source link

Improve TWC upgrade button #1114

Open tobibeer opened 9 years ago

tobibeer commented 9 years ago

Background: Viewing a tiddler of type "text/x-tiddlywiki" (ie TiddlyWiki Classic format) offers a button labelled "upgrade" that if clicked just changes the type of the tiddler to "text/vnd.tiddlywiki" (ie TiddlyWiki5 format).


This was about to start as a request for the upgrade button to account for the new linebreak handling, which is very different from TWc where literal linebreaks are treated as such. Turns out this can't quite be separated from the overall upgrade process.

Anyhow, to account for old linebreaks, perhaps <br> need to be introduced for every hard linebreak \n that is not preceded by any of...

...and followed by a non-block-producing set of characters.

Starting a newline, block producing characters in TWc are...

Plenty cases are definitely non-trivial and need to be skipped or processed differently...

I just discovered that button as I tried to imported Mario's hangout notes into a TW5... the result of which is a lot of non-existend linebreaks. #1110 1110

Jermolene commented 9 years ago

I'm open to making improvements to the functionality of the TWC upgrade button. The tricky bit, as you've spotted, is figuring out a safe, useful set of rules for the upgrade.

tobibeer commented 9 years ago

figuring out a safe, useful set of rules for the upgrade

indeed ...I guess, it really asks for a bit of a pseudo-tw2-parser of some sorts, urgh :)

maybe, there are some (more) catchy quick wins after all...

Jermolene commented 9 years ago

I guess, it really asks for a bit of a pseudo-tw2-parser of some sorts, urgh :)

Yes, and of course we've already got a real tw2parser plugin.

I still think that a simple heuristic based on doubling up every line break is a reasonable starting point for the "upgrade" button.

tobibeer commented 9 years ago

I still think that a simple heuristic based on doubling up every line break is a reasonable starting point for the "upgrade" button.

I think not, because there are too many exceptions to that rule. However, once a workable matching pattern is figured out, better do...

"""
hard
line
breaks
"""

...which will also teach users that that actually exists.