Skip to main content

Library to extract tiddlers from a tiddlywiki file.

Project description

tiddlywiki_parser

Parse the tiddler our of a tiddlywiki for backup, git management or anything else.

A simple tool to extract the tiddlers from a single file
Tiddlywiki (A personal, non-linear web notebook (aka a wiki in a file)).

Warning

This is barely more than a hobby project at this point. I'm turning it into a package because I'd like to import it in another project, but if you're using a different version of Tiddlywiki or use it differently than me, I can't suggest, much less promise or guarantee that it will work.

If you have a case where it doesn't work, create an Issue, and I'll take a look at it.

Install

pip install tiddlywiki_parser 

Usage

import tiddlywiki_parser.readers as readers
import tiddlywiki_parser.writiers as writers
from tiddlywiki_parser.tiddlywiki import TiddlyWiki

raw_content = readers.read('/path/to/tiddlywiki/file')
tiddlywiki = TiddlyWiki(raw_content)
writers.export('/path/to/destination/file.json, tiddlywiki.export_list(), save_json=True)
  • readers.read() can also take a url.
  • TiddlyWiki.tiddlers is a list of all the Tiddler objects.
  • TiddlyWiki.export_list() is the same but converted to dicts.
  • TiddlyWiki.parse() parses the file. It is run automatically under normal circumstances.
  • TiddlyWiki.remake(delete_list=['title1', 'title2'])
    • Builds a new tiddlywiki deleting the specified titles, and with any changes made to tiddlers. Titles cannot be changed.
  • Tiddler.dict() returns the dict version of the Tiddler object.
  • writers.export() will write the tiddlywiki either as individual files or a s a json file.

Limitations

tiddlywiki 5.2.0 changed how tiddlers are stored. v1.x only deals with tiddlywiki files that are pre-5.2.0. Hopefully v2.x can deal with pre- and post-5.2.0.

tiddlywiki does allow storing tiddlers in both the old and new form in the same file, this library doesn't handle that case (or any sort of modifying pre 5.2.0 wikis).

Only handles parsing single file tiddlywiki files.

remake is highly experimental and doesn't deal with:

  • adding a new tiddler
  • renaming tiddlers
  • pre-5.2.0 wikis
  • probably a bunch of other cases.

Command Line

There is a command line packaged with the package. It will parse a tiddlywiki file and save the tiddlers either as individual files or as a single json file.

usage: tiddlywiki_parser [-h] [--json] source output

positional arguments:
  source      The path to the html file
  output      The path to the output dir (or file).

options:
  -h, --help  show this help message and exit
  --json      Save as a json file instead of as individual tiddlers. output
              must be a dir.

source can be either a local file or an url.
output is the where the data should be written. It's either a directory for a writing individual files or a json file if --json is specified.

Packaging

This should now be a proper package, and it uses uv for all the packaging stuff.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiddlywiki_parser-2.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiddlywiki_parser-2.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file tiddlywiki_parser-2.1.0.tar.gz.

File metadata

  • Download URL: tiddlywiki_parser-2.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.2

File hashes

Hashes for tiddlywiki_parser-2.1.0.tar.gz
Algorithm Hash digest
SHA256 483a37dc7628a7267a8376f971bf9c9c8393171c1fdf7a8ebbc809494811243d
MD5 d66ad2d40629a12560a70bc8ff73e2a7
BLAKE2b-256 3d04da2dd82869c5941b9f9bdc6de3d9bfd29a6e2f007929b44407e0b989b1f5

See more details on using hashes here.

File details

Details for the file tiddlywiki_parser-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tiddlywiki_parser-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a601117d9dd77ee7a2e0668b3becc83330515619b5ed734c5351e60f65cc00a
MD5 63d11007945f10653924ae59f122f23c
BLAKE2b-256 f82f4483b321598d32cbaff4d965219971378d1a8152cf801fb948ff184f427d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page