[tw5] Tiddlywiki file suddently corrupted on save (commas missing in TW inner JSON file)

Hi all,

Today I opened my TW file to work on it, and it was blank. Last time I used it it was perfect.

I tried to import that broken file into a fresh empty TW: error message saying that the JSON file was broken, “missing , or ]”.

So I checked the file and I had approx 100 instances of “}{” instead of “},{”. Weird.

Fixed them all, then I could open the file again and retrieved my work. BUT… I added a new simple tiddler, and saved, and the file got broken again. Was back with my 100 “}{”.

Tried to import the fixed file into a fresh empty TW, and add a simple tiddler then saved: got a broken TW file with 100 “}{”.

Does anyone knows what is happening ?

Versions:

  • MacOS 11.6
  • Firefox 93.0
  • TW 5.2.0

Best,
Eric

Hi Eric,

Thanks for the detailed report. There is some conditional logic in the JSON tiddler output template to handle including a comma before every tiddler except the first. It seems that that logic has got corrupted, but it’s not immediately obvious how.

Are you using any TW plugins? Does the wiki include any JavaScript modules (ie tiddlers with type “application/javascript”)?

Best wishes

Jeremy

Hi Jeremy,

thanks for your answer it was very helpful !!

From your email I understood that my problem could come from a plugin or a javascript module.

I first tried to uninstall all the modules but that didn’t help. So I imported all my data (i.e. the tiddlers that I am the creator of) into a fresh empty TW, and I imported the plugins one by one. Doing so, I found the one that broke my TW. Following the instructions on tidtoc — an in-tiddler toc of headings

I’ve double checked, tried to import other modules, and my TW is working well, as long as I don’t import the two elements above.

But if this needs to be investigated further, I"ll be happy to help.

Best,
Eric

http://eucaly-tw5.tiddlyspot.com/ list matchfilter as Old Plugins (not recommanded). In a tab below is some explanation of changes in support of regexp.

Also, note that a core-defined “match” filter (with different usage semantics) was added in TW5.1.20 (Aug 09, 2019). When you import Eucaly’s old “match” filter definition, you override the core-defined filter definition. This overridden filter definition is then applied in any core wikitext code that uses match[...], which very likely caused the resulting error in the generated JSON output produced when you save the file.

It’s probably the “match” filter operator that causes the problems. TW implemented it’s own “match” with V5.1.20 and the old plugin probably overwrites it.

IMO you are lucky, that it didn’t “brick” the whole system. …

The “match” operator is used by the $:/core/templates/store.area.template.html which is responsible to save the tiddler store. … Just a guess, but there may be the problem. …

-mario

Thanks Mario, I understand better why it wasn’t working.

And indeed, I am very happy I could save my data !!

FYI, in order to fix my issue, i.e. to overcome the TW’s “match” vs Eucaly’s “match” name conflit mentioned by Mario, here is what it did.

Might be useful to anyone willing a have a table of content per tiddler

1/ create a new tiddler called $:/core/modules/filters/matcheucaly.js
2/ set type as application/javascript, and field module-type as filteroperator
3/ copy paste everything from Eucaly's Tiddly World — – powered by TiddlyWiki (v5.1.0) 's $:/core/modules/filters/match.js tiddler into the above tiddler

4/ replace exports.match = … by exports.matcheucaly = …

5/ import toc tiddler from tidtoc — an in-tiddler toc of headings
6/ replace match by matcheucaly in the imported toc tiddler

7/ save, restart
8/ and tada! The TOC per tiddler by Tobias Beer is working again :slight_smile:

Thanks for all the help,
Eric

1 Like