extwee 2.0.5 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +25 -25
- package/.github/FUNDING.yml +3 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/nodejs.yml +25 -24
- package/.travis.yml +13 -13
- package/CODE_OF_CONDUCT.md +82 -82
- package/LICENSE +21 -21
- package/README.md +173 -36
- package/SECURITY.md +12 -12
- package/babel.config.json +18 -22
- package/build/extwee +0 -0
- package/build/extwee.exe +0 -0
- package/build/extwee.web.min.js +2 -0
- package/build/extwee.web.min.js.LICENSE.txt +1 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +167 -0
- package/docs/_sidebar.md +19 -0
- package/docs/examples/dynamicPassages.md +28 -0
- package/docs/examples/jsonToTwee.md +23 -0
- package/docs/examples/twsToTwee.md +25 -0
- package/docs/formats/json.md +17 -0
- package/docs/formats/twee.md +13 -0
- package/docs/formats/twine1HTML.md +13 -0
- package/docs/formats/twine2ArchiveHTML.md +13 -0
- package/docs/formats/twine2HTML.md +13 -0
- package/docs/formats/tws.md +9 -0
- package/docs/index.html +26 -0
- package/docs/install/binaries.md +9 -0
- package/docs/install/npm.md +20 -0
- package/docs/install/npx.md +9 -0
- package/docs/objects/passage.md +47 -0
- package/docs/objects/story.md +70 -0
- package/docs/objects/storyformat.md +27 -0
- package/index.html +22 -0
- package/index.js +29 -31
- package/package.json +65 -58
- package/src/JSON/parse.js +128 -0
- package/src/Passage.js +298 -202
- package/src/Story.js +650 -489
- package/src/StoryFormat/parse.js +134 -0
- package/src/StoryFormat.js +259 -300
- package/src/TWS/parse.js +86 -0
- package/src/Twee/parse.js +157 -0
- package/src/Twine1HTML/compile.js +58 -0
- package/src/Twine1HTML/parse.js +134 -0
- package/src/Twine2ArchiveHTML/compile.js +36 -0
- package/src/Twine2ArchiveHTML/parse.js +49 -0
- package/src/Twine2HTML/compile.js +35 -0
- package/src/Twine2HTML/parse.js +348 -0
- package/src/extwee.js +206 -0
- package/test/CLI/CLI.test.js +49 -0
- package/test/CLI/files/example.json +1 -0
- package/test/CLI/files/example6.twee +22 -0
- package/test/{Roundtrip → CLI/files}/harlowe.js +2 -2
- package/test/CLI/{input.html → files/input.html} +47 -47
- package/test/CLI/files/output/test.twee +0 -0
- package/test/CLI/{tweeExample.twee → files/tweeExample.twee} +17 -17
- package/test/CLI/files/twine1/LICENSE.txt +32 -0
- package/test/CLI/files/twine1/code.js +5 -0
- package/test/CLI/files/twine1/engine.js +43 -0
- package/test/CLI/files/twine1/header.html +325 -0
- package/test/CLI/files/twine1Test.html +371 -0
- package/test/{HTMLParser → CLI/files}/twineExample.html +16 -15
- package/test/JSON/JSON.Parse.test.js +316 -0
- package/test/Passage.test.js +175 -104
- package/test/Roundtrip/{Example1.html → Files/Example1.html} +63 -63
- package/test/Roundtrip/Files/LICENSE +19 -0
- package/test/Roundtrip/Files/example1.twee +10 -0
- package/test/Roundtrip/{example2.twee → Files/example2.twee} +27 -18
- package/test/Roundtrip/Files/example4.twee +27 -0
- package/test/{StoryFormatParser → Roundtrip/Files}/harlowe.js +2 -2
- package/test/Roundtrip/{round.html → Files/round.html} +6 -7
- package/test/Roundtrip/Roundtrip.test.js +54 -0
- package/test/Story.test.js +624 -355
- package/test/StoryFormat/StoryFormat.Parse.test.js +91 -0
- package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/example.js +3 -3
- package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/example2.js +3 -3
- package/test/{CLI → StoryFormat/StoryFormatParser}/harlowe.js +2 -2
- package/test/StoryFormat.test.js +152 -152
- package/test/TWS/Parse.test.js +78 -0
- package/test/TWS/TWSParser/Example1.tws +150 -0
- package/test/TWS/TWSParser/Example5.tws +414 -0
- package/test/TWS/TWSParser/noscale.tws +0 -0
- package/test/TWS/TWSParser/nostory.tws +0 -0
- package/test/Twee/Twee.Parse.test.js +76 -0
- package/test/{TweeParser → Twee/TweeParser}/emptytags.twee +2 -2
- package/test/{TweeParser → Twee/TweeParser}/example.twee +32 -32
- package/test/{TweeParser → Twee/TweeParser}/missing.twee +19 -19
- package/test/{TweeParser → Twee/TweeParser}/multipleScriptPassages.twee +19 -19
- package/test/{TweeParser → Twee/TweeParser}/multipleStyleTag.twee +19 -19
- package/test/{TweeParser → Twee/TweeParser}/multipletags.twee +10 -10
- package/test/{TweeParser → Twee/TweeParser}/noTitle.twee +2 -2
- package/test/{TweeParser → Twee/TweeParser}/notes.twee +16 -16
- package/test/{TweeParser → Twee/TweeParser}/pasagemetadataerror.twee +2 -2
- package/test/{TweeParser → Twee/TweeParser}/scriptPassage.twee +16 -16
- package/test/{TweeParser → Twee/TweeParser}/singletag.twee +13 -13
- package/test/{TweeParser → Twee/TweeParser}/startMetadata.twee +14 -14
- package/test/{TweeParser → Twee/TweeParser}/storydataerror.twee +25 -25
- package/test/{TweeParser → Twee/TweeParser}/stylePassage.twee +16 -16
- package/test/{Story → Twee/TweeParser}/test.twee +25 -25
- package/test/Twine1HTML/Twine1HTML.Compile.test.js +180 -0
- package/test/Twine1HTML/Twine1HTML.Parse.test.js +183 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/LICENSE +674 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js +43 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/jquery.js +4 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/modernizr.js +4 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/engineTest.html +1 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/LICENSE +32 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/code.js +4 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/header.html +327 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test.html +0 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test1.html +6 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test2.html +6 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test3.html +43 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test4.html +372 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test5.html +372 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTML.Compile.test.js +35 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTML.Parse.test.js +25 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTMLCompiler/test1.html +6 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTMLParser/test1.html +3 -0
- package/test/Twine2HTML/Twine2HTML.Compile.test.js +224 -0
- package/test/Twine2HTML/Twine2HTML.Parse.test.js +172 -0
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/creator.html +4 -5
- package/test/{CLI → Twine2HTML/Twine2HTMLCompiler}/example6.twee +15 -15
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/missingStoryTitle.twee +29 -29
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test11.html +1 -3
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test2.html +10 -11
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test3.html +1 -2
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test4.html +4 -5
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test6.html +1 -2
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/Example1.html +52 -52
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/Tags.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/lyingStartnode.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/lyingTagColors.html +48 -48
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingCreator.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingCreatorVersion.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingFormat.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingFormatVersion.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingIFID.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingName.html +33 -33
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPID.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPassageName.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPassageTags.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPosition.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingScript.html +14 -14
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingSize.html +35 -35
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingStartnode.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingStyle.html +14 -14
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingZoom.html +11 -11
- package/test/Twine2HTML/Twine2HTMLParser/twineExample.html +23 -0
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample2.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample3.html +15 -15
- package/web-index.js +29 -0
- package/webpack.config.js +12 -0
- package/bin/extwee.js +0 -47
- package/src/FileReader.js +0 -33
- package/src/HTMLParser.js +0 -343
- package/src/HTMLWriter.js +0 -231
- package/src/StoryFormatParser.js +0 -142
- package/src/TweeParser.js +0 -161
- package/src/TweeWriter.js +0 -98
- package/story-formats/chapbook-1.2.0/format.js +0 -1
- package/story-formats/chapbook-1.2.0/logo.svg +0 -1
- package/story-formats/harlowe-1.2.4/format.js +0 -1
- package/story-formats/harlowe-1.2.4/icon.svg +0 -78
- package/story-formats/harlowe-2.1.0/format.js +0 -2
- package/story-formats/harlowe-2.1.0/icon.svg +0 -78
- package/story-formats/harlowe-3.1.0/format.js +0 -3
- package/story-formats/harlowe-3.1.0/icon.svg +0 -78
- package/story-formats/paperthin-1.0.0/format.js +0 -1
- package/story-formats/paperthin-1.0.0/icon.svg +0 -5
- package/story-formats/snowman-1.4.0/format.js +0 -1
- package/story-formats/snowman-1.4.0/icon.svg +0 -436
- package/story-formats/snowman-2.0.2/format.js +0 -1
- package/story-formats/snowman-2.0.2/icon.svg +0 -436
- package/story-formats/sugarcube-1.0.35/LICENSE +0 -23
- package/story-formats/sugarcube-1.0.35/format.js +0 -1
- package/story-formats/sugarcube-1.0.35/icon.svg +0 -56
- package/story-formats/sugarcube-2.31.1/LICENSE +0 -22
- package/story-formats/sugarcube-2.31.1/format.js +0 -1
- package/story-formats/sugarcube-2.31.1/icon.svg +0 -56
- package/test/CLI/test2.html +0 -47
- package/test/CLI/twineExample.html +0 -15
- package/test/CLI.test.js +0 -30
- package/test/FileReader/t1.txt +0 -1
- package/test/FileReader.test.js +0 -14
- package/test/HTMLParser.test.js +0 -177
- package/test/HTMLWriter/example6.twee +0 -16
- package/test/HTMLWriter.test.js +0 -289
- package/test/Roundtrip/example1.twee +0 -21
- package/test/Roundtrip.test.js +0 -48
- package/test/Story/startmeta.twee +0 -29
- package/test/StoryFormatParser.test.js +0 -91
- package/test/TweeParser/test.twee +0 -25
- package/test/TweeParser.test.js +0 -79
- package/test/TweeWriter/test1.twee +0 -18
- package/test/TweeWriter/test3.twee +0 -12
- package/test/TweeWriter/test4.twee +0 -14
- package/test/TweeWriter/test5.twee +0 -20
- package/test/TweeWriter.test.js +0 -85
- /package/test/CLI/{test.twee → files/test.twee} +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/format.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/format_doublename.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingAuthor.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingDescription.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingImage.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingLicense.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingName.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingProofing.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingSource.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingURL.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingVersion.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/versionWrong.js +0 -0
- /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/TestTags.html +0 -0
- /package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/tagColors.html +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! https://mths.be/he v1.2.0 by @mathias | MIT license */
|
package/docs/.nojekyll
ADDED
|
File without changes
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Extwee
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/gh/videlais/extwee)
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/extwee)
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/extwee)
|
|
10
|
+
|
|
11
|
+
## Story Compilation
|
|
12
|
+
|
|
13
|
+
The process of *story compilation* converts human-readable content, what is generally called a *story*, into a playable format such as HyperText Markup Language (HTML) able to be read by another application such as a web browser. The result is then presented as links or other visual, interactive elements to a player or reader, depending on the work created.
|
|
14
|
+
|
|
15
|
+
The term *compilation* is used because different parts of code are put together in a specific arrangement to enable later play. As part of Twine-compatible HTML, this means combining story format JavaScript code with story HTML data.
|
|
16
|
+
|
|
17
|
+
Extwee is **not** an authoring tool. It cannot be used to create story content. This data must be created using other tools or processes. Extwee can then *compile* the story with story format code to produce something playable.
|
|
18
|
+
|
|
19
|
+
Playable formats are the following and require external story formats[^1] to enable play:
|
|
20
|
+
|
|
21
|
+
- Twine 2 HTML
|
|
22
|
+
- Twine 1 HTML
|
|
23
|
+
|
|
24
|
+
More human-readable formats include:
|
|
25
|
+
|
|
26
|
+
- Twee 3[^2]
|
|
27
|
+
- Twine 2 JSON[^3]
|
|
28
|
+
|
|
29
|
+
From 2009 to 2015, Twine 1 supported a now [historical format named TWS](https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-twsoutput.md). This was a binary format used for archival purposes. Extwee can read this format but does not support creating it because no other tools, including current versions of Twine, accept it as valid input.
|
|
30
|
+
|
|
31
|
+
Twine 2 supports exporting a collection of stories (known as a *library*) in the [Twine 2 Archive HTML format](https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-archive-spec.md). Extwee can also read and write this format, creating either a collection of stories from the data or writing a collection of internal objects to a file.
|
|
32
|
+
|
|
33
|
+
[^1]: Extwee does not include or publish story formats. These can be found in the [Story Format Archive (SFA)](https://github.com/videlais/story-formats-archive).
|
|
34
|
+
|
|
35
|
+
[^2]: Twee exists in three versions. The first existed between 2006 to 2009 and was part of Twine 1. The move to Twine 2 in 2009 dropped support and the story compilation tools [Twee2](https://dan-q.github.io/twee2/) and [Tweego](https://www.motoslave.net/tweego/) adopted their own extensions and modifications. Beginning in 2017, work was done to unite the different projects. This resulted in [Twee 3](https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md) in March 2021.
|
|
36
|
+
|
|
37
|
+
[^3]: In October 2023, JavaScript Object Notation (JSON) was added as a supported community format for story compilation tools. Extwee is the first tool to support this format.
|
|
38
|
+
|
|
39
|
+
## Format Support
|
|
40
|
+
|
|
41
|
+
Extwee is a story compilation tool supporting multiple historical and current Twine-compatible formats.
|
|
42
|
+
|
|
43
|
+
<table>
|
|
44
|
+
<tr>
|
|
45
|
+
<td>Format</td>
|
|
46
|
+
<td>Input</td>
|
|
47
|
+
<td>Output</td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td><a href='https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-htmloutput-doc.md'>Twine 1 HTML (2006 - 2015)</a> </td>
|
|
51
|
+
<td>Yes</td>
|
|
52
|
+
<td>Partial support. Twine 1 HTML can be produced, but the StorySettings optional passage introduced in Twine 1.4.0 requires external libraries like jQuery not included with Extwee.</td>
|
|
53
|
+
</tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td><a href="https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-twsoutput.md">Twine 1 TWS (2009 - 2015)</a></td>
|
|
56
|
+
<td>Yes</td>
|
|
57
|
+
<td>Extwee does not support TWS (Python pickle) output because no current version of Twine or other story compilation tool produces this historical format.</td>
|
|
58
|
+
</tr>
|
|
59
|
+
<tr>
|
|
60
|
+
<td><a href="https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-htmloutput-spec.md">Twine 2 HTML (2015 - Present)</a></td>
|
|
61
|
+
<td>Yes</td>
|
|
62
|
+
<td>Yes</td>
|
|
63
|
+
</tr>
|
|
64
|
+
<tr>
|
|
65
|
+
<td><a href="https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-archive-spec.md">Twine 2 Archive HTML (2015 - Present)</a></td>
|
|
66
|
+
<td>Yes</td>
|
|
67
|
+
<td>Yes</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td><a href="https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md">Twee 3 (2021 - Present)</a></td>
|
|
71
|
+
<td>Yes</td>
|
|
72
|
+
<td>Yes</td>
|
|
73
|
+
</tr>
|
|
74
|
+
<tr>
|
|
75
|
+
<td><a href="https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-jsonoutput-doc.md">Twine 2 JSON (2023 - Present)</a></td>
|
|
76
|
+
<td>Yes</td>
|
|
77
|
+
<td>Yes</td>
|
|
78
|
+
</tr>
|
|
79
|
+
</table>
|
|
80
|
+
|
|
81
|
+
**Note:** Round-trip translations can present problems because of required fields and properties per format. Some metadata may be added or removed based on the specification being followed.
|
|
82
|
+
|
|
83
|
+
## Node and Web API
|
|
84
|
+
|
|
85
|
+
The following objects and methods are available in Node.js or browser contexts.
|
|
86
|
+
|
|
87
|
+
**Note:** When used in a browser context, all objects and methods are part of the `window.Extwee` global.
|
|
88
|
+
|
|
89
|
+
### Objects
|
|
90
|
+
|
|
91
|
+
An object must be created using either the `new` keyword in JavaScript or as the result of parsing data.
|
|
92
|
+
|
|
93
|
+
- `StoryFormat`
|
|
94
|
+
- `Passage`
|
|
95
|
+
- `Story`
|
|
96
|
+
|
|
97
|
+
Story and Passage objects can generate multiple output formats: `toTwee()`, `toTwine1HTML()`, `toTwine2HTML()`, and `toJSON()`. Stories cannot be played in a browser without the corresponding compiler combining it with story format data.
|
|
98
|
+
|
|
99
|
+
### Parsers
|
|
100
|
+
|
|
101
|
+
Translates output formats such as HTML, Twee, JSON, or JSONP into objects.
|
|
102
|
+
|
|
103
|
+
**Note:** Twine 1 story formats exist across multiple files (`header.html` and optional `code.js`). They cannot be parsed into a `StoryFormat` object.
|
|
104
|
+
|
|
105
|
+
- `parseTwee()`
|
|
106
|
+
- `parseJSON()`
|
|
107
|
+
- `parseStoryFormat()`
|
|
108
|
+
- `parseTwine1HTML()`
|
|
109
|
+
- `parseTwine2HTML()`
|
|
110
|
+
- `parseTwine2ArchiveHTML()`
|
|
111
|
+
|
|
112
|
+
### Compilers
|
|
113
|
+
|
|
114
|
+
Compiles story, story formats, or other data into an archive or playable format.
|
|
115
|
+
|
|
116
|
+
- `compileTwine2HTML()`
|
|
117
|
+
- `compileTwine1HTML()`
|
|
118
|
+
- `compileTwine2ArchiveHTML()`
|
|
119
|
+
|
|
120
|
+
**Note:** In order to create playable Twine 1 HTML, an `engine.js` file must be supplied.
|
|
121
|
+
|
|
122
|
+
## Documentation
|
|
123
|
+
|
|
124
|
+
Extwee has documentation on individual source files hosted on GitHub Pages.
|
|
125
|
+
|
|
126
|
+
## Command-Line Usage
|
|
127
|
+
|
|
128
|
+
Extwee supports a command-line interface for four general scenarios:
|
|
129
|
+
|
|
130
|
+
### Compiling Twee 3 + Twine 2 Story Format into Twine 2 HTML
|
|
131
|
+
|
|
132
|
+
Compile Twee 3 + StoryFormat into Twine 2 HTML:
|
|
133
|
+
|
|
134
|
+
`extwee -c -i <tweeFile> -s <storyFormat> -o <Twine2HTML>`
|
|
135
|
+
|
|
136
|
+
### De-compiling Twine 2 HTML into Twee 3
|
|
137
|
+
|
|
138
|
+
De-compile Twine 2 HTML into Twee 3:
|
|
139
|
+
|
|
140
|
+
`extwee -d -i <twine2HTML> -o <outputTwee>`
|
|
141
|
+
|
|
142
|
+
### Compiling Twee 3 into Twine 1 HTML
|
|
143
|
+
|
|
144
|
+
Enabling Twine 1 mode requires using the `-t1` or `--twine1` flag.
|
|
145
|
+
|
|
146
|
+
`extwee -t1 -c -i <tweeFile> -o <Twine1HTML> -engine <engineJS> -name <storyFormatName> -codejs <CodeJS> -header <header>`
|
|
147
|
+
|
|
148
|
+
### De-compiling Twine 1 HTML into Twee 3
|
|
149
|
+
|
|
150
|
+
Enabling Twine 1 mode requires using the `-t1` or `--twine1` flag.
|
|
151
|
+
|
|
152
|
+
`extwee -t1 -d -i <twine1HTML> -o <outputTwee>`
|
|
153
|
+
|
|
154
|
+
## Roadmap
|
|
155
|
+
|
|
156
|
+
Each major version has its own GitHub project:
|
|
157
|
+
|
|
158
|
+
- [Road to Extwee 2.2.0](https://github.com/users/videlais/projects/2)
|
|
159
|
+
- [Road to Extwee 2.4.0](https://github.com/users/videlais/projects/4)
|
|
160
|
+
|
|
161
|
+
## Tree Shaking Support
|
|
162
|
+
|
|
163
|
+
For [advanced tree shaking](https://developer.mozilla.org/en-US/docs/Glossary/Tree_shaking) patterns, most formats are broke into `compile.js` and `parse.js` files exporting associated `compile()` and `parse()` functions. When using the API, it is possible to only import a single function or object to produce smaller and potentially faster code in projects dependent on Extwee functionality.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
Distributed under the MIT License. See `LICENSE.txt` for more information.
|
package/docs/_sidebar.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
- Installation and General Usage
|
|
2
|
+
- [Binaries (stand alone)](/install/binaries.md)
|
|
3
|
+
- [Using NPX (as part of workflow)](/install/npx.md)
|
|
4
|
+
- [Using NPM (via API)](/install/npm.md)
|
|
5
|
+
- Objects
|
|
6
|
+
- [Passage](/objects/passage.md)
|
|
7
|
+
- [Story](/objects/story.md)
|
|
8
|
+
- [Story Format](/objects/storyformat.md)
|
|
9
|
+
- Formats
|
|
10
|
+
- [Twee 3](/formats/twee.md)
|
|
11
|
+
- [Twine 2 HTML](/formats/twine2HTML.md)
|
|
12
|
+
- [Twine 2 JSON](/formats/json.md)
|
|
13
|
+
- [Twine 2 Archive HTML](/formats/twine2ArchiveHTML.md)
|
|
14
|
+
- [Twine 1 HTML](/formats/twine1HTML.md)
|
|
15
|
+
- [Twine 1 TWS](/formats/tws.md)
|
|
16
|
+
|
|
17
|
+
- Examples
|
|
18
|
+
- [Dynamically Generating Passages](/examples/dynamicPassages.md)
|
|
19
|
+
- [Converting Twine 2 JSON into Twee 3](/examples/jsonToTwee.md)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Dynamically Generating Passages
|
|
2
|
+
|
|
3
|
+
Through using the API, it is possible to dynamically create passages and then export this story into Twee (or JSON) using only the **Story** and **Passage** objects.
|
|
4
|
+
|
|
5
|
+
Both **Story** and **Passage** objects can be created through the `new` keyword in JavaScript. After creating a **Story**, the use of the method `addPassage(Passage)` can be used to add new passages.
|
|
6
|
+
|
|
7
|
+
In the following example, the use of a `for()` loop is used to generate 20 passages and a starting passage is set. Finally, the **Story** data is converted into Twee and written to an output file.
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
// Import only Story and Passage.
|
|
11
|
+
import { Story, Passage } from 'extwee';
|
|
12
|
+
// Import only writeFileSync() for writing to files.
|
|
13
|
+
import { writeFileSync } from 'node:fs';
|
|
14
|
+
|
|
15
|
+
// Create the story.
|
|
16
|
+
const example = new Story( 'Example' );
|
|
17
|
+
|
|
18
|
+
// Generate 20 passages and add them to the story.
|
|
19
|
+
for(let i = 0; i < 20; i++;) {
|
|
20
|
+
example.addPassage( new Passage( `Passage ${i}`, 'Some Text') );
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Set a starting passage.
|
|
24
|
+
example.start = 'Passage 1';
|
|
25
|
+
|
|
26
|
+
// Create a Twee file.
|
|
27
|
+
writeFileSync( 'example.twee', example.toTwee() );
|
|
28
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Converting Twine 2 JSON to Twee 3
|
|
2
|
+
|
|
3
|
+
Conversion from Twine 2 JSON to Twee 3 requires multiple steps:
|
|
4
|
+
|
|
5
|
+
1. Read the JSON file.
|
|
6
|
+
2. Use `parseJSON()` to convert JSON into a **Story** object.
|
|
7
|
+
3. Using `Story.toTwee()`, convert the **Story** object into Twee 3.
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
// Import only Story and parseJSON().
|
|
11
|
+
import { Story, parseJSON } from 'extwee';
|
|
12
|
+
// Import only readFileSync() and writeFileSync() for reading and writing to files.
|
|
13
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
14
|
+
|
|
15
|
+
// Read in the JSON file
|
|
16
|
+
const inputFile = readFileSync( 'example.json', 'utf-8' );
|
|
17
|
+
|
|
18
|
+
// Convert from Twine 2 JSON to Story.
|
|
19
|
+
const s = parseJSON(inputFile);
|
|
20
|
+
|
|
21
|
+
// Write Twee output
|
|
22
|
+
writeFileSync( 'output.twee', s.toTwee() );
|
|
23
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# TWS To Twee
|
|
2
|
+
|
|
3
|
+
Converting from TWS to Twee 3 is similar to many other conversion processes:
|
|
4
|
+
|
|
5
|
+
1. Read the binary file.
|
|
6
|
+
2. Convert the binary files into a Buffer.
|
|
7
|
+
3. Parse the Buffer into a Story.
|
|
8
|
+
4. Convert Story data into Twee.
|
|
9
|
+
|
|
10
|
+
```javascript
|
|
11
|
+
// Import only readFileSynce() and writeFileSync().
|
|
12
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
13
|
+
// Only import Story and parseTWS().
|
|
14
|
+
import { Story, parseTWS } from 'extwee';
|
|
15
|
+
|
|
16
|
+
// Read the file contents using binary encoding.
|
|
17
|
+
const contents = readFileSync( 'Example1.tws', 'binary' );
|
|
18
|
+
// Convert from binary into Buffer.
|
|
19
|
+
const b = Buffer.from( contents, 'binary' );
|
|
20
|
+
// convert TWS into Story.
|
|
21
|
+
const s = parseTWS( b );
|
|
22
|
+
|
|
23
|
+
// Write Twee to output file.
|
|
24
|
+
writeFileSync( 'example.twee', s.toTwee() );
|
|
25
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# JSON
|
|
2
|
+
|
|
3
|
+
The [Twine 2 JSON specification](https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-jsonoutput-doc.md) defines a format for storing a Twine 2 compatible story and passage data in JavaScript Objection Notation (JSON).
|
|
4
|
+
|
|
5
|
+
Extwee can perform two actions.
|
|
6
|
+
|
|
7
|
+
## Parse
|
|
8
|
+
|
|
9
|
+
When using the `parseJSON()` function (or `JSON/parse.js` export), incoming Twine 2 JSON will be converted into a [**Story**](/objects/story.md) object.
|
|
10
|
+
|
|
11
|
+
## Output
|
|
12
|
+
|
|
13
|
+
Every **Story** object can create a JSON representation of its data using the `Story.toJSON()` method.
|
|
14
|
+
|
|
15
|
+
## Format Caution
|
|
16
|
+
|
|
17
|
+
As of December 2023, no current story compilation (other than Extwee) or version of Twine supports input or output of the Twine 2 JSON format.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Twee
|
|
2
|
+
|
|
3
|
+
The [Twee 3 specification](https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md) defines a human-readable format for storing a Twine 2 compatible story and passage data.
|
|
4
|
+
|
|
5
|
+
Extwee can perform two actions with Twee.
|
|
6
|
+
|
|
7
|
+
## Parse
|
|
8
|
+
|
|
9
|
+
When using the `parseTwee()` function (or `Twee/parse.js` export), incoming Twee will be converted into a [**Story**](/objects/story.md) object.
|
|
10
|
+
|
|
11
|
+
## Output
|
|
12
|
+
|
|
13
|
+
Every **Story** object can create a Twee representation of its data using the `Story.toTwee()` method.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Twine 1 HTML
|
|
2
|
+
|
|
3
|
+
The [Twine 1 HTML Output specification](https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-htmloutput-doc.md) defines the elements and attributes for encoding Twine 1 story and passage data.
|
|
4
|
+
|
|
5
|
+
Extwee can perform two actions with Twine 1 HTML.
|
|
6
|
+
|
|
7
|
+
## Parsing
|
|
8
|
+
|
|
9
|
+
When using the `parseTwine1HTML()` function (or `Twine1HTML/parse.js` export), incoming Twine 1 HTML will be converted into a [**Story**](/objects/story.md) object.
|
|
10
|
+
|
|
11
|
+
## Compilation
|
|
12
|
+
|
|
13
|
+
When using the `compileTwine1HTML()` function (or `Twine2HTML/compile.js` export), [**Story**](/objects/story.md) objects can be compiled into Twine 1 HTML output with additional content from `engine.js`, `header.html`, and `code.js` files.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Twine 2 Archive HTML
|
|
2
|
+
|
|
3
|
+
The [Twine 2 Archive HTML specification](https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-archive-spec.md) defines a collection of Twine 2 stories stored in HTML.
|
|
4
|
+
|
|
5
|
+
Extwee can perform two actions with Twine 2 archive HTML.
|
|
6
|
+
|
|
7
|
+
## Parsing
|
|
8
|
+
|
|
9
|
+
When using the `parseTwine2ArchiveHTML()` function (or `Twine2ArchiveHTML/parse.js` export), incoming Twine 2 Archive HTML will be converted into an array of [**Story**](/objects/story.md) objects.
|
|
10
|
+
|
|
11
|
+
## Compilation
|
|
12
|
+
|
|
13
|
+
When using the `compileTwine2ArchiveHTML()` function (or `Twine2ArchiveHTML/compile.js` export), an array of **Story** objects can be converted into Twine 2 Archive HTML.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Twine 2 HTML
|
|
2
|
+
|
|
3
|
+
The [Twine 2 HTML Output specification](https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-htmloutput-spec.md) defines the elements and attributes for encoding Twine 2 story and passage data.
|
|
4
|
+
|
|
5
|
+
Extwee can perform two actions with Twine 2 HTML.
|
|
6
|
+
|
|
7
|
+
## Parsing
|
|
8
|
+
|
|
9
|
+
When using the `parseTwine2HTML()` function (or `Twine2HTML/parse.js` export), incoming Twine 2 HTML will be converted into a [**Story**](/objects/story.md) object.
|
|
10
|
+
|
|
11
|
+
## Compilation
|
|
12
|
+
|
|
13
|
+
When using the `compileTwine2HTML()` function (or `Twine2HTML/compile.js` export), [**Story**](/objects/story.md) and [**StoryFormat**](/objects/storyformat.md) objects can be compiled into Twine 2 HTML output.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# TWS
|
|
2
|
+
|
|
3
|
+
The [Twine 1 TWS documentation](https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-twsoutput.md) details the Python pickle format used in Twine 1.
|
|
4
|
+
|
|
5
|
+
Extwee can only parse TWS files.
|
|
6
|
+
|
|
7
|
+
## Parsing
|
|
8
|
+
|
|
9
|
+
When using the `parseTWS()` function (or `TWS/parse.js` export), incoming TWS will be converted into a [**Story**](/objects/story.md) object.
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Document</title>
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
|
7
|
+
<meta name="description" content="Description">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
|
9
|
+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/buble.css" />
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>
|
|
14
|
+
window.$docsify = {
|
|
15
|
+
name: 'Extwee Documentation',
|
|
16
|
+
repo: 'https://github.com/videlais/extwee',
|
|
17
|
+
loadSidebar: true
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
<!-- Docsify v4 -->
|
|
21
|
+
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
|
|
22
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script>
|
|
23
|
+
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
|
|
24
|
+
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-javascript.min.js"></script>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Binaries
|
|
2
|
+
|
|
3
|
+
Either by downloading the `extwee` (or `extwee.exe`) files from the [Releases listing](https://github.com/videlais/extwee/releases) or from the `build` folder, Extwee can be used as a stand-alone command-line program. (Currently, only builds for MacOS and Windows are included.)
|
|
4
|
+
|
|
5
|
+
## CLI Example
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
extwee.exe -c -i <tweeFile> -s <storyFormat> -o <Twine2HTML>
|
|
9
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# NPM
|
|
2
|
+
|
|
3
|
+
While general compilation and de-compilation is possible using the CLI, more advanced usage patterns can be enabled through the API.
|
|
4
|
+
|
|
5
|
+
By installing `extwee`, developers can directly access its objects, parsers, and compilation functionality.
|
|
6
|
+
|
|
7
|
+
## Example
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import { Story, Passage } from 'extwee';
|
|
11
|
+
|
|
12
|
+
// Create the story.
|
|
13
|
+
const example = new Story( 'Example' );
|
|
14
|
+
// Add a new passage.
|
|
15
|
+
example.addPassage(new Passage( 'Test', 'Some Text') );
|
|
16
|
+
|
|
17
|
+
// Confirm size change.
|
|
18
|
+
// (Should produce 1).
|
|
19
|
+
console.log ( example.size() );
|
|
20
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Passage
|
|
2
|
+
|
|
3
|
+
The smallest unit in Twine is a *passage*.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
When using the Extwee API, a **Passage** object holds four properties:
|
|
8
|
+
|
|
9
|
+
- name ( string ) Name of the passage.
|
|
10
|
+
- text ( string ) Content of the passage.
|
|
11
|
+
- tags ( array(string) ) Array of tags associated with the passage.
|
|
12
|
+
- Metadata ( object ) Key-value pairs associated with the passage.
|
|
13
|
+
|
|
14
|
+
### Property Example
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
import { Passage } from 'extwee';
|
|
18
|
+
|
|
19
|
+
// Create a single passage.
|
|
20
|
+
const example = new Passage('Example', 'Some text');
|
|
21
|
+
|
|
22
|
+
// Output current passage text.
|
|
23
|
+
console.log( example.text );
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Methods
|
|
27
|
+
|
|
28
|
+
Each passage is capable of producing multiple formats of its internal data:
|
|
29
|
+
|
|
30
|
+
- `toTwee()`: Converts passage data into Twee 3.
|
|
31
|
+
- `toJSON()`: Converts passage data into Twine 2 JSON.
|
|
32
|
+
- `toTwine2HTML()`: Converts passage data into Twine 2 HTML.
|
|
33
|
+
- `toTwine1HTML()`: Converts passage data into Twine 1 HTML.
|
|
34
|
+
|
|
35
|
+
### Method Example
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
import { Passage } from 'extwee';
|
|
39
|
+
|
|
40
|
+
// Create a single passage.
|
|
41
|
+
const example = new Passage('Example', 'Some text');
|
|
42
|
+
|
|
43
|
+
// Convert to Twee 3.
|
|
44
|
+
console.log( example.toTwee() );
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Note:** While each passage can create different representations of its data, each conversion is considered partial without the corresponding story metadata or story format to create the playable form.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Story
|
|
2
|
+
|
|
3
|
+
A *story* is a collection of [passages](/guide/passage.md) with its own metadata.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
Depending on the incoming format or creation method, many possible properties can be populated.
|
|
8
|
+
|
|
9
|
+
- name ( string ) Name of the story.
|
|
10
|
+
- start ( string ) Starting passage for Twine 2 HTML or Twee 3.
|
|
11
|
+
- IFID ( string ) When converting to multiple formats, a new IFID will be generated if it does not exist.
|
|
12
|
+
- format ( string ) Name of the story format for Twine 2 HTML.
|
|
13
|
+
- formatVersion ( string ) Semantic version of the named story format for Twine 2 HTML or Twee 3.
|
|
14
|
+
- zoom ( float ) Zoom level for Twine 2 HTML or Twee 3.
|
|
15
|
+
- passages ( array(Passage) ) **[Read-only]** Collection of internal passages.
|
|
16
|
+
- creator ( string ) Name of story creation tool. (Defaults to "Extwee").
|
|
17
|
+
- creatorVersion ( string ) Semantic version of named creation tool.
|
|
18
|
+
- metadata ( object ) Key-value pairs of metadata values.
|
|
19
|
+
- tagColors ( object ) Key-value pairs of tags and their named colors.
|
|
20
|
+
|
|
21
|
+
## Creation Example
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { Story } from 'extwee';
|
|
25
|
+
|
|
26
|
+
// Create a story.
|
|
27
|
+
const example = new Story('Example');
|
|
28
|
+
|
|
29
|
+
// Show story name
|
|
30
|
+
console.log ( example.name );
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Note:** All properties have protections. Attempting to assign the wrong type will result in an error.
|
|
34
|
+
|
|
35
|
+
## Passage Methods
|
|
36
|
+
|
|
37
|
+
As collections of passages, each **Story** has multiple methods for accessing and mutating its data:
|
|
38
|
+
|
|
39
|
+
- `addPassage(Passage)`: Adds a new passage to the collection. (In Twine, passage names must be unique. Extwee will produce a console warning and ignore any repeating names.)
|
|
40
|
+
- `removePassageByName(string)`: Looks for an removes a passage based on its name. If the passage does not exist, nothing happens.
|
|
41
|
+
- `getPassagesByTags(string)`: Returns an array of any passages containing a particular tag value.
|
|
42
|
+
- `getPassageByName(string)`: Returns either `null`` or the named passage.
|
|
43
|
+
- `size()`: Returns the number of passages in the collection.
|
|
44
|
+
- `forEachPassage(callback)`: Allows for iterating over the passage collection.
|
|
45
|
+
|
|
46
|
+
## Passage Creation Example
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import { Story, Passage } from 'extwee';
|
|
50
|
+
|
|
51
|
+
// Create the story.
|
|
52
|
+
const example = new Story( 'Example' );
|
|
53
|
+
// Add a new passage.
|
|
54
|
+
example.addPassage(new Passage( 'Test', 'Some Text') );
|
|
55
|
+
|
|
56
|
+
// Confirm size change.
|
|
57
|
+
// (Should produce 1).
|
|
58
|
+
console.log ( example.size() );
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Note:** It is not possible to directly access and act on the *passages* property. All actions must take place through available methods.
|
|
62
|
+
|
|
63
|
+
Like passages, each **Story** can generate multiple formats based on its data:
|
|
64
|
+
|
|
65
|
+
- `toTwee()`: Convert the story, its properties, and all its passages into Twee 3.
|
|
66
|
+
- `toJSON()`: Converts the story, its properties, and all its passages into Twine 2 JSON.
|
|
67
|
+
- `toTwine1HTML()`: Converts the story, its properties, and all its passages into Twine 1 HTML.
|
|
68
|
+
- `toTwine2HTML()`: Converts the story, its properties, and all its passages into Twine 2 HTML.
|
|
69
|
+
|
|
70
|
+
**Note:** While stories can create different representations of its data, most conversions are considered partial without the corresponding story format to create the playable form.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Story Format
|
|
2
|
+
|
|
3
|
+
For a story to be playable in Twine, it must be combined with a *story format*.
|
|
4
|
+
|
|
5
|
+
In Twine 1, story formats can exist across multiple files:
|
|
6
|
+
|
|
7
|
+
- `engine.js`: "engine" as included from Twine 1.
|
|
8
|
+
- `header.html`: HTML "header" the Twine 1 HTML will be added into to create published file.
|
|
9
|
+
- `code.js`: While technically optional, most story formats include extra code found in a `code.js` file.
|
|
10
|
+
|
|
11
|
+
In Twine 2, story formats are single files generally named `format.js`. These are [JSONP files](https://en.wikipedia.org/wiki/JSONP) with JSON data of the story format included within a function call payload.
|
|
12
|
+
|
|
13
|
+
## Properties
|
|
14
|
+
|
|
15
|
+
When working with Twine 2 story formats, the associated `parse()` function call be used to create a **StoryFormat** object with the following properties:
|
|
16
|
+
|
|
17
|
+
- name ( string ) Name of the story format.
|
|
18
|
+
- version ( string ) Semantic version.
|
|
19
|
+
- author ( string ) Author of the story format.
|
|
20
|
+
- description ( string ) Summary of the story format.
|
|
21
|
+
- image ( string ) URL of an image (ideally SVG) acting as its icon in Twine.
|
|
22
|
+
- url ( string ) URL of the directory containing the `format.js` file.
|
|
23
|
+
- license ( string ) License acronym and sometimes version.
|
|
24
|
+
- proofing ( boolean ) (defaults to false). True if the story format is a "proofing" format.
|
|
25
|
+
- source ( string ) Full HTML output of the story format including the two placeholders {{STORY_NAME}} and {{STORY_DATA}}. (The placeholders are not themselves required.)
|
|
26
|
+
|
|
27
|
+
**Note:** Generally, even when using the Extwee API, it is rare to work with story formats beyond parsing them as part of Twine 1 or Twine 2 HTML compilation.
|
package/index.html
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Document</title>
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
|
7
|
+
<meta name="description" content="Description">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
|
9
|
+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>
|
|
14
|
+
window.$docsify = {
|
|
15
|
+
name: '',
|
|
16
|
+
repo: ''
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
<!-- Docsify v4 -->
|
|
20
|
+
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|