Skip to main content

Twine Graph

Twine Graph is a Python package and command line tool for parsing passage and link structure from published .html Twine stories and outputting the resulting graphs in visual (.pdf) or structured (.json) formats. The goal of Twine Graph is to allow for research and analysis of story structure in freely-available Twine games.

Prerequisites

Twine Graph requires Python 3 and the beautifulsoup4 and graphviz packages. Tested primarily on Mac OS X within an Anaconda environment.

Installation

The easiest way to install Twine Graph is through pip:

pip install twine-graph

Example usage

The installed package can be called from the command line through its entry-point, as in the following sample call (using the example .html file included in the github project):

twine_graph twine_graph_example.html

The output .gv.pdf file can be opened for a visual representation of the passage and link structure of the story, while the output .json file provides a structured representation:

{
  "passages": [
    {
      "pid": 1,
      "name": "Hello",
      "text": "[[Hello->World]]",
      "links": [
        {
          "text": "Hello",
          "destination": {
            "name": "World",
            "pid": 2
          }
        }
      ]
    },
    {
      "pid": 2,
      "name": "World",
      "text": "Hello World",
      "links": []
    }
  ]
}

Known Issues

  • Doesn't detect links produced by custom javascript
  • Doesn't detect links referenced through variables (i.e. variable tracking not supported)

Related Work

  • twine-parser: A Javascript utility for parsing twine stories into graph objects.
  • TwineJson: A utility for Twine that exports a story into JSON format.

Author

Enrique Henestroza Anguiano

License

This project is licensed under the GNU GPL License - see LICENSE for details

Metadata

Release files for twine-graph 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twine-graph 0.0.1
File Size Uploaded
twine-graph-0.0.1.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for twine-graph 0.0.1
File Interpreter ABI Platform
twine_graph-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 kB

Release files / twine-graph-0.0.1.tar.gz

Download URL twine-graph-0.0.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
50cb8d33ab353ae04eb4bbdd4dbb489f1154d97cdc0e40efe0257992d72fb25a
BLAKE2b-256 checksum
How to use checksums
c51b3d0a6403e9e796dff66a31b47999b552755a218061459e0f8159992e219e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Release files / twine_graph-0.0.1-py3-none-any.whl

Download URL twine_graph-0.0.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f49f955a4afdaa1e3b7ce9e56583007daae79dc58076e36b87f601e488a8c694
BLAKE2b-256 checksum
How to use checksums
27bf03e79eab7b9da5e57f05e6cac11be0a15e3a02792ae9c105bd63f3600a0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page