Is TiddlyWiki written in itself?

Theoretically yes … The problem with “in theory” is, that it always works “in theory”, but in praxis it does not. … As so often the devil is in the details. Having one sentence of specification is a bit “sparse”

But

The TW data model is simple. It basically is a JSON structure, which is wrapped in an HTML <script> tag, that is embedded into an HTML file, which contains the TW core-code and core-UI.

If you

  1. open https://tiddlywiki.com/empty.html
  2. create a tiddler
    • named eg: my-new-tiddler
    • tagged: tag-1
    • field named: field-1 value: value-1
    • text

      some text
      field-1: {{!!field-1}}"

  3. save / download the file empty.html
  4. open it in your favourite text editor eg: VSCode :wink:

you will see several HTML comment markers

  • <!--~~ Raw markup ...
  • <!--~~ Static styles ...
  • <!--~~ Static content ...
  • <!--~~ Ordinary tiddlers ... ← Explained in more details later [A]
  • <!--~~ Library modules ... ← position [B]
  • <!--~~ Boot kernel prologue ...
  • <!--~~ Boot kernel ...
  • <!--~~ Raw markup for the bottom ...

If you search for and jump to: <!--~~ Library modules .. you’ll see a structure like this:

{"created":"20230329111008703","text":"some text\n\nfield-1: {{!!field-1}}","tags":"tag-1","title":"my-new-tiddler","modified":"20230329111824745","field-1":"value-1"}
]</script><div id="storeArea" style="display:none;"></div>
<!--~~ Library modules ~~-->

The big blob of text above the my-new-tiddler is the TW core-plugin, which also is a tiddler.

The pretty-printed structure of the wiki store looks like this:

<script class="tiddlywiki-tiddler-store" type="application/json">[
[
	{
		"title": "my-new-tiddler",
		"created": "20230329111008703",
		"modified": "20230329111824745",
		"tags": "tag-1",
		"field-1": "value-1"
		"text": "some text\n\nfield-1: {{!!field-1}}",
	},
	{
		"title": "minimal-viable-tiddler",
	}
]</script>

So … If your UI can search for <script class="tiddlywiki-tiddler-store" type="application/json"> and parse a JSON array, that contains tiddler objects you are able to read every tiddler-store from every tiddlywiki.html file.

Important: It’s allowed to have several stores wrapped in <script class="tiddlywiki-tiddler-store" type="application/json"> tags.

If you are able to create a JSON “tiddler store” and inject it into empty.html using the described markers, you are able to create a valid file-TiddlyWiki, which can be opened and saved in the browser.

See: How do TWs JSON Formats Look Like

The template $:/core/templates/tiddlywiki5.html responsible to create a file-tiddliwiki is at GitHub
and html-template at tiddlywiki-com

have fun!
mario
also see: TiddlyWikiPharo and critical code/data literacy curriculum - #8 by pmario

my-new-tiddler.json (169 Bytes)

1 Like