squiffy-compiler 6.0.0-beta.0 → 6.0.0-beta.2
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/dist/compiler.js +21 -2
- package/package.json +2 -2
package/dist/compiler.js
CHANGED
|
@@ -93,6 +93,7 @@ export async function compile(settings) {
|
|
|
93
93
|
}
|
|
94
94
|
const regexes = {
|
|
95
95
|
section: /^\[\[(.*)\]\]:$/,
|
|
96
|
+
snippet: /^\[snippet:\s*(.+)\]:$/,
|
|
96
97
|
passage: /^\[(.*)\]:$/,
|
|
97
98
|
title: /^@title (.*)$/,
|
|
98
99
|
import: /^@import (.*)$/,
|
|
@@ -112,6 +113,7 @@ export async function compile(settings) {
|
|
|
112
113
|
let passage = null; // annotated differently to section, as a workaround for TypeScript "Property does not exist on type never"
|
|
113
114
|
let textStarted = false;
|
|
114
115
|
let inUiBlock = false;
|
|
116
|
+
let inSnippet = false;
|
|
115
117
|
const ensureThisSectionExists = () => {
|
|
116
118
|
return ensureSectionExists(section, isFirst, inputFilename, lineCount);
|
|
117
119
|
};
|
|
@@ -134,11 +136,21 @@ export async function compile(settings) {
|
|
|
134
136
|
match[key] = result;
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
|
-
if (match.
|
|
139
|
+
if (match.snippet) {
|
|
140
|
+
inSnippet = true;
|
|
141
|
+
section = null;
|
|
142
|
+
passage = null;
|
|
143
|
+
textStarted = false;
|
|
144
|
+
}
|
|
145
|
+
else if (match.section) {
|
|
146
|
+
inSnippet = false;
|
|
138
147
|
section = story.addSection(match.section[1], inputFilename, lineCount);
|
|
139
148
|
passage = null;
|
|
140
149
|
textStarted = false;
|
|
141
150
|
}
|
|
151
|
+
else if (inSnippet) {
|
|
152
|
+
// skip all content inside snippet blocks
|
|
153
|
+
}
|
|
142
154
|
else if (match.passage) {
|
|
143
155
|
if (!section) {
|
|
144
156
|
errors.push(`ERROR: ${inputFilename} line ${lineCount}: Can't add passage "${match.passage[1]}" as no section has been created.`);
|
|
@@ -383,8 +395,15 @@ export async function compile(settings) {
|
|
|
383
395
|
// Link destination data may look like:
|
|
384
396
|
// passageName
|
|
385
397
|
// passageName, my_attribute=2
|
|
398
|
+
// passage name with a comma, in the name
|
|
386
399
|
// We're only interested in checking if the named passage or section exists.
|
|
387
|
-
|
|
400
|
+
// First check if the full link is a valid destination (handles names containing commas).
|
|
401
|
+
const trimmedLink = link.trim();
|
|
402
|
+
if (Object.keys(keys).includes(trimmedLink)) {
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
// Otherwise, assume a comma separates the destination from setters.
|
|
406
|
+
const linkDestination = trimmedLink.split(",")[0].trim();
|
|
388
407
|
return Object.keys(keys).includes(linkDestination);
|
|
389
408
|
}
|
|
390
409
|
function showBadLinksWarning(badLinks, linkTo, before, after, section, passage) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squiffy-compiler",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.2",
|
|
4
4
|
"description": "A tool for creating multiple-choice interactive stories",
|
|
5
5
|
"author": "Alex Warren",
|
|
6
6
|
"contributors": [
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"type": "module",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "d8f215aafa4534ddff8ecee0f8eaa4dd3eb9a46a"
|
|
35
35
|
}
|