extwee 2.0.6 → 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 -523
- 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/CLI/{twineExample.html → 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/{example4.twee → Files/example4.twee} +27 -27
- package/test/{StoryFormatParser → Roundtrip/Files}/harlowe.js +2 -2
- package/test/Roundtrip/{round.html → Files/round.html} +6 -4
- package/test/Roundtrip/Roundtrip.test.js +54 -0
- package/test/Story.test.js +638 -423
- 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 -4
- package/test/{CLI → Twine2HTML/Twine2HTMLCompiler}/example6.twee +15 -15
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/missingStoryTitle.twee +29 -29
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test2.html +10 -8
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test3.html +1 -1
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test4.html +4 -4
- 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/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample.html +23 -23
- 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 -345
- package/src/HTMLWriter.js +0 -231
- package/src/StoryFormatParser.js +0 -142
- package/src/TweeParser.js +0 -161
- package/src/TweeWriter.js +0 -121
- 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 -45
- 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 -287
- 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/test6.twee +0 -15
- package/test/TweeWriter/test7.twee +0 -15
- package/test/TweeWriter.test.js +0 -107
- /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/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test11.html +0 -0
- /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test6.html +0 -0
- /package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/tagColors.html +0 -0
package/test/CLI.test.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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', () => {
|
|
10
|
-
// Remove the test files, if they exist
|
|
11
|
-
beforeAll(() => {
|
|
12
|
-
shell.rm(`${testFilePath}/test.*`);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// Test generating Twee files
|
|
16
|
-
describe('Decompile', () => {
|
|
17
|
-
it('Decompile: HTML into Twee', () => {
|
|
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', () => {
|
|
25
|
-
it('Compile: Twee + StoryFormat into Twee', () => {
|
|
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
|
-
});
|
package/test/FileReader/t1.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Gibberish
|
package/test/FileReader.test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import FileReader from '../src/FileReader.js';
|
|
2
|
-
|
|
3
|
-
describe('FileReader', () => {
|
|
4
|
-
describe('#readFile()', () => {
|
|
5
|
-
it('Should throw error if file not found', () => {
|
|
6
|
-
expect(() => { FileReader.read('test/FileReader/t2.txt'); }).toThrow();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('Should read the contents of a file', () => {
|
|
10
|
-
const fr = FileReader.read('test/FileReader/t1.txt');
|
|
11
|
-
expect(fr).toBe('Gibberish');
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
});
|
package/test/HTMLParser.test.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import FileReader from '../src/FileReader.js';
|
|
2
|
-
import HTMLParser from '../src/HTMLParser.js';
|
|
3
|
-
|
|
4
|
-
// Pull the name and version of this project from package.json.
|
|
5
|
-
// These are used as the 'creator' and 'creator-version'.
|
|
6
|
-
const { version } = JSON.parse(FileReader.read('package.json'));
|
|
7
|
-
|
|
8
|
-
describe('HTMLParser', () => {
|
|
9
|
-
describe('#parse()', () => {
|
|
10
|
-
it('Should throw error if content is not Twine-2 style HTML', () => {
|
|
11
|
-
expect(() => { HTMLParser.parse(''); }).toThrow();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('Should be able to parse Twine 2 HTML for story name', () => {
|
|
15
|
-
const fr = FileReader.read('test/HTMLParser/twineExample.html');
|
|
16
|
-
const story = HTMLParser.parse(fr);
|
|
17
|
-
const storyTitle = story.getPassageByName('StoryTitle');
|
|
18
|
-
expect(storyTitle.text).toBe('twineExample');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('Should be able to parse Twine 2 HTML for correct number of passages', () => {
|
|
22
|
-
const fr = FileReader.read('test/HTMLParser/twineExample.html');
|
|
23
|
-
const tp = HTMLParser.parse(fr);
|
|
24
|
-
expect(tp.size()).toBe(5);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('Should be able to correctly parse passage tags', () => {
|
|
28
|
-
const fr = FileReader.read('test/HTMLParser/Tags.html');
|
|
29
|
-
const story = HTMLParser.parse(fr);
|
|
30
|
-
const p = story.getPassageByName('Untitled Passage');
|
|
31
|
-
expect(p.tags).toHaveLength(2);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('Should set a missing name to Untitled', () => {
|
|
35
|
-
const fr = FileReader.read('test/HTMLParser/missingName.html');
|
|
36
|
-
const story = HTMLParser.parse(fr);
|
|
37
|
-
const p = story.getPassageByName('StoryTitle');
|
|
38
|
-
expect(p.text).toBe('Untitled');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('Should set a missing IFID to an empty string', () => {
|
|
42
|
-
const fr = FileReader.read('test/HTMLParser/missingIFID.html');
|
|
43
|
-
const tp = HTMLParser.parse(fr);
|
|
44
|
-
expect(tp.IFID).toBe('');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('Should have Extwee for creator when missing', () => {
|
|
48
|
-
const fr = FileReader.read('test/HTMLParser/missingCreator.html');
|
|
49
|
-
const tp = HTMLParser.parse(fr);
|
|
50
|
-
expect(tp.creator).toBe('extwee');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('Should have correct for creatorVersion when missing', () => {
|
|
54
|
-
const fr = FileReader.read('test/HTMLParser/missingCreatorVersion.html');
|
|
55
|
-
const tp = HTMLParser.parse(fr);
|
|
56
|
-
expect(tp.creatorVersion).toBe(version);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('Should have empty string as format when missing', () => {
|
|
60
|
-
const fr = FileReader.read('test/HTMLParser/missingFormat.html');
|
|
61
|
-
const tp = HTMLParser.parse(fr);
|
|
62
|
-
expect(tp.format).toBe('');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('Should have empty string as formatVersion when missing', () => {
|
|
66
|
-
const fr = FileReader.read('test/HTMLParser/missingFormatVersion.html');
|
|
67
|
-
const tp = HTMLParser.parse(fr);
|
|
68
|
-
expect(tp.formatVersion).toBe('');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('Should have empty string as zoom when missing', () => {
|
|
72
|
-
const fr = FileReader.read('test/HTMLParser/missingZoom.html');
|
|
73
|
-
const tp = HTMLParser.parse(fr);
|
|
74
|
-
expect(tp.zoom).toBe(0);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('Should not have position if passage does not', () => {
|
|
78
|
-
const fr = FileReader.read('test/HTMLParser/missingPosition.html');
|
|
79
|
-
const story = HTMLParser.parse(fr);
|
|
80
|
-
const p = story.getPassageByName('Untitled Passage');
|
|
81
|
-
expect(Object.prototype.hasOwnProperty.call(p.metadata, 'position')).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('Should not have size if passage does not', () => {
|
|
85
|
-
const fr = FileReader.read('test/HTMLParser/missingSize.html');
|
|
86
|
-
const story = HTMLParser.parse(fr);
|
|
87
|
-
const p = story.getPassageByName('Untitled Passage');
|
|
88
|
-
expect(Object.prototype.hasOwnProperty.call(p.metadata, 'size')).toBe(false);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('Should have empty array as tags if tags is missing', () => {
|
|
92
|
-
const fr = FileReader.read('test/HTMLParser/missingPassageTags.html');
|
|
93
|
-
const story = HTMLParser.parse(fr);
|
|
94
|
-
const p = story.getPassageByName('Untitled Passage');
|
|
95
|
-
expect(p.tags).toHaveLength(0);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('Should not have stylesheet tag if no passages exist with it', () => {
|
|
99
|
-
const fr = FileReader.read('test/HTMLParser/missingStyle.html');
|
|
100
|
-
const story = HTMLParser.parse(fr);
|
|
101
|
-
const passages = story.getPassagesByTag('stylesheet');
|
|
102
|
-
expect(passages.length).toBe(0);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('Should not have script tag if no passages exist with it', () => {
|
|
106
|
-
const fr = FileReader.read('test/HTMLParser/missingScript.html');
|
|
107
|
-
const story = HTMLParser.parse(fr);
|
|
108
|
-
const passages = story.getPassagesByTag('script');
|
|
109
|
-
expect(passages.length).toBe(0);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('Should have script and style tags normally', () => {
|
|
113
|
-
const fr = FileReader.read('test/HTMLParser/Example1.html');
|
|
114
|
-
const story = HTMLParser.parse(fr);
|
|
115
|
-
const scriptPassages = story.getPassagesByTag('script');
|
|
116
|
-
const stylesheetPassages = story.getPassagesByTag('stylesheet');
|
|
117
|
-
expect(scriptPassages.length).toBe(1);
|
|
118
|
-
expect(stylesheetPassages.length).toBe(1);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('Should not have start property if startNode does not exist when parsed', () => {
|
|
122
|
-
const fr = FileReader.read('test/HTMLParser/missingStartnode.html');
|
|
123
|
-
const story = HTMLParser.parse(fr);
|
|
124
|
-
expect(story.start).toBe('');
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('Should not add passages without names', () => {
|
|
128
|
-
const fr = FileReader.read('test/HTMLParser/missingPassageName.html');
|
|
129
|
-
const story = HTMLParser.parse(fr);
|
|
130
|
-
// There is only one passage, StoryTitle
|
|
131
|
-
expect(story.size()).toBe(0);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('Should not add passages without PID', () => {
|
|
135
|
-
const fr = FileReader.read('test/HTMLParser/missingPID.html');
|
|
136
|
-
const story = HTMLParser.parse(fr);
|
|
137
|
-
// There is only one passage, StoryTitle
|
|
138
|
-
expect(story.size()).toBe(0);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('Parse tag colors', () => {
|
|
142
|
-
const fr = FileReader.read('test/HTMLParser/tagColors.html');
|
|
143
|
-
const story = HTMLParser.parse(fr);
|
|
144
|
-
// Test for tag colors
|
|
145
|
-
const tagColors = story.tagColors;
|
|
146
|
-
expect(tagColors.a).toBe('red');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('Will not set start if startnode is missing', () => {
|
|
150
|
-
const fr = FileReader.read('test/HTMLParser/missingStartnode.html');
|
|
151
|
-
const story = HTMLParser.parse(fr);
|
|
152
|
-
// Test for default start
|
|
153
|
-
expect(story.start).toBe('');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('Throw error when startnode has PID that does not exist', () => {
|
|
157
|
-
const fr = FileReader.read('test/HTMLParser/lyingStartnode.html');
|
|
158
|
-
expect(() => {
|
|
159
|
-
HTMLParser.parse(fr);
|
|
160
|
-
}).toThrow();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('Do not update name and color if those attributes do not exist', () => {
|
|
164
|
-
const fr = FileReader.read('test/HTMLParser/lyingTagColors.html');
|
|
165
|
-
const story = HTMLParser.parse(fr);
|
|
166
|
-
const tagColorProperties = Object.keys(story.tagColors).length;
|
|
167
|
-
expect(tagColorProperties).toBe(0);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
describe('#escapeMetacharacters()', () => {
|
|
172
|
-
it('Should escape metacharacters', () => {
|
|
173
|
-
/* eslint no-useless-escape: "off" */
|
|
174
|
-
expect(HTMLParser.escapeMetacharacters('\\\{\\\}\\\[\\\]\\\\')).toBe('\\\\{\\\\}\\\\[\\\\]\\\\');
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
:: StoryTitle
|
|
2
|
-
twineExample
|
|
3
|
-
|
|
4
|
-
:: Start [tag tags] {"position": "200,200", "size": "100,100"}
|
|
5
|
-
Content
|
|
6
|
-
|
|
7
|
-
:: Style1 [stylesheet]
|
|
8
|
-
body {background-color: green;}
|
|
9
|
-
|
|
10
|
-
:: StoryData
|
|
11
|
-
{
|
|
12
|
-
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
-
"format": "Harlowe",
|
|
14
|
-
"formatVersion": "2.1.0",
|
|
15
|
-
"zoom": "1"
|
|
16
|
-
}
|
package/test/HTMLWriter.test.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import FileReader from '../src/FileReader.js';
|
|
2
|
-
import StoryFormatParser from '../src/StoryFormatParser.js';
|
|
3
|
-
import HTMLParser from '../src/HTMLParser.js';
|
|
4
|
-
import TweeParser from '../src/TweeParser.js';
|
|
5
|
-
import HTMLWriter from '../src/HTMLWriter.js';
|
|
6
|
-
import Story from '../src/Story.js';
|
|
7
|
-
import Passage from '../src/Passage.js';
|
|
8
|
-
|
|
9
|
-
describe('HTMLWriter', () => {
|
|
10
|
-
describe('#write()', () => {
|
|
11
|
-
it('story should be instanceof Story', () => {
|
|
12
|
-
expect(() => { HTMLWriter.write('test/HTMLWriter/test.html', {}); }).toThrow();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('storyFormat should be instanceof StoryFormat', () => {
|
|
16
|
-
const s = new Story();
|
|
17
|
-
expect(() => { HTMLWriter.write('test/HTMLWriter/test.html', s, {}); }).toThrow();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('Read, write, and read HTML', () => {
|
|
21
|
-
// Read HTML.
|
|
22
|
-
const fr = FileReader.read('test/HTMLParser/twineExample3.html');
|
|
23
|
-
// Parse HTML.
|
|
24
|
-
const story = HTMLParser.parse(fr);
|
|
25
|
-
|
|
26
|
-
const s1Title = story.getPassageByName('StoryTitle').text;
|
|
27
|
-
|
|
28
|
-
// Read StoryFormat.
|
|
29
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
30
|
-
// Parse StoryFormat.
|
|
31
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
32
|
-
|
|
33
|
-
// Write HTML.
|
|
34
|
-
HTMLWriter.write('test/HTMLWriter/test2.html', story, storyFormat);
|
|
35
|
-
|
|
36
|
-
// Read HTML.
|
|
37
|
-
const fr3 = FileReader.read('test/HTMLWriter/test2.html');
|
|
38
|
-
// Parse HTML.
|
|
39
|
-
const story2 = HTMLParser.parse(fr3);
|
|
40
|
-
|
|
41
|
-
// Test both names to be the same.
|
|
42
|
-
expect(s1Title).toBe(story2.name);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('Should write one and two-tag passages', () => {
|
|
46
|
-
// Read HTML.
|
|
47
|
-
const fr = FileReader.read('test/HTMLWriter/TestTags.html');
|
|
48
|
-
// Parse HTML.
|
|
49
|
-
const story = HTMLParser.parse(fr);
|
|
50
|
-
|
|
51
|
-
// Read StoryFormat.
|
|
52
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
53
|
-
// Parse StoryFormat.
|
|
54
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
55
|
-
|
|
56
|
-
// Write HTML.
|
|
57
|
-
HTMLWriter.write('test/HTMLWriter/test3.html', story, storyFormat);
|
|
58
|
-
|
|
59
|
-
// Read HTML.
|
|
60
|
-
const fr3 = FileReader.read('test/HTMLWriter/test3.html');
|
|
61
|
-
// Parse HTML.
|
|
62
|
-
const story2 = HTMLParser.parse(fr3);
|
|
63
|
-
|
|
64
|
-
let tags = '';
|
|
65
|
-
let tags2 = '';
|
|
66
|
-
|
|
67
|
-
// Combine contents of tags.
|
|
68
|
-
story.forEach((p) => {
|
|
69
|
-
tags += p.tags.join('');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Combine contents of tags.
|
|
73
|
-
story2.forEach((p) => {
|
|
74
|
-
tags2 += p.tags.join('');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Test combination tags.
|
|
78
|
-
// They should be the same.
|
|
79
|
-
expect(tags).toBe(tags2);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('Should throw error if file path invalid', () => {
|
|
83
|
-
// Read HTML.
|
|
84
|
-
const fr = FileReader.read('test/HTMLParser/twineExample3.html');
|
|
85
|
-
// Parse HTML.
|
|
86
|
-
const story = HTMLParser.parse(fr);
|
|
87
|
-
|
|
88
|
-
// Read StoryFormat.
|
|
89
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
90
|
-
// Parse StoryFormat.
|
|
91
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
92
|
-
|
|
93
|
-
// Throw error if path is invalid.
|
|
94
|
-
expect(() => {
|
|
95
|
-
HTMLWriter.write('test2/HTMLWriter/test2.html', story, storyFormat);
|
|
96
|
-
}).toThrow();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('Should not add optional position to passages', () => {
|
|
100
|
-
// Create Story.
|
|
101
|
-
const story = new Story();
|
|
102
|
-
// Add passage.
|
|
103
|
-
story.addPassage(new Passage('A'));
|
|
104
|
-
// Add passage.
|
|
105
|
-
story.addPassage(new Passage('B'));
|
|
106
|
-
// Add StoryTitle
|
|
107
|
-
story.addPassage(new Passage('StoryTitle', 'Title'));
|
|
108
|
-
// Add Start
|
|
109
|
-
story.addPassage(new Passage('Start', 'Content'));
|
|
110
|
-
|
|
111
|
-
// Read StoryFormat.
|
|
112
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
113
|
-
// Parse StoryFormat.
|
|
114
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
115
|
-
|
|
116
|
-
// Write out HTML with story and storyFormat.
|
|
117
|
-
// (Will add position to passages without them.)
|
|
118
|
-
HTMLWriter.write('test/HTMLWriter/test4.html', story, storyFormat);
|
|
119
|
-
|
|
120
|
-
// Read new HTML file.
|
|
121
|
-
const fr3 = FileReader.read('test/HTMLWriter/test4.html');
|
|
122
|
-
// Parse new HTML file.
|
|
123
|
-
const story2 = HTMLParser.parse(fr3);
|
|
124
|
-
|
|
125
|
-
// Verify none of the directly created passages have position.
|
|
126
|
-
story.forEach((passage) => {
|
|
127
|
-
expect(Object.prototype.hasOwnProperty.call(passage.metadata, 'position')).toBe(false);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Verify none parsed passages have position.
|
|
131
|
-
story2.forEach((passage) => {
|
|
132
|
-
expect(Object.prototype.hasOwnProperty.call(passage.metadata, 'position')).toBe(false);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("Don't write creator if missing originally", () => {
|
|
137
|
-
// Create a new story.
|
|
138
|
-
const story = new Story();
|
|
139
|
-
|
|
140
|
-
// Create a passage.
|
|
141
|
-
story.addPassage(new Passage('A'));
|
|
142
|
-
|
|
143
|
-
// Create another passage.
|
|
144
|
-
story.addPassage(new Passage('B'));
|
|
145
|
-
|
|
146
|
-
// Create another passage.
|
|
147
|
-
story.addPassage(new Passage('StoryTitle', 'Title'));
|
|
148
|
-
|
|
149
|
-
// Add Start
|
|
150
|
-
story.addPassage(new Passage('Start', 'Content'));
|
|
151
|
-
|
|
152
|
-
// Read StoryFormat.
|
|
153
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
154
|
-
// Parse StoryFormat.
|
|
155
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
156
|
-
|
|
157
|
-
// Write the HTML.
|
|
158
|
-
HTMLWriter.write('test/HTMLWriter/creator.html', story, storyFormat);
|
|
159
|
-
|
|
160
|
-
// Read HTML.
|
|
161
|
-
const fr3 = FileReader.read('test/HTMLWriter/creator.html');
|
|
162
|
-
// Parse HTML.
|
|
163
|
-
const story2 = HTMLParser.parse(fr3);
|
|
164
|
-
|
|
165
|
-
// Test creator (should be default)
|
|
166
|
-
expect(story.creator).toBe('extwee');
|
|
167
|
-
|
|
168
|
-
// Test parsed creator (should be default)
|
|
169
|
-
expect(story2.creator).toBe('extwee');
|
|
170
|
-
|
|
171
|
-
// Creator should be the same
|
|
172
|
-
expect(story.creator).toBe(story2.creator);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('Throw error if StoryTitle does not exist', () => {
|
|
176
|
-
// Create a new story.
|
|
177
|
-
const story = new Story();
|
|
178
|
-
|
|
179
|
-
// Create a passage.
|
|
180
|
-
story.addPassage(new Passage('A'));
|
|
181
|
-
|
|
182
|
-
// Read StoryFormat.
|
|
183
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
184
|
-
// Parse StoryFormat.
|
|
185
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
186
|
-
|
|
187
|
-
expect(() => {
|
|
188
|
-
HTMLWriter.write('test', story, storyFormat);
|
|
189
|
-
}).toThrow();
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('Throw error if no start or Start exists', () => {
|
|
193
|
-
// Create a new story.
|
|
194
|
-
const story = new Story();
|
|
195
|
-
|
|
196
|
-
// Create a passage.
|
|
197
|
-
story.addPassage(new Passage('A'));
|
|
198
|
-
|
|
199
|
-
// Create StoryTitle
|
|
200
|
-
story.addPassage(new Passage('StoryTitle', 'Name'));
|
|
201
|
-
|
|
202
|
-
// Read StoryFormat.
|
|
203
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
204
|
-
// Parse StoryFormat.
|
|
205
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
206
|
-
|
|
207
|
-
// Throws error
|
|
208
|
-
expect(() => {
|
|
209
|
-
HTMLWriter.write('test/HTMLWriter/test6.html', story, storyFormat);
|
|
210
|
-
}).toThrow();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('Write with Start without start', () => {
|
|
214
|
-
// Create a new story.
|
|
215
|
-
const story = new Story();
|
|
216
|
-
|
|
217
|
-
// Create a passage.
|
|
218
|
-
story.addPassage(new Passage('A'));
|
|
219
|
-
|
|
220
|
-
// Create StoryTitle
|
|
221
|
-
story.addPassage(new Passage('StoryTitle', 'Name'));
|
|
222
|
-
|
|
223
|
-
// Create Start
|
|
224
|
-
story.addPassage(new Passage('Start', 'Content'));
|
|
225
|
-
|
|
226
|
-
// Read StoryFormat.
|
|
227
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
228
|
-
// Parse StoryFormat.
|
|
229
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
230
|
-
|
|
231
|
-
// Write file
|
|
232
|
-
HTMLWriter.write('test/HTMLWriter/test6.html', story, storyFormat);
|
|
233
|
-
|
|
234
|
-
// Read new HTML file.
|
|
235
|
-
const fr3 = FileReader.read('test/HTMLWriter/test6.html');
|
|
236
|
-
// Parse new HTML file.
|
|
237
|
-
const story2 = HTMLParser.parse(fr3);
|
|
238
|
-
|
|
239
|
-
// Should not be start
|
|
240
|
-
expect(story2.start).toBe('Start');
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('Throw error if starting passage property does not exist', () => {
|
|
244
|
-
// Create a new story.
|
|
245
|
-
const story = new Story();
|
|
246
|
-
|
|
247
|
-
// Create a passage.
|
|
248
|
-
story.addPassage(new Passage('A'));
|
|
249
|
-
|
|
250
|
-
// Create StoryTitle
|
|
251
|
-
story.addPassage(new Passage('StoryTitle', 'Name'));
|
|
252
|
-
|
|
253
|
-
// Set a passage that doesn't exist
|
|
254
|
-
story.start = 'Nope';
|
|
255
|
-
|
|
256
|
-
// Read StoryFormat.
|
|
257
|
-
const fr2 = FileReader.read('test/StoryFormatParser/format.js');
|
|
258
|
-
// Parse StoryFormat.
|
|
259
|
-
const storyFormat = StoryFormatParser.parse(fr2);
|
|
260
|
-
|
|
261
|
-
// Throws error
|
|
262
|
-
expect(() => {
|
|
263
|
-
HTMLWriter.write('test/HTMLWriter/test7.html', story, storyFormat);
|
|
264
|
-
}).toThrow();
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('Should correctly replace all instances of STORY_NAME', () => {
|
|
268
|
-
const fr = FileReader.read('test/HTMLWriter/example6.twee');
|
|
269
|
-
const story = TweeParser.parse(fr);
|
|
270
|
-
const storyFormatFile = FileReader.read('test/StoryFormatParser/format_doublename.js');
|
|
271
|
-
const sfp = StoryFormatParser.parse(storyFormatFile);
|
|
272
|
-
HTMLWriter.write('test/HTMLWriter/test11.html', story, sfp);
|
|
273
|
-
const frh = FileReader.read('test/HTMLWriter/test11.html');
|
|
274
|
-
expect(frh.indexOf('STORY_NAME')).toBe(-1);
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
describe('escape()', () => {
|
|
279
|
-
it('Should throw error if argument is not string', () => {
|
|
280
|
-
expect(() => { HTMLWriter.escape(1); }).toThrow();
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('Should escape HTML sequences', () => {
|
|
284
|
-
expect(HTMLWriter.escape('<script>alert("Hi!");</script>')).toBe('<script>alert("Hi!");</script>');
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
:: StoryData
|
|
2
|
-
{
|
|
3
|
-
"ifid": "E70FC479-01D9-4E44-AC6A-AFF9F5E1C475",
|
|
4
|
-
"format": "Chapbook",
|
|
5
|
-
"format-version": "1.1.0",
|
|
6
|
-
"zoom": 1,
|
|
7
|
-
"start": "StoryTitle"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
:: StoryTitle
|
|
11
|
-
Example1
|
|
12
|
-
|
|
13
|
-
:: Untitled Passage {"position":"200,102","size":"100,100"}
|
|
14
|
-
[[Another passage]]
|
|
15
|
-
|
|
16
|
-
:: Another passage {"position":"200,252","size":"100,100"}
|
|
17
|
-
[[A third]]
|
|
18
|
-
|
|
19
|
-
:: A third {"position":"200,402","size":"100,100"}
|
|
20
|
-
Double-click this passage to edit it.
|
|
21
|
-
|
package/test/Roundtrip.test.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import TweeWriter from '../src/TweeWriter.js';
|
|
2
|
-
import FileReader from '../src/FileReader.js';
|
|
3
|
-
import TweeParser from '../src/TweeParser.js';
|
|
4
|
-
import HTMLParser from '../src/HTMLParser.js';
|
|
5
|
-
import StoryFormatParser from '../src/StoryFormatParser.js';
|
|
6
|
-
import HTMLWriter from '../src/HTMLWriter.js';
|
|
7
|
-
|
|
8
|
-
describe('Round-trip testing', () => {
|
|
9
|
-
it('Should round-trip HTML-to-Twee', () => {
|
|
10
|
-
// Read HTML
|
|
11
|
-
const fr = FileReader.read('test/Roundtrip/Example1.html');
|
|
12
|
-
// Parse HTML
|
|
13
|
-
const s = HTMLParser.parse(fr);
|
|
14
|
-
// Write Story into Twee
|
|
15
|
-
TweeWriter.write(s, 'test/Roundtrip/example1.twee');
|
|
16
|
-
// Read new Twee file
|
|
17
|
-
const fr2 = FileReader.read('test/Roundtrip/example1.twee');
|
|
18
|
-
// Parse the new Twee
|
|
19
|
-
const s2 = TweeParser.parse(fr2);
|
|
20
|
-
// Number of passages should be the same, too
|
|
21
|
-
expect(s2.size()).toBe(s.size());
|
|
22
|
-
// IFID should be the same
|
|
23
|
-
expect(s.ifid).toBe(s2.ifid);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('Should round-trip Twee-to-HTML', () => {
|
|
27
|
-
// Read StoryFormat
|
|
28
|
-
const storyFormat = FileReader.read('test/Roundtrip/harlowe.js');
|
|
29
|
-
// Parse StoryFormat
|
|
30
|
-
const sfp = StoryFormatParser.parse(storyFormat);
|
|
31
|
-
// Read Twee
|
|
32
|
-
const fr = FileReader.read('test/Roundtrip/example2.twee');
|
|
33
|
-
// Parse Twee
|
|
34
|
-
const story = TweeParser.parse(fr);
|
|
35
|
-
// Write HTML
|
|
36
|
-
HTMLWriter.write('test/Roundtrip/round.html', story, sfp);
|
|
37
|
-
// Read HTML
|
|
38
|
-
const fr2 = FileReader.read('test/Roundtrip/round.html');
|
|
39
|
-
// Parse HTML
|
|
40
|
-
const story2 = HTMLParser.parse(fr2);
|
|
41
|
-
// Number of passages should be the same, too
|
|
42
|
-
expect(story2.size()).toBe(story.size());
|
|
43
|
-
// IFID should be the same
|
|
44
|
-
expect(story.ifid).toBe(story2.ifid);
|
|
45
|
-
// Should have same 'start' name
|
|
46
|
-
expect(story.start).toBe(story2.start);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
:: StoryTitle
|
|
2
|
-
twineExample
|
|
3
|
-
|
|
4
|
-
:: Another
|
|
5
|
-
This should be the start passage!
|
|
6
|
-
|
|
7
|
-
:: Start
|
|
8
|
-
Some content.
|
|
9
|
-
|
|
10
|
-
:: StoryData
|
|
11
|
-
{
|
|
12
|
-
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
-
"format": "Harlowe",
|
|
14
|
-
"formatVersion": "2.1.0",
|
|
15
|
-
"zoom": "1",
|
|
16
|
-
"start": "Another"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
:: Script1 [script]
|
|
20
|
-
// Some code
|
|
21
|
-
|
|
22
|
-
:: Script2 [script]
|
|
23
|
-
//More code here!
|
|
24
|
-
|
|
25
|
-
:: Style1 [stylesheet]
|
|
26
|
-
body {font-size: 1.2em}
|
|
27
|
-
|
|
28
|
-
:: Style2 [stylesheet]
|
|
29
|
-
p {font-style: italic;}
|