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.
Files changed (216) hide show
  1. package/.eslintrc.json +25 -25
  2. package/.github/FUNDING.yml +3 -0
  3. package/.github/dependabot.yml +11 -0
  4. package/.github/workflows/nodejs.yml +25 -24
  5. package/.travis.yml +13 -13
  6. package/CODE_OF_CONDUCT.md +82 -82
  7. package/LICENSE +21 -21
  8. package/README.md +173 -36
  9. package/SECURITY.md +12 -12
  10. package/babel.config.json +18 -22
  11. package/build/extwee +0 -0
  12. package/build/extwee.exe +0 -0
  13. package/build/extwee.web.min.js +2 -0
  14. package/build/extwee.web.min.js.LICENSE.txt +1 -0
  15. package/docs/.nojekyll +0 -0
  16. package/docs/README.md +167 -0
  17. package/docs/_sidebar.md +19 -0
  18. package/docs/examples/dynamicPassages.md +28 -0
  19. package/docs/examples/jsonToTwee.md +23 -0
  20. package/docs/examples/twsToTwee.md +25 -0
  21. package/docs/formats/json.md +17 -0
  22. package/docs/formats/twee.md +13 -0
  23. package/docs/formats/twine1HTML.md +13 -0
  24. package/docs/formats/twine2ArchiveHTML.md +13 -0
  25. package/docs/formats/twine2HTML.md +13 -0
  26. package/docs/formats/tws.md +9 -0
  27. package/docs/index.html +26 -0
  28. package/docs/install/binaries.md +9 -0
  29. package/docs/install/npm.md +20 -0
  30. package/docs/install/npx.md +9 -0
  31. package/docs/objects/passage.md +47 -0
  32. package/docs/objects/story.md +70 -0
  33. package/docs/objects/storyformat.md +27 -0
  34. package/index.html +22 -0
  35. package/index.js +29 -31
  36. package/package.json +65 -58
  37. package/src/JSON/parse.js +128 -0
  38. package/src/Passage.js +298 -202
  39. package/src/Story.js +650 -523
  40. package/src/StoryFormat/parse.js +134 -0
  41. package/src/StoryFormat.js +259 -300
  42. package/src/TWS/parse.js +86 -0
  43. package/src/Twee/parse.js +157 -0
  44. package/src/Twine1HTML/compile.js +58 -0
  45. package/src/Twine1HTML/parse.js +134 -0
  46. package/src/Twine2ArchiveHTML/compile.js +36 -0
  47. package/src/Twine2ArchiveHTML/parse.js +49 -0
  48. package/src/Twine2HTML/compile.js +35 -0
  49. package/src/Twine2HTML/parse.js +348 -0
  50. package/src/extwee.js +206 -0
  51. package/test/CLI/CLI.test.js +49 -0
  52. package/test/CLI/files/example.json +1 -0
  53. package/test/CLI/files/example6.twee +22 -0
  54. package/test/{Roundtrip → CLI/files}/harlowe.js +2 -2
  55. package/test/CLI/{input.html → files/input.html} +47 -47
  56. package/test/CLI/files/output/test.twee +0 -0
  57. package/test/CLI/{tweeExample.twee → files/tweeExample.twee} +17 -17
  58. package/test/CLI/files/twine1/LICENSE.txt +32 -0
  59. package/test/CLI/files/twine1/code.js +5 -0
  60. package/test/CLI/files/twine1/engine.js +43 -0
  61. package/test/CLI/files/twine1/header.html +325 -0
  62. package/test/CLI/files/twine1Test.html +371 -0
  63. package/test/CLI/{twineExample.html → files/twineExample.html} +16 -15
  64. package/test/JSON/JSON.Parse.test.js +316 -0
  65. package/test/Passage.test.js +175 -104
  66. package/test/Roundtrip/{Example1.html → Files/Example1.html} +63 -63
  67. package/test/Roundtrip/Files/LICENSE +19 -0
  68. package/test/Roundtrip/Files/example1.twee +10 -0
  69. package/test/Roundtrip/{example2.twee → Files/example2.twee} +27 -18
  70. package/test/Roundtrip/{example4.twee → Files/example4.twee} +27 -27
  71. package/test/{StoryFormatParser → Roundtrip/Files}/harlowe.js +2 -2
  72. package/test/Roundtrip/{round.html → Files/round.html} +6 -4
  73. package/test/Roundtrip/Roundtrip.test.js +54 -0
  74. package/test/Story.test.js +638 -423
  75. package/test/StoryFormat/StoryFormat.Parse.test.js +91 -0
  76. package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/example.js +3 -3
  77. package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/example2.js +3 -3
  78. package/test/{CLI → StoryFormat/StoryFormatParser}/harlowe.js +2 -2
  79. package/test/StoryFormat.test.js +152 -152
  80. package/test/TWS/Parse.test.js +78 -0
  81. package/test/TWS/TWSParser/Example1.tws +150 -0
  82. package/test/TWS/TWSParser/Example5.tws +414 -0
  83. package/test/TWS/TWSParser/noscale.tws +0 -0
  84. package/test/TWS/TWSParser/nostory.tws +0 -0
  85. package/test/Twee/Twee.Parse.test.js +76 -0
  86. package/test/{TweeParser → Twee/TweeParser}/emptytags.twee +2 -2
  87. package/test/{TweeParser → Twee/TweeParser}/example.twee +32 -32
  88. package/test/{TweeParser → Twee/TweeParser}/missing.twee +19 -19
  89. package/test/{TweeParser → Twee/TweeParser}/multipleScriptPassages.twee +19 -19
  90. package/test/{TweeParser → Twee/TweeParser}/multipleStyleTag.twee +19 -19
  91. package/test/{TweeParser → Twee/TweeParser}/multipletags.twee +10 -10
  92. package/test/{TweeParser → Twee/TweeParser}/noTitle.twee +2 -2
  93. package/test/{TweeParser → Twee/TweeParser}/notes.twee +16 -16
  94. package/test/{TweeParser → Twee/TweeParser}/pasagemetadataerror.twee +2 -2
  95. package/test/{TweeParser → Twee/TweeParser}/scriptPassage.twee +16 -16
  96. package/test/{TweeParser → Twee/TweeParser}/singletag.twee +13 -13
  97. package/test/{TweeParser → Twee/TweeParser}/startMetadata.twee +14 -14
  98. package/test/{TweeParser → Twee/TweeParser}/storydataerror.twee +25 -25
  99. package/test/{TweeParser → Twee/TweeParser}/stylePassage.twee +16 -16
  100. package/test/{Story → Twee/TweeParser}/test.twee +25 -25
  101. package/test/Twine1HTML/Twine1HTML.Compile.test.js +180 -0
  102. package/test/Twine1HTML/Twine1HTML.Parse.test.js +183 -0
  103. package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/LICENSE +674 -0
  104. package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js +43 -0
  105. package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/jquery.js +4 -0
  106. package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/modernizr.js +4 -0
  107. package/test/Twine1HTML/Twine1HTMLCompiler/engineTest.html +1 -0
  108. package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/LICENSE +32 -0
  109. package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/code.js +4 -0
  110. package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/header.html +327 -0
  111. package/test/Twine1HTML/Twine1HTMLCompiler/test.html +0 -0
  112. package/test/Twine1HTML/Twine1HTMLCompiler/test1.html +6 -0
  113. package/test/Twine1HTML/Twine1HTMLCompiler/test2.html +6 -0
  114. package/test/Twine1HTML/Twine1HTMLCompiler/test3.html +43 -0
  115. package/test/Twine1HTML/Twine1HTMLCompiler/test4.html +372 -0
  116. package/test/Twine1HTML/Twine1HTMLCompiler/test5.html +372 -0
  117. package/test/Twine2ArchiveHTML/Twine2ArchiveHTML.Compile.test.js +35 -0
  118. package/test/Twine2ArchiveHTML/Twine2ArchiveHTML.Parse.test.js +25 -0
  119. package/test/Twine2ArchiveHTML/Twine2ArchiveHTMLCompiler/test1.html +6 -0
  120. package/test/Twine2ArchiveHTML/Twine2ArchiveHTMLParser/test1.html +3 -0
  121. package/test/Twine2HTML/Twine2HTML.Compile.test.js +224 -0
  122. package/test/Twine2HTML/Twine2HTML.Parse.test.js +172 -0
  123. package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/creator.html +4 -4
  124. package/test/{CLI → Twine2HTML/Twine2HTMLCompiler}/example6.twee +15 -15
  125. package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/missingStoryTitle.twee +29 -29
  126. package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test2.html +10 -8
  127. package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test3.html +1 -1
  128. package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test4.html +4 -4
  129. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/Example1.html +52 -52
  130. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/Tags.html +15 -15
  131. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/lyingStartnode.html +15 -15
  132. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/lyingTagColors.html +48 -48
  133. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingCreator.html +11 -11
  134. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingCreatorVersion.html +11 -11
  135. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingFormat.html +11 -11
  136. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingFormatVersion.html +11 -11
  137. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingIFID.html +11 -11
  138. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingName.html +33 -33
  139. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPID.html +15 -15
  140. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPassageName.html +15 -15
  141. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPassageTags.html +15 -15
  142. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPosition.html +15 -15
  143. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingScript.html +14 -14
  144. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingSize.html +35 -35
  145. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingStartnode.html +11 -11
  146. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingStyle.html +14 -14
  147. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingZoom.html +11 -11
  148. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample.html +23 -23
  149. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample2.html +15 -15
  150. package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample3.html +15 -15
  151. package/web-index.js +29 -0
  152. package/webpack.config.js +12 -0
  153. package/bin/extwee.js +0 -47
  154. package/src/FileReader.js +0 -33
  155. package/src/HTMLParser.js +0 -345
  156. package/src/HTMLWriter.js +0 -231
  157. package/src/StoryFormatParser.js +0 -142
  158. package/src/TweeParser.js +0 -161
  159. package/src/TweeWriter.js +0 -121
  160. package/story-formats/chapbook-1.2.0/format.js +0 -1
  161. package/story-formats/chapbook-1.2.0/logo.svg +0 -1
  162. package/story-formats/harlowe-1.2.4/format.js +0 -1
  163. package/story-formats/harlowe-1.2.4/icon.svg +0 -78
  164. package/story-formats/harlowe-2.1.0/format.js +0 -2
  165. package/story-formats/harlowe-2.1.0/icon.svg +0 -78
  166. package/story-formats/harlowe-3.1.0/format.js +0 -3
  167. package/story-formats/harlowe-3.1.0/icon.svg +0 -78
  168. package/story-formats/paperthin-1.0.0/format.js +0 -1
  169. package/story-formats/paperthin-1.0.0/icon.svg +0 -5
  170. package/story-formats/snowman-1.4.0/format.js +0 -1
  171. package/story-formats/snowman-1.4.0/icon.svg +0 -436
  172. package/story-formats/snowman-2.0.2/format.js +0 -1
  173. package/story-formats/snowman-2.0.2/icon.svg +0 -436
  174. package/story-formats/sugarcube-1.0.35/LICENSE +0 -23
  175. package/story-formats/sugarcube-1.0.35/format.js +0 -1
  176. package/story-formats/sugarcube-1.0.35/icon.svg +0 -56
  177. package/story-formats/sugarcube-2.31.1/LICENSE +0 -22
  178. package/story-formats/sugarcube-2.31.1/format.js +0 -1
  179. package/story-formats/sugarcube-2.31.1/icon.svg +0 -56
  180. package/test/CLI/test2.html +0 -45
  181. package/test/CLI.test.js +0 -30
  182. package/test/FileReader/t1.txt +0 -1
  183. package/test/FileReader.test.js +0 -14
  184. package/test/HTMLParser.test.js +0 -177
  185. package/test/HTMLWriter/example6.twee +0 -16
  186. package/test/HTMLWriter.test.js +0 -287
  187. package/test/Roundtrip/example1.twee +0 -21
  188. package/test/Roundtrip.test.js +0 -48
  189. package/test/Story/startmeta.twee +0 -29
  190. package/test/StoryFormatParser.test.js +0 -91
  191. package/test/TweeParser/test.twee +0 -25
  192. package/test/TweeParser.test.js +0 -79
  193. package/test/TweeWriter/test1.twee +0 -18
  194. package/test/TweeWriter/test3.twee +0 -12
  195. package/test/TweeWriter/test4.twee +0 -14
  196. package/test/TweeWriter/test5.twee +0 -20
  197. package/test/TweeWriter/test6.twee +0 -15
  198. package/test/TweeWriter/test7.twee +0 -15
  199. package/test/TweeWriter.test.js +0 -107
  200. /package/test/CLI/{test.twee → files/test.twee} +0 -0
  201. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/format.js +0 -0
  202. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/format_doublename.js +0 -0
  203. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingAuthor.js +0 -0
  204. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingDescription.js +0 -0
  205. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingImage.js +0 -0
  206. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingLicense.js +0 -0
  207. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingName.js +0 -0
  208. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingProofing.js +0 -0
  209. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingSource.js +0 -0
  210. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingURL.js +0 -0
  211. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingVersion.js +0 -0
  212. /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/versionWrong.js +0 -0
  213. /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/TestTags.html +0 -0
  214. /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test11.html +0 -0
  215. /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test6.html +0 -0
  216. /package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/tagColors.html +0 -0
@@ -1,91 +0,0 @@
1
- import StoryFormatParser from '../src/StoryFormatParser.js';
2
- import FileReader from '../src/FileReader';
3
-
4
- describe('StoryFormatParser', () => {
5
- describe('#parse()', () => {
6
- it('Should throw error if JSON missing', () => {
7
- const fr = FileReader.read('test/StoryFormatParser/example.js');
8
- expect(() => { StoryFormatParser.parse(fr); }).toThrow();
9
- });
10
-
11
- it('Should throw error if JSON malformed', () => {
12
- const fr = FileReader.read('test/StoryFormatParser/example2.js');
13
- expect(() => { StoryFormatParser.parse(fr); }).toThrow();
14
- });
15
-
16
- it('Should correctly parse a StoryFormat name', () => {
17
- const fr = FileReader.read('test/StoryFormatParser/format.js');
18
- const sfp = StoryFormatParser.parse(fr);
19
- expect(sfp.name).toBe('Snowman');
20
- });
21
-
22
- it('Should correctly parse Harlowe story format', () => {
23
- const fr = FileReader.read('test/StoryFormatParser/harlowe.js');
24
- const sfp = StoryFormatParser.parse(fr);
25
- expect(sfp.name).toBe('Harlowe');
26
- });
27
-
28
- it('Should detect missing name and set default', () => {
29
- const fr = FileReader.read('test/StoryFormatParser/missingName.js');
30
- const sfp = StoryFormatParser.parse(fr);
31
- expect(sfp.name).toBe('Untitled Story Format');
32
- });
33
-
34
- it('Should detect missing author and set default', () => {
35
- const fr = FileReader.read('test/StoryFormatParser/missingAuthor.js');
36
- const sfp = StoryFormatParser.parse(fr);
37
- expect(sfp.author).toBe('');
38
- });
39
-
40
- it('Should detect missing description and set default', () => {
41
- const fr = FileReader.read('test/StoryFormatParser/missingDescription.js');
42
- const sfp = StoryFormatParser.parse(fr);
43
- expect(sfp.description).toBe('');
44
- });
45
-
46
- it('Should detect missing image and set default', () => {
47
- const fr = FileReader.read('test/StoryFormatParser/missingImage.js');
48
- const sfp = StoryFormatParser.parse(fr);
49
- expect(sfp.image).toBe('');
50
- });
51
-
52
- it('Should detect missing url and set default', () => {
53
- const fr = FileReader.read('test/StoryFormatParser/missingURL.js');
54
- const sfp = StoryFormatParser.parse(fr);
55
- expect(sfp.url).toBe('');
56
- });
57
-
58
- it('Should detect missing license and set default', () => {
59
- const fr = FileReader.read('test/StoryFormatParser/missingLicense.js');
60
- const sfp = StoryFormatParser.parse(fr);
61
- expect(sfp.license).toBe('');
62
- });
63
-
64
- it('Should detect proofing license and set default', () => {
65
- const fr = FileReader.read('test/StoryFormatParser/missingProofing.js');
66
- const sfp = StoryFormatParser.parse(fr);
67
- expect(sfp.proofing).toBe(false);
68
- });
69
-
70
- it('Should throw error if version does not exist', () => {
71
- const fr = FileReader.read('test/StoryFormatParser/missingVersion.js');
72
- expect(() => {
73
- StoryFormatParser.parse(fr);
74
- }).toThrow();
75
- });
76
-
77
- it('Should throw error if version is not semantic style', () => {
78
- const fr = FileReader.read('test/StoryFormatParser/versionWrong.js');
79
- expect(() => {
80
- StoryFormatParser.parse(fr);
81
- }).toThrow();
82
- });
83
-
84
- it('Should throw error if source is not found', () => {
85
- const fr = FileReader.read('test/StoryFormatParser/missingSource.js');
86
- expect(() => {
87
- StoryFormatParser.parse(fr);
88
- }).toThrow();
89
- });
90
- });
91
- });
@@ -1,25 +0,0 @@
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,79 +0,0 @@
1
- import FileReader from '../src/FileReader.js';
2
- import TweeParser from '../src/TweeParser.js';
3
-
4
- describe('TweeParser', () => {
5
- describe('#parse()', () => {
6
- it('Should throw error if non-string is used', () => {
7
- expect(() => { TweeParser.parse(1); }).toThrow();
8
- });
9
-
10
- it('Should throw error if empty string is used', () => {
11
- expect(() => { TweeParser.parse(); }).toThrow();
12
- });
13
-
14
- it('Should throw error if no passages are present', () => {
15
- expect(() => { TweeParser.parse('()()'); }).toThrow();
16
- });
17
-
18
- it('Should throw error if it detects malformed passage headers', () => {
19
- expect(() => { TweeParser.parse('::{}[]\nNo name'); }).toThrow();
20
- });
21
-
22
- it('Should cut notes before passages', () => {
23
- const fr = FileReader.read('test/TweeParser/notes.twee');
24
- const story = TweeParser.parse(fr);
25
- const p = story.getPassageByName('StoryTitle');
26
- expect(p.text).toBe('twineExample');
27
- });
28
-
29
- it('Should be able to parse Twee file for Story Name', () => {
30
- const fr = FileReader.read('test/TweeParser/example.twee');
31
- const story = TweeParser.parse(fr);
32
- const p = story.getPassageByName('StoryTitle');
33
- expect(p.text).toBe('twineExample');
34
- });
35
-
36
- it('Should parse single tag on Start passage', () => {
37
- const fr = FileReader.read('test/TweeParser/singletag.twee');
38
- const story = TweeParser.parse(fr);
39
- const start = story.getPassageByName('Start');
40
- expect(start.tags).toHaveLength(1);
41
- });
42
-
43
- it('Should parse multiple tag', () => {
44
- const fr = FileReader.read('test/TweeParser/multipletags.twee');
45
- const story = TweeParser.parse(fr);
46
- const start = story.getPassageByName('Start');
47
- expect(start.tags).toHaveLength(2);
48
- });
49
-
50
- it('Should parse single script passage', () => {
51
- const fr = FileReader.read('test/TweeParser/scriptPassage.twee');
52
- const story = TweeParser.parse(fr);
53
- const p = story.getPassageByName('UserScript');
54
- expect(p.tags).toHaveLength(1);
55
- });
56
-
57
- it('Should parse single stylesheet passage', () => {
58
- const fr = FileReader.read('test/TweeParser/stylePassage.twee');
59
- const story = TweeParser.parse(fr);
60
- const p = story.getPassageByName('UserStylesheet');
61
- expect(p.tags).toHaveLength(1);
62
- expect(p.name).toBe('UserStylesheet');
63
- });
64
-
65
- it('Should parse StoryTitle', () => {
66
- const fr = FileReader.read('test/TweeParser/test.twee');
67
- const story = TweeParser.parse(fr);
68
- const p = story.getPassageByName('StoryTitle');
69
- expect(p).not.toBe(null);
70
- });
71
-
72
- it('Should parse StoryAuthor', () => {
73
- const fr = FileReader.read('test/TweeParser/example.twee');
74
- const story = TweeParser.parse(fr);
75
- const p = story.getPassageByName('StoryAuthor');
76
- expect(p).not.toBe(null);
77
- });
78
- });
79
- });
@@ -1,18 +0,0 @@
1
- :: StoryData
2
- {
3
- "ifid": "6BD10D27-BA22-42E1-A024-4E1AD35D8B59",
4
- "format": "Test",
5
- "format-version": "1.2.3",
6
- "zoom": 1,
7
- "start": "Untitled"
8
- }
9
-
10
- :: StoryTitle
11
- Title
12
-
13
- :: Start
14
- Content
15
-
16
- :: Untitled
17
- Some stuff
18
-
@@ -1,12 +0,0 @@
1
- :: StoryData
2
- {
3
- "ifid": "DE7DF8AD-E4CD-499E-A4E7-C5B98B73449A",
4
- "start": "Start"
5
- }
6
-
7
- :: StoryTitle
8
- Title
9
-
10
- :: Start [tag tags]
11
-
12
-
@@ -1,14 +0,0 @@
1
- :: StoryData
2
- {
3
- "ifid": "D5D54A73-4E5F-4186-9276-EBDE28110006"
4
- }
5
-
6
- :: StoryTitle
7
- Title
8
-
9
- :: Start
10
- Content
11
-
12
- :: Untitled
13
- Some stuff
14
-
@@ -1,20 +0,0 @@
1
- :: StoryData
2
- {
3
- "ifid": "580061AA-F033-46F0-997E-D45857DCFE9D",
4
- "start": "Start",
5
- "tag-colors": {
6
- "bar": "green",
7
- "foo": "red",
8
- "qaz": "blue"
9
- }
10
- }
11
-
12
- :: StoryTitle
13
- Title
14
-
15
- :: Start
16
- Content
17
-
18
- :: Untitled
19
- Some stuff
20
-
@@ -1,15 +0,0 @@
1
- :: StoryData
2
- {
3
- "ifid": "3ACDC55E-675E-4C5F-89B8-DB2871BCD61B",
4
- "start": "Start"
5
- }
6
-
7
- :: StoryTitle
8
- Title
9
-
10
- :: Start
11
- Content
12
-
13
- :: Test [script]
14
- Test
15
-
@@ -1,15 +0,0 @@
1
- :: StoryData
2
- {
3
- "ifid": "48833603-6D79-4041-B1E4-009E4A08753A",
4
- "start": "Start"
5
- }
6
-
7
- :: StoryTitle
8
- Title
9
-
10
- :: Start
11
- Content
12
-
13
- :: Test [stylesheet]
14
- Test
15
-
@@ -1,107 +0,0 @@
1
- import FileReader from '../src/FileReader.js';
2
- import Story from '../src/Story.js';
3
- import Passage from '../src/Passage.js';
4
- import TweeWriter from '../src/TweeWriter.js';
5
- import TweeParser from '../src/TweeParser.js';
6
-
7
- describe('TweeWriter', () => {
8
- describe('#write()', () => {
9
- let s = null;
10
-
11
- beforeEach(() => {
12
- s = new Story();
13
- });
14
-
15
- it('Should throw error if object passed is not instanceof Story', () => {
16
- expect(() => { TweeWriter.write({}); }).toThrow();
17
- });
18
-
19
- it('Should throw error if output file invalid', () => {
20
- expect(() => { TweeWriter.write(new Story(), ''); }).toThrow();
21
- });
22
-
23
- it('Should write Twee file', () => {
24
- s.addPassage(new Passage('StoryData', '{}'));
25
- s.addPassage(new Passage('StoryTitle', 'Title'));
26
- s.addPassage(new Passage('Start', 'Content'));
27
- TweeWriter.write(s, 'test/TweeWriter/test1.twee');
28
- const fr = FileReader.read('test/TweeWriter/test1.twee');
29
- const story = TweeParser.parse(fr);
30
- const p = story.getPassageByName('StoryTitle');
31
- expect(p.text).toBe('Title');
32
- });
33
-
34
- it('Should correctly write Twee file with passage tags', () => {
35
- s.addPassage(new Passage('Start', '', ['tag', 'tags']));
36
- s.addPassage(new Passage('StoryTitle', 'Title'));
37
- // Verify only one passage.
38
- expect(s.size()).toBe(1);
39
-
40
- // Set an ifid property
41
- s.IFID = 'DE7DF8AD-E4CD-499E-A4E7-C5B98B73449A';
42
-
43
- // Write contents to file.
44
- TweeWriter.write(s, 'test/TweeWriter/test3.twee');
45
- // Read file.
46
- const fr = FileReader.read('test/TweeWriter/test3.twee');
47
- // Parse file.
48
- const tp = TweeParser.parse(fr);
49
- // Verify only two passages
50
- expect(tp.size()).toBe(1);
51
- });
52
-
53
- it('Should write format, formatVersion, zoom, and start', () => {
54
- s.addPassage(new Passage('StoryTitle', 'Title'));
55
- s.addPassage(new Passage('Start', 'Content'));
56
- s.addPassage(new Passage('Untitled', 'Some stuff'));
57
-
58
- s.format = 'Test';
59
- s.formatVersion = '1.2.3';
60
- s.zoom = 1;
61
- s.start = 'Untitled';
62
-
63
- TweeWriter.write(s, 'test/TweeWriter/test1.twee');
64
- const fr = FileReader.read('test/TweeWriter/test1.twee');
65
- const story2 = TweeParser.parse(fr);
66
- console.log(story2);
67
- expect(story2.format).toBe('Test');
68
- });
69
-
70
- it('Should write tag colors', () => {
71
- s.addPassage(new Passage('StoryTitle', 'Title'));
72
- s.addPassage(new Passage('Start', 'Content'));
73
- s.addPassage(new Passage('Untitled', 'Some stuff'));
74
- s.tagColors = {
75
- bar: 'green',
76
- foo: 'red',
77
- qaz: 'blue'
78
- };
79
- TweeWriter.write(s, 'test/TweeWriter/test5.twee');
80
- const fr = FileReader.read('test/TweeWriter/test5.twee');
81
- const story2 = TweeParser.parse(fr);
82
- expect(story2.tagColors.bar).toBe('green');
83
- });
84
-
85
- it('Should write Twee file with "script" tags', () => {
86
- s.addPassage(new Passage('Test', 'Test', ['script']));
87
- s.addPassage(new Passage('StoryTitle', 'Title'));
88
- s.addPassage(new Passage('Start', 'Content'));
89
- TweeWriter.write(s, 'test/TweeWriter/test6.twee');
90
- const fr = FileReader.read('test/TweeWriter/test6.twee');
91
- const story = TweeParser.parse(fr);
92
- const p = story.getPassagesByTag('script');
93
- expect(p[0].text).toBe('Test');
94
- });
95
-
96
- it('Should write Twee file with "stylesheet" tags', () => {
97
- s.addPassage(new Passage('Test', 'Test', ['stylesheet']));
98
- s.addPassage(new Passage('StoryTitle', 'Title'));
99
- s.addPassage(new Passage('Start', 'Content'));
100
- TweeWriter.write(s, 'test/TweeWriter/test7.twee');
101
- const fr = FileReader.read('test/TweeWriter/test7.twee');
102
- const story = TweeParser.parse(fr);
103
- const p = story.getPassagesByTag('stylesheet');
104
- expect(p[0].text).toBe('Test');
105
- });
106
- });
107
- });
File without changes