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
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
These are some notes at the top of the file
|
|
3
|
-
*/
|
|
4
|
-
:: StoryTitle
|
|
5
|
-
twineExample
|
|
6
|
-
|
|
7
|
-
:: Start {"position":"102,104","size":"100,100"}
|
|
8
|
-
Start passage
|
|
9
|
-
|
|
10
|
-
:: StoryData
|
|
11
|
-
{
|
|
12
|
-
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
-
"format": "Harlowe",
|
|
14
|
-
"formatVersion": "2.1.0",
|
|
15
|
-
"zoom": "1"
|
|
16
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
These are some notes at the top of the file
|
|
3
|
+
*/
|
|
4
|
+
:: StoryTitle
|
|
5
|
+
twineExample
|
|
6
|
+
|
|
7
|
+
:: Start {"position":"102,104","size":"100,100"}
|
|
8
|
+
Start passage
|
|
9
|
+
|
|
10
|
+
:: StoryData
|
|
11
|
+
{
|
|
12
|
+
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
+
"format": "Harlowe",
|
|
14
|
+
"formatVersion": "2.1.0",
|
|
15
|
+
"zoom": "1"
|
|
16
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
:: Start {"position}
|
|
2
|
-
Some content
|
|
1
|
+
:: Start {"position}
|
|
2
|
+
Some content
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
:: Start
|
|
2
|
-
Content
|
|
3
|
-
|
|
4
|
-
:: StoryTitle
|
|
5
|
-
Title
|
|
6
|
-
|
|
7
|
-
:: UserScript [script]
|
|
8
|
-
window.example = {}
|
|
9
|
-
|
|
10
|
-
:: StoryData
|
|
11
|
-
{
|
|
12
|
-
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
-
"format": "Harlowe",
|
|
14
|
-
"formatVersion": "2.1.0",
|
|
15
|
-
"zoom": "1"
|
|
16
|
-
}
|
|
1
|
+
:: Start
|
|
2
|
+
Content
|
|
3
|
+
|
|
4
|
+
:: StoryTitle
|
|
5
|
+
Title
|
|
6
|
+
|
|
7
|
+
:: UserScript [script]
|
|
8
|
+
window.example = {}
|
|
9
|
+
|
|
10
|
+
:: StoryData
|
|
11
|
+
{
|
|
12
|
+
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
+
"format": "Harlowe",
|
|
14
|
+
"formatVersion": "2.1.0",
|
|
15
|
+
"zoom": "1"
|
|
16
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
:: Start [tag]
|
|
2
|
-
Content
|
|
3
|
-
|
|
4
|
-
:: StoryTitle
|
|
5
|
-
Title
|
|
6
|
-
|
|
7
|
-
:: StoryData
|
|
8
|
-
{
|
|
9
|
-
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
10
|
-
"format": "Harlowe",
|
|
11
|
-
"formatVersion": "2.1.0",
|
|
12
|
-
"zoom": "1"
|
|
13
|
-
}
|
|
1
|
+
:: Start [tag]
|
|
2
|
+
Content
|
|
3
|
+
|
|
4
|
+
:: StoryTitle
|
|
5
|
+
Title
|
|
6
|
+
|
|
7
|
+
:: StoryData
|
|
8
|
+
{
|
|
9
|
+
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
10
|
+
"format": "Harlowe",
|
|
11
|
+
"formatVersion": "2.1.0",
|
|
12
|
+
"zoom": "1"
|
|
13
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
:: StoryTitle
|
|
2
|
-
Example
|
|
3
|
-
|
|
4
|
-
:: StoryData
|
|
5
|
-
{
|
|
6
|
-
"ifid": "A74F654F-3F85-44DE-8A87-9845AECD04B0",
|
|
7
|
-
"format": "Harlowe",
|
|
8
|
-
"formatVersion": "3.2.1",
|
|
9
|
-
"zoom": "1",
|
|
10
|
-
"start": "Untitled Passage"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
:: Untitled Passage {"position":"100,99","size":"100,100"}
|
|
14
|
-
Double-click this passage to edit it.
|
|
1
|
+
:: StoryTitle
|
|
2
|
+
Example
|
|
3
|
+
|
|
4
|
+
:: StoryData
|
|
5
|
+
{
|
|
6
|
+
"ifid": "A74F654F-3F85-44DE-8A87-9845AECD04B0",
|
|
7
|
+
"format": "Harlowe",
|
|
8
|
+
"formatVersion": "3.2.1",
|
|
9
|
+
"zoom": "1",
|
|
10
|
+
"start": "Untitled Passage"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:: Untitled Passage {"position":"100,99","size":"100,100"}
|
|
14
|
+
Double-click this passage to edit it.
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
:: StoryTitle
|
|
2
|
-
twineExample
|
|
3
|
-
|
|
4
|
-
:: Start
|
|
5
|
-
Some content.
|
|
6
|
-
|
|
7
|
-
:: StoryData
|
|
8
|
-
{
|
|
9
|
-
"ifid": 2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
10
|
-
"format": "Harlowe",
|
|
11
|
-
"formatVersion": "2.1.0",
|
|
12
|
-
"zoom": "1"
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
:: Script1 [script]
|
|
16
|
-
// Some code
|
|
17
|
-
|
|
18
|
-
:: Script2 [script]
|
|
19
|
-
//More code here!
|
|
20
|
-
|
|
21
|
-
:: Style1 [stylesheet]
|
|
22
|
-
body {font-size: 1.2em}
|
|
23
|
-
|
|
24
|
-
:: Style2 [stylesheet]
|
|
25
|
-
p {font-style: italic;}
|
|
1
|
+
:: StoryTitle
|
|
2
|
+
twineExample
|
|
3
|
+
|
|
4
|
+
:: Start
|
|
5
|
+
Some content.
|
|
6
|
+
|
|
7
|
+
:: StoryData
|
|
8
|
+
{
|
|
9
|
+
"ifid": 2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
10
|
+
"format": "Harlowe",
|
|
11
|
+
"formatVersion": "2.1.0",
|
|
12
|
+
"zoom": "1"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:: Script1 [script]
|
|
16
|
+
// Some code
|
|
17
|
+
|
|
18
|
+
:: Script2 [script]
|
|
19
|
+
//More code here!
|
|
20
|
+
|
|
21
|
+
:: Style1 [stylesheet]
|
|
22
|
+
body {font-size: 1.2em}
|
|
23
|
+
|
|
24
|
+
:: Style2 [stylesheet]
|
|
25
|
+
p {font-style: italic;}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
:: Start
|
|
2
|
-
Content
|
|
3
|
-
|
|
4
|
-
:: StoryTitle
|
|
5
|
-
Title
|
|
6
|
-
|
|
7
|
-
:: UserStylesheet [stylesheet]
|
|
8
|
-
1
|
|
9
|
-
|
|
10
|
-
:: StoryData
|
|
11
|
-
{
|
|
12
|
-
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
-
"format": "Harlowe",
|
|
14
|
-
"formatVersion": "2.1.0",
|
|
15
|
-
"zoom": "1"
|
|
16
|
-
}
|
|
1
|
+
:: Start
|
|
2
|
+
Content
|
|
3
|
+
|
|
4
|
+
:: StoryTitle
|
|
5
|
+
Title
|
|
6
|
+
|
|
7
|
+
:: UserStylesheet [stylesheet]
|
|
8
|
+
1
|
|
9
|
+
|
|
10
|
+
:: StoryData
|
|
11
|
+
{
|
|
12
|
+
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
13
|
+
"format": "Harlowe",
|
|
14
|
+
"formatVersion": "2.1.0",
|
|
15
|
+
"zoom": "1"
|
|
16
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
:: StoryTitle
|
|
2
|
-
twineExample
|
|
3
|
-
|
|
4
|
-
:: Start
|
|
5
|
-
Some content.
|
|
6
|
-
|
|
7
|
-
:: StoryData
|
|
8
|
-
{
|
|
9
|
-
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
10
|
-
"format": "Harlowe",
|
|
11
|
-
"formatVersion": "2.1.0",
|
|
12
|
-
"zoom": "1"
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
:: Script1 [script]
|
|
16
|
-
// Some code
|
|
17
|
-
|
|
18
|
-
:: Script2 [script]
|
|
19
|
-
//More code here!
|
|
20
|
-
|
|
21
|
-
:: Style1 [stylesheet]
|
|
22
|
-
body {font-size: 1.2em}
|
|
23
|
-
|
|
24
|
-
:: Style2 [stylesheet]
|
|
25
|
-
p {font-style: italic;}
|
|
1
|
+
:: StoryTitle
|
|
2
|
+
twineExample
|
|
3
|
+
|
|
4
|
+
:: Start
|
|
5
|
+
Some content.
|
|
6
|
+
|
|
7
|
+
:: StoryData
|
|
8
|
+
{
|
|
9
|
+
"ifid": "2B68ECD6-348F-4CF5-96F8-549A512A8128",
|
|
10
|
+
"format": "Harlowe",
|
|
11
|
+
"formatVersion": "2.1.0",
|
|
12
|
+
"zoom": "1"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:: Script1 [script]
|
|
16
|
+
// Some code
|
|
17
|
+
|
|
18
|
+
:: Script2 [script]
|
|
19
|
+
//More code here!
|
|
20
|
+
|
|
21
|
+
:: Style1 [stylesheet]
|
|
22
|
+
body {font-size: 1.2em}
|
|
23
|
+
|
|
24
|
+
:: Style2 [stylesheet]
|
|
25
|
+
p {font-style: italic;}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { compile as compileTwine1HTML } from '../../src/Twine1HTML/compile.js';
|
|
2
|
+
import Story from '../../src/Story.js';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import Passage from '../../src/Passage.js';
|
|
5
|
+
|
|
6
|
+
describe('Twine1HTMLCompiler', () => {
|
|
7
|
+
describe('compile()', () => {
|
|
8
|
+
it('story should be instanceof Story', () => {
|
|
9
|
+
expect(() => { compileTwine1HTML({}); }).toThrow();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('Should create an empty file without valid header.html', function () {
|
|
13
|
+
// Create story.
|
|
14
|
+
const s = new Story();
|
|
15
|
+
|
|
16
|
+
// Compile Twine 1.
|
|
17
|
+
const t1 = compileTwine1HTML(s);
|
|
18
|
+
|
|
19
|
+
// Test.
|
|
20
|
+
expect(t1.length).toBe(0);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('Should replace "VERSION" and "TIME" in mock header.html file', function () {
|
|
24
|
+
// Create story.
|
|
25
|
+
const s = new Story();
|
|
26
|
+
|
|
27
|
+
// Set creator.
|
|
28
|
+
s.creator = 'Test1';
|
|
29
|
+
|
|
30
|
+
// Read mock header.html
|
|
31
|
+
const header = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/test1.html', 'utf-8');
|
|
32
|
+
|
|
33
|
+
// Read engine code.
|
|
34
|
+
const engine = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js', 'utf-8');
|
|
35
|
+
|
|
36
|
+
// Compile file.
|
|
37
|
+
const result = compileTwine1HTML(s, engine, header);
|
|
38
|
+
|
|
39
|
+
// Test for creator.
|
|
40
|
+
expect(result.includes('Test1')).toBe(true);
|
|
41
|
+
|
|
42
|
+
// Test for time.
|
|
43
|
+
expect(result.includes(new Date().getFullYear().toString())).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('Should include Twine engine code', function () {
|
|
47
|
+
// Create story.
|
|
48
|
+
const s = new Story();
|
|
49
|
+
|
|
50
|
+
// Read mock header.html
|
|
51
|
+
const header = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/engineTest.html', 'utf-8');
|
|
52
|
+
|
|
53
|
+
// Read engine code.
|
|
54
|
+
const engine = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js', 'utf-8');
|
|
55
|
+
|
|
56
|
+
// Compile file.
|
|
57
|
+
compileTwine1HTML(s, engine, header);
|
|
58
|
+
|
|
59
|
+
// Read file.
|
|
60
|
+
const result = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/test3.html', 'utf-8');
|
|
61
|
+
|
|
62
|
+
// Test for engine.
|
|
63
|
+
expect(result.includes('function clone(a)')).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('Should include story format based on name', function () {
|
|
67
|
+
// Create story.
|
|
68
|
+
const s = new Story();
|
|
69
|
+
|
|
70
|
+
// Add passage.
|
|
71
|
+
s.addPassage(new Passage('Start', 'Work'));
|
|
72
|
+
|
|
73
|
+
// Set story start.
|
|
74
|
+
s.start = 'Start';
|
|
75
|
+
|
|
76
|
+
// Read header.html.
|
|
77
|
+
const header = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/header.html', 'utf-8');
|
|
78
|
+
|
|
79
|
+
// Read code.js.
|
|
80
|
+
const codeJS = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/code.js', 'utf-8');
|
|
81
|
+
|
|
82
|
+
// Read engine code.
|
|
83
|
+
const engine = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js', 'utf-8');
|
|
84
|
+
|
|
85
|
+
// Compile file.
|
|
86
|
+
const result = compileTwine1HTML(s, engine, header, 'jonah', codeJS);
|
|
87
|
+
|
|
88
|
+
// Test for code.js.
|
|
89
|
+
expect(result.includes('Tale.prototype.canBookmark')).toBe(true);
|
|
90
|
+
|
|
91
|
+
// Test for passage.
|
|
92
|
+
expect(result.includes('tiddler="Start"')).toBe(true);
|
|
93
|
+
|
|
94
|
+
// Test for story size.
|
|
95
|
+
expect(result.includes('data-size="1"')).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('Should include story format based on name with jQuery and Modernizr', function () {
|
|
99
|
+
// Create story.
|
|
100
|
+
const s = new Story();
|
|
101
|
+
|
|
102
|
+
// Add passage.
|
|
103
|
+
s.addPassage(new Passage('Start', 'Work'));
|
|
104
|
+
|
|
105
|
+
// Set story start.
|
|
106
|
+
s.start = 'Start';
|
|
107
|
+
|
|
108
|
+
// Read header.html.
|
|
109
|
+
const header = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/header.html', 'utf-8');
|
|
110
|
+
|
|
111
|
+
// Read code.js.
|
|
112
|
+
const codeJS = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/code.js', 'utf-8');
|
|
113
|
+
|
|
114
|
+
// Read engine code.
|
|
115
|
+
const engine = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js', 'utf-8');
|
|
116
|
+
|
|
117
|
+
// Read Modernizr.
|
|
118
|
+
const Modernizr = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/Twine1/modernizr.js');
|
|
119
|
+
|
|
120
|
+
// Read jQuery.
|
|
121
|
+
const jQuery = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/Twine1/jquery.js');
|
|
122
|
+
|
|
123
|
+
// Compile file.
|
|
124
|
+
const result = compileTwine1HTML(s, engine, header, 'jonah', codeJS, { jquery: jQuery, modernizr: Modernizr });
|
|
125
|
+
|
|
126
|
+
// Test for code.js.
|
|
127
|
+
expect(result.includes('Tale.prototype.canBookmark')).toBe(true);
|
|
128
|
+
|
|
129
|
+
// Test for passage.
|
|
130
|
+
expect(result.includes('tiddler="Start"')).toBe(true);
|
|
131
|
+
|
|
132
|
+
// Test for story size.
|
|
133
|
+
expect(result.includes('data-size="1"')).toBe(true);
|
|
134
|
+
|
|
135
|
+
// Test for jQuery.
|
|
136
|
+
expect(result.includes('jQuery v1.11.0')).toBe(true);
|
|
137
|
+
|
|
138
|
+
// Test for Modernizr.
|
|
139
|
+
expect(result.includes('Modernizr 2.6.2')).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('Should include story format based on name without jQuery and Modernizr', function () {
|
|
143
|
+
// Create story.
|
|
144
|
+
const s = new Story();
|
|
145
|
+
|
|
146
|
+
// Add passage.
|
|
147
|
+
s.addPassage(new Passage('Start', 'Work'));
|
|
148
|
+
|
|
149
|
+
// Set story start.
|
|
150
|
+
s.start = 'Start';
|
|
151
|
+
|
|
152
|
+
// Read header.html.
|
|
153
|
+
const header = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/header.html', 'utf-8');
|
|
154
|
+
|
|
155
|
+
// Read code.js.
|
|
156
|
+
const codeJS = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/code.js', 'utf-8');
|
|
157
|
+
|
|
158
|
+
// Read engine code.
|
|
159
|
+
const engine = readFileSync('test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js', 'utf-8');
|
|
160
|
+
|
|
161
|
+
// Compile file.
|
|
162
|
+
const result = compileTwine1HTML(s, engine, header, 'jonah', codeJS, {});
|
|
163
|
+
|
|
164
|
+
// Test for code.js.
|
|
165
|
+
expect(result.includes('Tale.prototype.canBookmark')).toBe(true);
|
|
166
|
+
|
|
167
|
+
// Test for passage.
|
|
168
|
+
expect(result.includes('tiddler="Start"')).toBe(true);
|
|
169
|
+
|
|
170
|
+
// Test for story size.
|
|
171
|
+
expect(result.includes('data-size="1"')).toBe(true);
|
|
172
|
+
|
|
173
|
+
// Test for jQuery
|
|
174
|
+
expect(result.includes('jQuery v1.11.0')).not.toBe(true);
|
|
175
|
+
|
|
176
|
+
// Test for Modernizr
|
|
177
|
+
expect(result.includes('Modernizr 2.6.2')).not.toBe(true);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { parse as parseTwine1HTML } from '../../src/Twine1HTML/parse.js';
|
|
2
|
+
|
|
3
|
+
describe('Twine1HTML', function () {
|
|
4
|
+
describe('parse()', function () {
|
|
5
|
+
it('Should throw error if elements cannot be found', function () {
|
|
6
|
+
expect(() => { parseTwine1HTML('{'); }).toThrow();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('Should parse a single passage - storeArea', function () {
|
|
10
|
+
const el = '<div id="storeArea"><div tiddler="Untitled Passage 4" tags="" created="202309031439" modifier="twee" twine-position="401,10">dd</div></div>';
|
|
11
|
+
|
|
12
|
+
// Parse Twine 1 HTML.
|
|
13
|
+
const s = parseTwine1HTML(el);
|
|
14
|
+
|
|
15
|
+
// Expect a single passage.
|
|
16
|
+
expect(s.size()).toBe(1);
|
|
17
|
+
|
|
18
|
+
// Expect creator
|
|
19
|
+
expect(s.creator).toBe('twee');
|
|
20
|
+
|
|
21
|
+
// Look for the passage.
|
|
22
|
+
const p = s.getPassageByName('Untitled Passage 4');
|
|
23
|
+
|
|
24
|
+
// Expect passage name.
|
|
25
|
+
expect(p.name).toBe('Untitled Passage 4');
|
|
26
|
+
|
|
27
|
+
// Expect no tags.
|
|
28
|
+
expect(p.tags.length).toBe(0);
|
|
29
|
+
|
|
30
|
+
// Expect position
|
|
31
|
+
expect(p.metadata.position).toBe('401,10');
|
|
32
|
+
|
|
33
|
+
// Expect text
|
|
34
|
+
expect(p.text).toBe('dd');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('Should parse a single passage - store-area', function () {
|
|
38
|
+
const el = '<div id="store-area"><div tiddler="Untitled Passage 4" tags="" created="202309031439" modifier="twee" twine-position="401,10">dd</div></div>';
|
|
39
|
+
|
|
40
|
+
// Parse Twine 1 HTML.
|
|
41
|
+
const s = parseTwine1HTML(el);
|
|
42
|
+
|
|
43
|
+
// Expect a single passage.
|
|
44
|
+
expect(s.size()).toBe(1);
|
|
45
|
+
|
|
46
|
+
// Expect creator
|
|
47
|
+
expect(s.creator).toBe('twee');
|
|
48
|
+
|
|
49
|
+
// Look for the passage.
|
|
50
|
+
const p = s.getPassageByName('Untitled Passage 4');
|
|
51
|
+
|
|
52
|
+
// Expect passage name.
|
|
53
|
+
expect(p.name).toBe('Untitled Passage 4');
|
|
54
|
+
|
|
55
|
+
// Expect no tags.
|
|
56
|
+
expect(p.tags.length).toBe(0);
|
|
57
|
+
|
|
58
|
+
// Expect position
|
|
59
|
+
expect(p.metadata.position).toBe('401,10');
|
|
60
|
+
|
|
61
|
+
// Expect text
|
|
62
|
+
expect(p.text).toBe('dd');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('Should override name with StoryTitle', function () {
|
|
66
|
+
const el = '<div id="storeArea"><div tiddler="StoryTitle" tags="" created="202309031438" modifier="twee" twine-position="10,150">Untitled Story</div></div>';
|
|
67
|
+
const s = parseTwine1HTML(el);
|
|
68
|
+
expect(s.name).toBe('Untitled Story');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('Should parse a single passage with multiple tags', function () {
|
|
72
|
+
const el = '<div id="storeArea"><div tiddler="Untitled Passage 1" tags="tag1, tag2, tag3" created="202309031439" modifier="twee" twine-position="262,10">[[Untitled Passage 2]]</div></div>';
|
|
73
|
+
|
|
74
|
+
// Parse Twine 1 HTML.
|
|
75
|
+
const s = parseTwine1HTML(el);
|
|
76
|
+
|
|
77
|
+
// Expect a single passage.
|
|
78
|
+
expect(s.size()).toBe(1);
|
|
79
|
+
|
|
80
|
+
// Expect creator
|
|
81
|
+
expect(s.creator).toBe('twee');
|
|
82
|
+
|
|
83
|
+
// Look for the passage.
|
|
84
|
+
const p = s.getPassageByName('Untitled Passage 1');
|
|
85
|
+
|
|
86
|
+
// Expect passage name.
|
|
87
|
+
expect(p.name).toBe('Untitled Passage 1');
|
|
88
|
+
|
|
89
|
+
// Expect no tags.
|
|
90
|
+
expect(p.tags.length).toBe(3);
|
|
91
|
+
|
|
92
|
+
// Expect position
|
|
93
|
+
expect(p.metadata.position).toBe('262,10');
|
|
94
|
+
|
|
95
|
+
// Expect text
|
|
96
|
+
expect(p.text).toBe('[[Untitled Passage 2]]');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('Should parse a single passage without twine-position', function () {
|
|
100
|
+
const el = '<div id="storeArea"><div tiddler="Untitled Passage 1" tags="tag1, tag2, tag3" created="202309031439" modifier="twee">[[Untitled Passage 2]]</div></div>';
|
|
101
|
+
|
|
102
|
+
// Parse Twine 1 HTML.
|
|
103
|
+
const s = parseTwine1HTML(el);
|
|
104
|
+
|
|
105
|
+
// Expect a single passage.
|
|
106
|
+
expect(s.size()).toBe(1);
|
|
107
|
+
|
|
108
|
+
// Expect creator
|
|
109
|
+
expect(s.creator).toBe('twee');
|
|
110
|
+
|
|
111
|
+
// Look for the passage.
|
|
112
|
+
const p = s.getPassageByName('Untitled Passage 1');
|
|
113
|
+
|
|
114
|
+
// Expect passage name.
|
|
115
|
+
expect(p.name).toBe('Untitled Passage 1');
|
|
116
|
+
|
|
117
|
+
// Expect no tags.
|
|
118
|
+
expect(p.tags.length).toBe(3);
|
|
119
|
+
|
|
120
|
+
// Expect position to not exist.
|
|
121
|
+
expect(Object.prototype.hasOwnProperty.call(p.metadata, 'position')).toBe(false);
|
|
122
|
+
|
|
123
|
+
// Expect text.
|
|
124
|
+
expect(p.text).toBe('[[Untitled Passage 2]]');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('Should parse a single passage without tags', function () {
|
|
128
|
+
const el = '<div id="storeArea"><div tiddler="Untitled Passage 1" created="202309031439" modifier="twee">[[Untitled Passage 2]]</div></div>';
|
|
129
|
+
|
|
130
|
+
// Parse Twine 1 HTML.
|
|
131
|
+
const s = parseTwine1HTML(el);
|
|
132
|
+
|
|
133
|
+
// Expect a single passage.
|
|
134
|
+
expect(s.size()).toBe(1);
|
|
135
|
+
|
|
136
|
+
// Expect creator
|
|
137
|
+
expect(s.creator).toBe('twee');
|
|
138
|
+
|
|
139
|
+
// Look for the passage.
|
|
140
|
+
const p = s.getPassageByName('Untitled Passage 1');
|
|
141
|
+
|
|
142
|
+
// Expect passage name.
|
|
143
|
+
expect(p.name).toBe('Untitled Passage 1');
|
|
144
|
+
|
|
145
|
+
// Expect no tags.
|
|
146
|
+
expect(p.tags.length).toBe(0);
|
|
147
|
+
|
|
148
|
+
// Expect position to not exist.
|
|
149
|
+
expect(Object.prototype.hasOwnProperty.call(p.metadata, 'position')).toBe(false);
|
|
150
|
+
|
|
151
|
+
// Expect text.
|
|
152
|
+
expect(p.text).toBe('[[Untitled Passage 2]]');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('Should parse a single passage without modifier', function () {
|
|
156
|
+
const el = '<div id="storeArea"><div tiddler="Untitled Passage 1" tags="tag1, tag2, tag3" created="202309031439">[[Untitled Passage 2]]</div></div>';
|
|
157
|
+
|
|
158
|
+
// Parse Twine 1 HTML.
|
|
159
|
+
const s = parseTwine1HTML(el);
|
|
160
|
+
|
|
161
|
+
// Expect a single passage.
|
|
162
|
+
expect(s.size()).toBe(1);
|
|
163
|
+
|
|
164
|
+
// Expect default creator
|
|
165
|
+
expect(s.creator).toBe('extwee');
|
|
166
|
+
|
|
167
|
+
// Look for the passage.
|
|
168
|
+
const p = s.getPassageByName('Untitled Passage 1');
|
|
169
|
+
|
|
170
|
+
// Expect passage name.
|
|
171
|
+
expect(p.name).toBe('Untitled Passage 1');
|
|
172
|
+
|
|
173
|
+
// Expect no tags.
|
|
174
|
+
expect(p.tags.length).toBe(3);
|
|
175
|
+
|
|
176
|
+
// Expect position to not exist.
|
|
177
|
+
expect(Object.prototype.hasOwnProperty.call(p.metadata, 'position')).toBe(false);
|
|
178
|
+
|
|
179
|
+
// Expect text.
|
|
180
|
+
expect(p.text).toBe('[[Untitled Passage 2]]');
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|