How to parse a field line of text from a .tid file?

I will elaborate my question with an example.

Quote from https://tiddlywiki.com/#TiddlerFiles:

These files consist of a sequence of lines containing name:value pairs, a blank line and then the text of the tiddler. For example:

title: MyTiddler
modifier: Jeremy

This is the text of my tiddler.

This shows that characters : and <Space> have a special, delimiting meaning.

I opened a single HTML file wiki in browser and created a custom field with name my:field: name: and value my:field: value:. TiddlyWiki allowed me to create such a field and save the tiddler. Then I exported the tiddler in .tid format. The field line in the exported file looks like

my:field: name: my:field: value:

If I’d have such a string outside of the context provided above, how to parse it into a name:value pair?

testing this with my node setup, this is a case where it gets saved as a json rather than tid format, precisely (at least I assume) because the field name isn’t compatible with the simpler structure of the .tid format

$ cat tiddlers/blah.json 
[
    {
        "created": "20250927145514677",
        "text": "",
        "tags": "",
        "title": "blah",
        "modified": "20250927145620948",
        "type": "text/vnd.tiddlywiki",
        "my:field: name:": "my:field: value:"
    }
]

Exporting from the browser to .tid format, that field is a little different to me than your example - note the double colon after “name”

my:field: name:: my:field: value:

Since in practice this is a case where the tid format breaks down, I’d argue that TW should either disallow export to that format in this instance, or at least warn that the exported tid will not be imported reliably. (for my taste, I’d in fact argue that “colon-space” should simply not be allowed in field names, but for the sake of compatibility, that ship has long sailed)

Back to testing - importing that tid file, I see this - the name/value split is made on the first colon-space found in the file:

2025-09-28T01:02:39_7309c850

This is a known bug: [BUG] Tiddlers with multi-line fields can be incorrectly exported as .tid files · Issue #5809 · TiddlyWiki/TiddlyWiki5 · GitHub

1 Like

Doesn’t multiline imply the presence of \n in strings? In my example that’s not happening. Yet it’s another edge case. The problem is indeed, as @nemo pointed, that neither :, <Space>, :<Space can be used as patterns to decide on the name:value parts of a line, as long as the characters mentioned above are allowed to be freely used.

JSON has no such problems, because strings are quoted there.

Perhaps it would be possible to borrow the trick from there and use quoted strings when needed to deal with such ambiguity, as in "name": "value"? Or would this introduce other problems? Is it common to have " in field names/values, for fields other than text?

This is how we check if a tiddler cannot be saved as a tid file under node.js:

1 Like