extwee 2.3.0 → 2.3.2

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/docs/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Extwee
1
+ <a name="readme-top"></a>
2
2
 
3
3
  [![codecov](https://codecov.io/gh/videlais/extwee/branch/master/graph/badge.svg)](https://codecov.io/gh/videlais/extwee)
4
4
 
@@ -8,13 +8,31 @@
8
8
 
9
9
  [![NPM Badge](https://nodei.co/npm/extwee.png?downloads=true)](https://www.npmjs.com/package/extwee)
10
10
 
11
+ ## Table of Contents
12
+
13
+ <ol>
14
+ <li><a href="#story-compilation">Story Compilation</a></li>
15
+ <li><a href="#format-support">Format Support</a></li>
16
+ <li><a href="#usage">Node and Web API</a></li>
17
+ <ol>
18
+ <li><a href="#objects">Objects</a></li>
19
+ <li><a href="#parsers">Parsers</a></li>
20
+ <li><a href="#compilers">Compilers</a></li>
21
+ </ol>
22
+ <li><a href="#documentation">Documentation</a></li>
23
+ <li><a href="#command-line-usage">Command-Line Usage</a></li>
24
+ <li><a href="#config-file-usage">Config File Usage</a></li>
25
+ <li><a href="#escaping- meta-characters">Escaping Meta-Characters</a></li>
26
+ <li><a href="#license">License</a></li>
27
+ </ol>
28
+
11
29
  ## Story Compilation
12
30
 
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.
31
+ 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). The result is then presented as links or other visual, interactive elements for another party.
14
32
 
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.
33
+ 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 JavaScript code (generally a "story format") with story HTML data.
16
34
 
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.
35
+ 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 content with story format code to produce something playable.
18
36
 
19
37
  Playable formats are the following and require external story formats[^1] to enable play:
20
38
 
@@ -38,48 +56,22 @@ Twine 2 supports exporting a collection of stories (known as a *library*) in the
38
56
 
39
57
  ## Format Support
40
58
 
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>
59
+ Extwee supports multiple historical and current Twine-compatible formats.
60
+
61
+ | Format | Input | Output |
62
+ |----------------------------------------------------------------------------------------------------------------------------------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
63
+ | [Twine 1 HTML (2006 - 2015)]( https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-htmloutput-doc.md ) | Yes | 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. |
64
+ | [Twine 1 TWS (2009 - 2015)]( https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-twsoutput.md ) | Yes | Extwee does not support TWS (Python pickle) output because no current version of Twine or other story compilation tool produces this historical format. |
65
+ | [Twine 2 HTML (2015 - Present)]( https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-htmloutput-spec.md ) | Yes | Yes |
66
+ | [Twine 2 Archive HTML (2015 - Present)]( https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-archive-spec.md ) | Yes | Yes |
67
+ | [Twee 3 (2021 - Present)]( https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md ) | Yes | Yes |
68
+ | [Twine 2 JSON (2023 - Present)]( https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-jsonoutput-doc.md ) | Yes | Yes |
69
+ | [Twine 2 Story Format (2015 - Present)]( https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-storyformats-spec.md ) | Yes | Yes |
80
70
 
81
71
  **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
72
 
73
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
74
+
83
75
  ## Node and Web API
84
76
 
85
77
  The following objects and methods are available in Node.js or browser contexts.
@@ -96,6 +88,10 @@ An object must be created using either the `new` keyword in JavaScript or as the
96
88
 
97
89
  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
90
 
91
+ The StoryFormat object supports `toString()` method of producing a tab-separated JSON output and `toJSON()` method of generating JSON output matching the Twine 2 Story Format Specification.
92
+
93
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
94
+
99
95
  ### Parsers
100
96
 
101
97
  Translates output formats such as HTML, Twee, JSON, or JSONP into objects.
@@ -109,6 +105,8 @@ Translates output formats such as HTML, Twee, JSON, or JSONP into objects.
109
105
  - `parseTwine2HTML()`
110
106
  - `parseTwine2ArchiveHTML()`
111
107
 
108
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
109
+
112
110
  ### Compilers
113
111
 
114
112
  Compiles story, story formats, or other data into an archive or playable format.
@@ -116,16 +114,31 @@ Compiles story, story formats, or other data into an archive or playable format.
116
114
  - `compileTwine2HTML()`
117
115
  - `compileTwine1HTML()`
118
116
  - `compileTwine2ArchiveHTML()`
117
+ - `compileStoryFormat()`
118
+
119
+ To create playable Twine 1 HTML, an `engine.js` file must be supplied. (See [Story Format Archive](https://github.com/videlais/story-formats-archive/tree/main/official/twine1/engine/1.4.2) for available Twine 1 `engine.js` file.)
120
+
121
+ Compilation of a story format adds the necessary function wrapper to convert the JSON output, via `toJSON()`, to JSONP.
122
+
123
+ ### Support Functionality
124
+
125
+ Multiple Twine formats support using [an IFID](https://ifdb.org/help-ifid) to identify one work from another.
119
126
 
120
- **Note:** In order to create playable Twine 1 HTML, an `engine.js` file must be supplied.
127
+ As part of its API, the Extwee method `generateIFID()` can be used to create a new IFID for a `Story` object or as part of other processes.
128
+
129
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
121
130
 
122
131
  ## Documentation
123
132
 
124
- Extwee has documentation on individual source files hosted on GitHub Pages.
133
+ Extwee has [documentation hosted on GitHub Pages](https://videlais.github.io/extwee/#/).
134
+
135
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
125
136
 
126
137
  ## Command-Line Usage
127
138
 
128
- Extwee supports a command-line interface for four general scenarios:
139
+ Extwee supports a command-line interface for four general scenarios.
140
+
141
+ **Notes:** As of Extwee 2.2.5, short and long command-line option flags are separated. Short options use one hyphen followed by one character and all long options begin with two hyphens and a name as word.
129
142
 
130
143
  ### Compiling Twee 3 + Twine 2 Story Format into Twine 2 HTML
131
144
 
@@ -141,27 +154,38 @@ De-compile Twine 2 HTML into Twee 3:
141
154
 
142
155
  ### Compiling Twee 3 into Twine 1 HTML
143
156
 
144
- Enabling Twine 1 mode requires using the `-t1` or `--twine1` flag.
157
+ Enabling Twine 1 mode requires using the `--twine1` long flag.
158
+
159
+ Because Twine 1 story formats can be split across files, compilation requires the "engine" from Twine 1 named `engine.js`, the name of the story format, and then its `header.html` template code and the optional but often included `code.js` file.
160
+
161
+ (Refer to the [Story Formats Archive](https://github.com/videlais/story-formats-archive) for access to historic `engine.js` and other files.)
145
162
 
146
- `extwee -t1 -c -i <tweeFile> -o <Twine1HTML> -engine <engineJS> -name <storyFormatName> -codejs <CodeJS> -header <header>`
163
+ `extwee --twine1 -c -i <tweeFile> -o <Twine1HTML> --engine <engineJS> --name <storyFormatName> --codejs <CodeJS> --header <header>`
147
164
 
148
165
  ### De-compiling Twine 1 HTML into Twee 3
149
166
 
150
- Enabling Twine 1 mode requires using the `-t1` or `--twine1` flag.
167
+ Enabling Twine 1 mode requires using the `--twine1` flag.
151
168
 
152
- `extwee -t1 -d -i <twine1HTML> -o <outputTwee>`
169
+ `extwee --twine1 -d -i <twine1HTML> -o <outputTwee>`
153
170
 
154
- ## Roadmap
171
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
155
172
 
156
- Each major version has its own GitHub project:
173
+ ## Config File Usage
157
174
 
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)
175
+ When invoked from its command-line interface using `npx extwee`, it will look for a `extwee.config.json` file in the local directory. If found, and its fields are valid, processing will use the values found in the file.
176
+
177
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
160
178
 
161
179
  ## Tree Shaking Support
162
180
 
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.
181
+ 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.
182
+
183
+ 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.
184
+
185
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
164
186
 
165
187
  ## License
166
188
 
167
189
  Distributed under the MIT License. See `LICENSE.txt` for more information.
190
+
191
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
package/docs/_sidebar.md CHANGED
@@ -1,5 +1,4 @@
1
1
  - Installation and General Usage
2
- - [Binaries (stand alone)](/install/binaries.md)
3
2
  - [Using NPX (as part of workflow)](/install/npx.md)
4
3
  - [Using NPM (via API)](/install/npm.md)
5
4
  - Objects
@@ -13,8 +13,4 @@ import { Story, Passage } from 'extwee';
13
13
  const example = new Story( 'Example' );
14
14
  // Add a new passage.
15
15
  example.addPassage(new Passage( 'Test', 'Some Text') );
16
-
17
- // Confirm size change.
18
- // (Should produce 1).
19
- console.log ( example.size() );
20
16
  ```
@@ -7,3 +7,73 @@ Extwee can be used via NPX (node package execution) without being added to a loc
7
7
  ```bash
8
8
  npx extwee -c -i <tweeFile> -s <storyFormat> -o <Twine2HTML>
9
9
  ```
10
+
11
+ ## Config File Usage
12
+
13
+ When used via NPX, Extwee will also look for a local file, `extwee.config.json`.
14
+
15
+ The configuration file supports some, but not all, possible actions using command-line arguments.
16
+
17
+ ### Defining `mode`
18
+
19
+ The most important option is `mode`. This **MUST BE** either `compile` or `decompile`.
20
+
21
+ ```json
22
+ {
23
+ "mode": "decompile"
24
+ }
25
+ ```
26
+
27
+ ### Defining `input` and `output`
28
+
29
+ To process files, the `input` and `output` properties **MUST BE** defined using either an absolute or relative path.
30
+
31
+ ```json
32
+ {
33
+ "mode": "compile",
34
+ "input": "index.twee",
35
+ "output": "index.html"
36
+ }
37
+ ```
38
+
39
+ ### Defining `story-format`
40
+
41
+ If using the `"mode": "compile"` option, the `story-format` property **MUST BE** defined. This should be the name of a directory in the relative `./story-formats` directory.
42
+
43
+ For example, if using Harlowe, the path would be `./story-formats/harlowe` and the key-value pair would be `"story-format": "harlowe"`.
44
+
45
+ ```json
46
+ {
47
+ "mode": "compile",
48
+ "input": "index.twee",
49
+ "output": "index.html",
50
+ "story-format": "harlowe"
51
+ }
52
+ ```
53
+
54
+ #### Defining optional `story-format-version`
55
+
56
+ The Story Format Archive retrieves story formats based on its version in a sub-directory structure:
57
+
58
+ ```file
59
+ story-formats/
60
+ ├── harlowe/
61
+ │ ├── 2.3.0/
62
+ │ └── format.js
63
+ │ ├── 2.4.0/
64
+ │ └── format.js
65
+ ```
66
+
67
+ This can be specified, such as `3.2.0`, or the default `latest`, can be used.
68
+
69
+ ```json
70
+ {
71
+ "mode": "compile",
72
+ "input": "index.twee",
73
+ "output": "index.html",
74
+ "story-format": "harlowe",
75
+ "story-format-version": "3.2.0"
76
+ }
77
+ ```
78
+
79
+ If only the story format name is specified, and it can be found in the local `story-formats` directory, it will search for a corresponding `format.js` file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extwee",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "A story compiler tool using Twine-compatible formats",
5
5
  "author": "Dan Cox",
6
6
  "main": "index.js",
@@ -33,22 +33,23 @@
33
33
  "uuid": "^11.1.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@babel/cli": "^7.27.2",
37
- "@babel/core": "^7.27.1",
38
- "@babel/preset-env": "^7.27.2",
36
+ "@babel/cli": "^7.28.0",
37
+ "@babel/core": "^7.28.0",
38
+ "@babel/preset-env": "^7.28.0",
39
39
  "@eslint/js": "^9.29.0",
40
- "@inquirer/prompts": "^7.5.2",
40
+ "@inquirer/prompts": "^7.6.0",
41
+ "@types/node": "^24.1.0",
41
42
  "@types/semver": "^7.7.0",
42
43
  "@types/uuid": "^10.0.0",
43
44
  "babel-loader": "^10.0.0",
44
45
  "clean-jsdoc-theme": "^4.3.0",
45
46
  "core-js": "^3.43.0",
46
47
  "eslint": "^9.29.0",
47
- "eslint-plugin-jest": "^28.14.0",
48
- "eslint-plugin-jsdoc": "^51.0.1",
49
- "globals": "^16.2.0",
50
- "jest": "^30.0.0",
51
- "jest-environment-jsdom": "^30.0.0",
48
+ "eslint-plugin-jest": "^29.0.1",
49
+ "eslint-plugin-jsdoc": "^52.0.2",
50
+ "globals": "^16.3.0",
51
+ "jest": "^30.0.4",
52
+ "jest-environment-jsdom": "^30.0.4",
52
53
  "regenerator-runtime": "^0.14.1",
53
54
  "typescript": "^5.8.3",
54
55
  "typescript-eslint": "^8.34.0",
package/src/Story.js CHANGED
@@ -7,7 +7,7 @@ import { encode } from 'html-entities';
7
7
  const creatorName = 'extwee';
8
8
 
9
9
  // Set the creator version.
10
- const creatorVersion = '2.3.0';
10
+ const creatorVersion = '2.3.2';
11
11
 
12
12
  /**
13
13
  * Story class.
@@ -251,5 +251,5 @@ export class Story {
251
251
  #private;
252
252
  }
253
253
  export const creatorName: "extwee";
254
- export const creatorVersion: "2.3.0";
254
+ export const creatorVersion: "2.3.2";
255
255
  import Passage from './Passage.js';
@@ -1,9 +0,0 @@
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
- ```