extwee 2.3.9 → 2.3.11
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/build/extwee.core.min.js +1 -1
- package/build/extwee.twine1html.min.js +1 -1
- package/build/extwee.twine2archive.min.js +1 -1
- package/build/extwee.tws.min.js +1 -1
- package/docs/build/extwee.core.min.js +1 -1
- package/docs/build/extwee.twine1html.min.js +1 -1
- package/docs/build/extwee.twine2archive.min.js +1 -1
- package/docs/build/extwee.tws.min.js +1 -1
- package/package.json +7 -7
- package/src/Passage.js +8 -9
- package/src/Story.js +17 -1
- package/test/Objects/Passage.test.js +34 -30
- package/test/Objects/SnowmanCompatibility.test.js +17 -31
- package/test/Objects/Story.test.js +7 -19
- package/test/Twee/Twee.Parse.test.js +18 -3
- package/test/Twee/TweeParser/cycling.twee +75 -0
- package/test/Twee/TweeParser/style.twee +16 -0
- package/test/Twine2HTML/Twine2HTML.Parse.test.js +3 -4
- package/types/src/Story.d.ts +1 -1
|
@@ -57,15 +57,16 @@ describe('Twee', () => {
|
|
|
57
57
|
const fr = readFileSync('test/Twee/TweeParser/scriptPassage.twee', 'utf-8');
|
|
58
58
|
const story = parseTwee(fr);
|
|
59
59
|
const p = story.getPassageByName('UserScript');
|
|
60
|
-
expect(p
|
|
60
|
+
expect(p).toBe(null);
|
|
61
|
+
expect(story.storyJavaScript.length).toBeGreaterThan(0);
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
it('Should parse single stylesheet passage', () => {
|
|
64
65
|
const fr = readFileSync('test/Twee/TweeParser/stylePassage.twee', 'utf-8');
|
|
65
66
|
const story = parseTwee(fr);
|
|
66
67
|
const p = story.getPassageByName('UserStylesheet');
|
|
67
|
-
expect(p
|
|
68
|
-
expect(
|
|
68
|
+
expect(p).toBe(null);
|
|
69
|
+
expect(story.storyStylesheet.length).toBeGreaterThan(0);
|
|
69
70
|
});
|
|
70
71
|
|
|
71
72
|
it('Should parse StoryTitle', () => {
|
|
@@ -89,5 +90,19 @@ describe('Twee', () => {
|
|
|
89
90
|
expect(p).not.toBe(null);
|
|
90
91
|
expect(startingPassage).toBe('Start');
|
|
91
92
|
});
|
|
93
|
+
|
|
94
|
+
it('Should correctly parse "script" tagged passages as story javascript AND remove passages from story', () => {
|
|
95
|
+
const fr = readFileSync('test/Twee/TweeParser/cycling.twee', 'utf-8');
|
|
96
|
+
const story = parseTwee(fr);
|
|
97
|
+
expect(story.storyJavaScript.length).toBeGreaterThan(0);
|
|
98
|
+
expect(story.passages.length).toBe(2);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('Should correctly parse "stylesheet" tagged passages as story stylesheet AND remove passages from story', () => {
|
|
102
|
+
const fr = readFileSync('test/Twee/TweeParser/style.twee', 'utf-8');
|
|
103
|
+
const story = parseTwee(fr);
|
|
104
|
+
expect(story.storyStylesheet.length).toBeGreaterThan(0);
|
|
105
|
+
expect(story.passages.length).toBe(1);
|
|
106
|
+
});
|
|
92
107
|
});
|
|
93
108
|
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
:: StoryTitle
|
|
2
|
+
Cycling Choices in Snowman
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
:: StoryData
|
|
6
|
+
{
|
|
7
|
+
"ifid": "2A4D6978-93A7-4FD3-96FB-94B995FCBE29"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
:: UserScript[script]
|
|
12
|
+
$(function() {
|
|
13
|
+
|
|
14
|
+
// Create a global object
|
|
15
|
+
window.setup = window.setup || {};
|
|
16
|
+
|
|
17
|
+
// Iterate through all elements with the class 'cycle'
|
|
18
|
+
// For each, save the current 'choices' and 'selection'
|
|
19
|
+
// (This sets all the 'default' values.)
|
|
20
|
+
$('.cycle').each(function() {
|
|
21
|
+
|
|
22
|
+
// Create a global object for each 'id'
|
|
23
|
+
var id = $(this).attr('id');
|
|
24
|
+
setup[id] = {};
|
|
25
|
+
|
|
26
|
+
// Save the current 'choices' for each
|
|
27
|
+
var choices = JSON.parse($(this).attr("data-cycling-choices"));
|
|
28
|
+
setup[id].choices = choices;
|
|
29
|
+
|
|
30
|
+
// Save the current 'selection' for each
|
|
31
|
+
var selection = $(this).attr("data-cycling-selection");
|
|
32
|
+
setup[id].selection = selection;
|
|
33
|
+
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
$('.cycle').click(function(){
|
|
37
|
+
|
|
38
|
+
// Save the 'id'
|
|
39
|
+
var id = $(this).attr('id');
|
|
40
|
+
|
|
41
|
+
// Retrieve the global 'choices'
|
|
42
|
+
var choices = setup[id].choices;
|
|
43
|
+
|
|
44
|
+
// Retrieve the global 'selection'
|
|
45
|
+
var selection = setup[id].selection;
|
|
46
|
+
|
|
47
|
+
// Update the 'selection' number
|
|
48
|
+
selection++;
|
|
49
|
+
|
|
50
|
+
// Check if 'selection' is greater than length of choices
|
|
51
|
+
if(selection >= choices.length) {
|
|
52
|
+
selection = 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Update the 'selection' on the element
|
|
56
|
+
$(this).attr("data-cycling-selection", selection);
|
|
57
|
+
|
|
58
|
+
// Update the text of the element with the choice
|
|
59
|
+
$(this).text(choices[selection]);
|
|
60
|
+
|
|
61
|
+
// Update the global values of 'choices' and 'selection'
|
|
62
|
+
setup[id].choices = choices;
|
|
63
|
+
setup[id].selection = selection;
|
|
64
|
+
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
:: Start
|
|
70
|
+
<a href='javascript:void(0)' id='cycleOne' class='cycle' data-cycling-choices='["One", "Two", "Three"]' data-cycling-selection=0>One</a>
|
|
71
|
+
|
|
72
|
+
[[Submit|Results]]
|
|
73
|
+
|
|
74
|
+
:: Results
|
|
75
|
+
<%= setup["cycleOne"].choices[setup["cycleOne"].selection] %>
|
|
@@ -105,10 +105,9 @@ describe('Twine2HTMLParser', () => {
|
|
|
105
105
|
it('Should have script and style tags normally', () => {
|
|
106
106
|
const fr = readFileSync('test/Twine2HTML/Twine2HTMLParser/Example1.html', 'utf-8');
|
|
107
107
|
const story = parseTwine2HTML(fr);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expect(
|
|
111
|
-
expect(stylesheetPassages.length).toBe(1);
|
|
108
|
+
// Script-tagged passages are now stored in storyJavaScript, not passages array
|
|
109
|
+
expect(story.storyJavaScript.length).toBeGreaterThan(0);
|
|
110
|
+
expect(story.storyStylesheet.length).toBeGreaterThan(0);
|
|
112
111
|
});
|
|
113
112
|
|
|
114
113
|
it('Should parse HTML without passage start node', () => {
|
package/types/src/Story.d.ts
CHANGED