@stxt-lang/core 0.7.1 → 0.8.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/out/core/Parser.js
CHANGED
|
@@ -90,6 +90,12 @@ class Parser {
|
|
|
90
90
|
// Parse the line
|
|
91
91
|
const line = (0, LineParser_1.parseLine)(lineString, lastNodeText, lastLevel, lineNumber);
|
|
92
92
|
if (line.isComment) {
|
|
93
|
+
// A comment at the level of an open block node (or shallower) closes the block
|
|
94
|
+
// (spec 6.1 and 9.1): a block is a literal and cannot be commented from inside.
|
|
95
|
+
// Only the block closes; the comment does not touch the rest of the hierarchy.
|
|
96
|
+
if (lastNodeText) {
|
|
97
|
+
this.closeToLevel(stack, stack.length - 1, result);
|
|
98
|
+
}
|
|
93
99
|
// Hand it over to the observers
|
|
94
100
|
this.observers.forEach(observer => {
|
|
95
101
|
observer.onComment(lineNumber, lineString);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** String normalization helpers used for names, namespaces and values. */
|
|
2
2
|
export declare class StringUtils {
|
|
3
3
|
private static readonly NODE_NAME;
|
|
4
|
+
private static readonly NODE_NAME_LETTER_OR_DIGIT;
|
|
4
5
|
private constructor();
|
|
5
6
|
/**
|
|
6
7
|
* Removes the trailing whitespace of a string.
|
package/out/core/StringUtils.js
CHANGED
|
@@ -62,7 +62,7 @@ class StringUtils {
|
|
|
62
62
|
*/
|
|
63
63
|
static isValidNodeName(input) {
|
|
64
64
|
const nfc = this.compactSpaces(input).normalize("NFC");
|
|
65
|
-
return this.NODE_NAME.test(nfc) && this.
|
|
65
|
+
return this.NODE_NAME.test(nfc) && this.NODE_NAME_LETTER_OR_DIGIT.test(nfc);
|
|
66
66
|
}
|
|
67
67
|
// Used for the normalized name of the nodes (STXT-SPEC 4.3): NFC + lower case,
|
|
68
68
|
// keeping diacritics and non-Latin alphabets (IDN model)
|
|
@@ -87,7 +87,9 @@ class StringUtils {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
exports.StringUtils = StringUtils;
|
|
90
|
-
// STXT-SPEC 4.2 / 4.3:
|
|
90
|
+
// STXT-SPEC 4.2 / 4.3: letters, decimal digits, combining marks (Mn, Mc) and the three
|
|
91
|
+
// separators, with at least one letter or digit. Validated after NFC so that a
|
|
91
92
|
// decomposed spelling such as "e" + combining acute is accepted as "é".
|
|
92
|
-
StringUtils.NODE_NAME = /^[\p{L}\p{Nd}\-_ ]+$/u;
|
|
93
|
+
StringUtils.NODE_NAME = /^[\p{L}\p{Nd}\p{Mn}\p{Mc}\-_ ]+$/u;
|
|
94
|
+
StringUtils.NODE_NAME_LETTER_OR_DIGIT = /[\p{L}\p{Nd}]/u;
|
|
93
95
|
//# sourceMappingURL=StringUtils.js.map
|
|
@@ -5,6 +5,10 @@ import { ValidationException } from "../exceptions/ValidationException";
|
|
|
5
5
|
/**
|
|
6
6
|
* Wrapper around a {@link SchemaValidator} that only validates namespaced nodes, so that a
|
|
7
7
|
* document mixing schema-bound and free nodes does not report the free ones as unknown.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated since 0.8.0: {@link SchemaValidator} applies this rule itself (STXT-SCHEMA-SPEC 5,
|
|
10
|
+
* the empty namespace is never validated), so the wrapper adds nothing. Register the
|
|
11
|
+
* `SchemaValidator` directly. Kept for compatibility; to be removed in 1.0.
|
|
8
12
|
*/
|
|
9
13
|
export declare class ConditionalValidator implements Validator {
|
|
10
14
|
private readonly schemaValidator;
|
|
@@ -4,6 +4,10 @@ exports.ConditionalValidator = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Wrapper around a {@link SchemaValidator} that only validates namespaced nodes, so that a
|
|
6
6
|
* document mixing schema-bound and free nodes does not report the free ones as unknown.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated since 0.8.0: {@link SchemaValidator} applies this rule itself (STXT-SCHEMA-SPEC 5,
|
|
9
|
+
* the empty namespace is never validated), so the wrapper adds nothing. Register the
|
|
10
|
+
* `SchemaValidator` directly. Kept for compatibility; to be removed in 1.0.
|
|
7
11
|
*/
|
|
8
12
|
class ConditionalValidator {
|
|
9
13
|
/**
|
|
@@ -26,6 +26,18 @@ class SchemaValidator {
|
|
|
26
26
|
const errors = [];
|
|
27
27
|
// Get the namespace
|
|
28
28
|
const namespace = node.getNamespace();
|
|
29
|
+
// The empty namespace is never validated (STXT-SCHEMA-SPEC 5): a node that neither
|
|
30
|
+
// declares nor inherits a namespace is valid by definition, no schema is looked up for
|
|
31
|
+
// it and SCHEMA_NOT_FOUND is never reported for it. Its children are still walked when
|
|
32
|
+
// recursive, because one of them may declare a namespace of its own.
|
|
33
|
+
if (namespace === "") {
|
|
34
|
+
if (this.recursiveValidation && node instanceof InlineNode_1.InlineNode) {
|
|
35
|
+
for (const childNode of node.getChildren()) {
|
|
36
|
+
errors.push(...this.validate(childNode));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return errors;
|
|
40
|
+
}
|
|
29
41
|
const schema = this.schemaProvider.getSchema(namespace);
|
|
30
42
|
if (!schema) {
|
|
31
43
|
errors.push(new ValidationException_1.ValidationException(node.getLine(), "SCHEMA_NOT_FOUND", `Not found schema: ${namespace}`));
|