extwee 1.5.3 → 2.0.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 -0
- package/.github/workflows/nodejs.yml +24 -0
- package/.travis.yml +13 -0
- package/CODE_OF_CONDUCT.md +82 -0
- package/LICENSE +21 -21
- package/README.md +36 -203
- package/SECURITY.md +12 -0
- package/babel.config.json +22 -0
- package/bin/extwee.js +49 -0
- package/index.js +31 -26
- package/package.json +60 -39
- package/src/FileReader.js +33 -0
- package/src/HTMLParser.js +343 -0
- package/src/HTMLWriter.js +196 -0
- package/src/Passage.js +202 -0
- package/src/Story.js +461 -0
- package/src/StoryFormat.js +300 -0
- package/src/StoryFormatParser.js +142 -0
- package/src/TweeParser.js +166 -0
- package/src/TweeWriter.js +98 -0
- package/story-formats/chapbook-1.2.0/format.js +1 -0
- package/story-formats/chapbook-1.2.0/logo.svg +1 -0
- package/story-formats/harlowe-1.2.4/format.js +1 -0
- package/story-formats/harlowe-1.2.4/icon.svg +78 -0
- package/story-formats/harlowe-2.1.0/format.js +2 -0
- package/story-formats/harlowe-2.1.0/icon.svg +78 -0
- package/story-formats/harlowe-3.1.0/format.js +3 -0
- package/story-formats/harlowe-3.1.0/icon.svg +78 -0
- package/story-formats/paperthin-1.0.0/format.js +1 -0
- package/story-formats/paperthin-1.0.0/icon.svg +5 -0
- package/story-formats/snowman-1.4.0/format.js +1 -0
- package/story-formats/snowman-1.4.0/icon.svg +436 -0
- package/story-formats/snowman-2.0.2/format.js +1 -0
- package/story-formats/snowman-2.0.2/icon.svg +436 -0
- package/story-formats/sugarcube-1.0.35/LICENSE +23 -0
- package/story-formats/sugarcube-1.0.35/format.js +1 -0
- package/story-formats/sugarcube-1.0.35/icon.svg +56 -0
- package/story-formats/sugarcube-2.31.1/LICENSE +22 -0
- package/story-formats/sugarcube-2.31.1/format.js +1 -0
- package/story-formats/sugarcube-2.31.1/icon.svg +56 -0
- package/test/CLI/example6.twee +16 -0
- package/test/CLI/harlowe.js +3 -0
- package/test/CLI/input.html +47 -0
- package/test/CLI/test.twee +18 -0
- package/test/CLI/test2.html +47 -0
- package/test/CLI/tweeExample.twee +17 -0
- package/test/CLI/twineExample.html +15 -0
- package/test/CLI.test.js +30 -0
- package/test/FileReader/t1.txt +1 -0
- package/test/FileReader.test.js +14 -0
- package/test/HTMLParser/Example1.html +53 -0
- package/test/HTMLParser/Tags.html +15 -0
- package/test/HTMLParser/lyingStartnode.html +15 -0
- package/test/HTMLParser/lyingTagColors.html +48 -0
- package/test/HTMLParser/missingCreator.html +11 -0
- package/test/HTMLParser/missingCreatorVersion.html +11 -0
- package/test/HTMLParser/missingFormat.html +11 -0
- package/test/HTMLParser/missingFormatVersion.html +11 -0
- package/test/HTMLParser/missingIFID.html +11 -0
- package/test/HTMLParser/missingName.html +33 -0
- package/test/HTMLParser/missingPID.html +15 -0
- package/test/HTMLParser/missingPassageName.html +15 -0
- package/test/HTMLParser/missingPassageTags.html +15 -0
- package/test/HTMLParser/missingPosition.html +15 -0
- package/test/HTMLParser/missingScript.html +14 -0
- package/test/HTMLParser/missingSize.html +35 -0
- package/test/HTMLParser/missingStartnode.html +11 -0
- package/test/HTMLParser/missingStyle.html +14 -0
- package/test/HTMLParser/missingZoom.html +11 -0
- package/test/HTMLParser/tagColors.html +31 -0
- package/test/HTMLParser/twineExample.html +15 -0
- package/test/HTMLParser/twineExample2.html +15 -0
- package/test/HTMLParser/twineExample3.html +15 -0
- package/test/HTMLParser.test.js +177 -0
- package/test/HTMLWriter/TestTags.html +42 -0
- package/test/HTMLWriter/creator.html +51 -0
- package/test/HTMLWriter/example6.twee +16 -0
- package/test/HTMLWriter/missingStoryTitle.twee +29 -0
- package/test/HTMLWriter/test11.html +123 -0
- package/test/HTMLWriter/test2.html +59 -0
- package/test/HTMLWriter/test3.html +50 -0
- package/test/HTMLWriter/test4.html +51 -0
- package/test/HTMLWriter/test6.html +50 -0
- package/test/HTMLWriter.test.js +279 -0
- package/test/Passage.test.js +104 -0
- package/test/Roundtrip/Example1.html +64 -0
- package/test/Roundtrip/example1.twee +21 -0
- package/test/Roundtrip/example2.twee +18 -0
- package/test/Roundtrip/harlowe.js +3 -0
- package/test/Roundtrip/round.html +50 -0
- package/test/Roundtrip.test.js +48 -0
- package/test/Story/startmeta.twee +29 -0
- package/test/Story/test.twee +25 -0
- package/test/Story.test.js +282 -0
- package/test/StoryFormat.test.js +152 -0
- package/test/StoryFormatParser/example.js +3 -0
- package/test/StoryFormatParser/example2.js +3 -0
- package/test/StoryFormatParser/format.js +1 -0
- package/test/StoryFormatParser/format_doublename.js +1 -0
- package/test/StoryFormatParser/harlowe.js +3 -0
- package/test/StoryFormatParser/missingAuthor.js +1 -0
- package/test/StoryFormatParser/missingDescription.js +1 -0
- package/test/StoryFormatParser/missingImage.js +1 -0
- package/test/StoryFormatParser/missingLicense.js +1 -0
- package/test/StoryFormatParser/missingName.js +1 -0
- package/test/StoryFormatParser/missingProofing.js +1 -0
- package/test/StoryFormatParser/missingSource.js +1 -0
- package/test/StoryFormatParser/missingURL.js +1 -0
- package/test/StoryFormatParser/missingVersion.js +1 -0
- package/test/StoryFormatParser/versionWrong.js +1 -0
- package/test/StoryFormatParser.test.js +91 -0
- package/test/TweeParser/emptytags.twee +2 -0
- package/test/TweeParser/example.twee +32 -0
- package/test/TweeParser/missing.twee +19 -0
- package/test/TweeParser/multipleScriptPassages.twee +19 -0
- package/test/TweeParser/multipleStyleTag.twee +19 -0
- package/test/TweeParser/multipletags.twee +10 -0
- package/test/TweeParser/noTitle.twee +2 -0
- package/test/TweeParser/notes.twee +16 -0
- package/test/TweeParser/pasagemetadataerror.twee +2 -0
- package/test/TweeParser/scriptPassage.twee +16 -0
- package/test/TweeParser/singletag.twee +13 -0
- package/test/TweeParser/startMetadata.twee +14 -0
- package/test/TweeParser/storydataerror.twee +25 -0
- package/test/TweeParser/stylePassage.twee +16 -0
- package/test/TweeParser/test.twee +25 -0
- package/test/TweeParser.test.js +79 -0
- package/test/TweeWriter/test1.twee +18 -0
- package/test/TweeWriter/test3.twee +12 -0
- package/test/TweeWriter/test4.twee +14 -0
- package/test/TweeWriter/test5.twee +20 -0
- package/test/TweeWriter.test.js +82 -0
- package/DirectoryReader.js +0 -128
- package/DirectoryWatcher.js +0 -63
- package/FileReader.js +0 -36
- package/HTMLParser.js +0 -206
- package/HTMLWriter.js +0 -177
- package/Passage.js +0 -20
- package/Story.js +0 -148
- package/StoryFormat.js +0 -41
- package/StoryFormatParser.js +0 -65
- package/TweeParser.js +0 -255
- package/TweeWriter.js +0 -111
- package/main.js +0 -103
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>twineExample</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<tw-story></tw-story>
|
|
9
|
+
<tw-storydata name="twineExample" startnode="1" creator="Twine" creator-version="2.2.1" ifid="2B68ECD6-348F-4CF5-96F8-549A512A8128" zoom="1" format="Harlowe" format-version="2.1.0" options="" hidden><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript"></script><tw-passagedata pid="1" name="Start" tags="" position="102,104" size="100,100">[[Another passage]]
|
|
10
|
+
|
|
11
|
+
[[A third passage]]</tw-passagedata><tw-passagedata pid="2" name="Another passage" tags="" position="353,60" size="100,100">[[A fourth passage]]
|
|
12
|
+
|
|
13
|
+
[[A third passage]] </tw-passagedata><tw-passagedata pid="3" name="A third passage" tags="" position="350,288" size="100,100">[[Start]]</tw-passagedata><tw-passagedata pid="4" name="A fourth passage" tags="" position="587,197" size="100,100">[[A fifth passage]]</tw-passagedata><tw-passagedata pid="5" name="A fifth passage" tags="" position="800,306" size="100,100">Double-click this passage to edit it.</tw-passagedata></tw-storydata>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
package/test/CLI.test.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import shell from 'shelljs';
|
|
2
|
+
|
|
3
|
+
// We could get this from process,
|
|
4
|
+
// but since we are using shelljs,
|
|
5
|
+
// we ask for the pwd() instead of cwd().
|
|
6
|
+
const currentPath = shell.pwd().stdout;
|
|
7
|
+
const testFilePath = currentPath + '/test/CLI';
|
|
8
|
+
|
|
9
|
+
describe('CLI', function () {
|
|
10
|
+
// Remove the test files, if they exist
|
|
11
|
+
beforeAll(function () {
|
|
12
|
+
shell.rm(`${testFilePath}/test.*`);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Test generating Twee files
|
|
16
|
+
describe('Decompile', function () {
|
|
17
|
+
test('Decompile: HTML into Twee', function () {
|
|
18
|
+
shell.exec(`node ${currentPath}/bin/extwee.js -d -i ${testFilePath}/input.html -o ${testFilePath}/test.twee`);
|
|
19
|
+
expect(shell.test('-e', `${testFilePath}/test.twee`)).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Test generating HTML files
|
|
24
|
+
describe('Compile', function () {
|
|
25
|
+
test('Compile: Twee + StoryFormat into Twee', function () {
|
|
26
|
+
shell.exec(`node ${currentPath}/bin/extwee.js -c -i ${testFilePath}/example6.twee -s ${testFilePath}/harlowe.js -o ${testFilePath}/test2.html`);
|
|
27
|
+
expect(shell.test('-e', `${testFilePath}/test2.html`)).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Gibberish
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import FileReader from '../src/FileReader.js';
|
|
2
|
+
|
|
3
|
+
describe('FileReader', function () {
|
|
4
|
+
describe('#readFile()', function () {
|
|
5
|
+
test('Should throw error if file not found', function () {
|
|
6
|
+
expect(() => { FileReader.read('test/FileReader/t2.txt'); }).toThrow();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('Should read the contents of a file', function () {
|
|
10
|
+
const fr = FileReader.read('test/FileReader/t1.txt');
|
|
11
|
+
expect(fr).toBe('Gibberish');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Example1</title>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<tw-storydata
|
|
10
|
+
name="Example1"
|
|
11
|
+
startnode="1"
|
|
12
|
+
creator="Twine"
|
|
13
|
+
creator-version="2.3.9"
|
|
14
|
+
ifid="E70FC479-01D9-4E44-AC6A-AFF9F5E1C475"
|
|
15
|
+
zoom="1"
|
|
16
|
+
format="Chapbook"
|
|
17
|
+
format-version="1.1.0"
|
|
18
|
+
options="" hidden>
|
|
19
|
+
<style
|
|
20
|
+
role="stylesheet"
|
|
21
|
+
id="twine-user-stylesheet"
|
|
22
|
+
type="text/twine-css">
|
|
23
|
+
body {
|
|
24
|
+
font-size: 1.2rem;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
<script
|
|
28
|
+
role="script"
|
|
29
|
+
id="twine-user-script"
|
|
30
|
+
type="text/twine-javascript">
|
|
31
|
+
window.setup = {};
|
|
32
|
+
</script>
|
|
33
|
+
<tw-passagedata
|
|
34
|
+
pid="1"
|
|
35
|
+
name="Untitled Passage"
|
|
36
|
+
tags=""
|
|
37
|
+
position="200,102"
|
|
38
|
+
size="100,100">[[Another passage]]</tw-passagedata>
|
|
39
|
+
<tw-passagedata
|
|
40
|
+
pid="2"
|
|
41
|
+
name="Another passage"
|
|
42
|
+
tags=""
|
|
43
|
+
position="200,252"
|
|
44
|
+
size="100,100">[[A third]]</tw-passagedata>
|
|
45
|
+
<tw-passagedata
|
|
46
|
+
pid="3"
|
|
47
|
+
name="A third"
|
|
48
|
+
tags=""
|
|
49
|
+
position="200,402"
|
|
50
|
+
size="100,100">Double-click this passage to edit it.</tw-passagedata>
|
|
51
|
+
</tw-storydata>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Tags</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<tw-story></tw-story>
|
|
9
|
+
<tw-storydata name="Tags" startnode="1" creator="Twine" creator-version="2.3.9" ifid="1A6023FC-F68A-4E55-BE9A-5EDFDB7879E6" zoom="1" format="Harlowe" format-version="3.1.0" options="" hidden>
|
|
10
|
+
<style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>
|
|
11
|
+
<script role="script" id="twine-user-script" type="text/twine-javascript"></script>
|
|
12
|
+
<tw-passagedata pid="1" name="Untitled Passage" tags="this-one another-one-like-this" position="200,99" size="100,100">Double-click this passage to edit it.</tw-passagedata>
|
|
13
|
+
</tw-storydata>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>twineExample</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<tw-story></tw-story>
|
|
9
|
+
<tw-storydata name="twineExample" startnode="99" creator="Twine" creator-version="2.2.1" ifid="2B68ECD6-348F-4CF5-96F8-549A512A8128" zoom="1" format="Harlowe" format-version="2.1.0" options="" hidden><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript"></script><tw-passagedata pid="1" name="Start" tags="" position="102,104" size="100,100">[[Another passage]]
|
|
10
|
+
|
|
11
|
+
[[A third passage]]</tw-passagedata><tw-passagedata pid="2" name="Another passage" tags="" position="353,60" size="100,100">[[A fourth passage]]
|
|
12
|
+
|
|
13
|
+
[[A third passage]] </tw-passagedata><tw-passagedata pid="3" name="A third passage" tags="" position="350,288" size="100,100">[[Start]]</tw-passagedata><tw-passagedata pid="4" name="A fourth passage" tags="" position="587,197" size="100,100">[[A fifth passage]]</tw-passagedata><tw-passagedata pid="5" name="A fifth passage" tags="" position="800,306" size="100,100">Double-click this passage to edit it.</tw-passagedata></tw-storydata>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|