turva-llms-txt-validator 0.9.0 → 0.9.1
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/README.md +3 -3
- package/dist/src/index.js +47 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -135,7 +135,7 @@ Links are read the way CommonMark reads them for the forms listed here.
|
|
|
135
135
|
- In this validator a raw HTML block is one of types 1 to 7 of CommonMark, and it is read only where its start is certain. The opener must be on the first line, after a blank line, or after a heading that itself stood at such a place. It must be indented at most three columns and stand outside every open list item. Under a paragraph line, a quote line, a list item line or another HTML line the opener hides nothing, and the lines after it keep their ordinary reading. The lines of a block hold no links, definitions, list items or headings for the checks. A `## Docs` line inside such a block is part of the block and no H2 section. Examples are the line between `<?x` and `?>` and the line directly under a `<div>` that stands after a blank line, with no blank line between them. Until 0.8.0 such a line counted as a section. The no-HTML check still reads them. A fence opener inside an HTML block is still read as a fence.
|
|
136
136
|
- A title (written with `#` or underlined with `=`), a link name or a summary whose text is only character references to white space, code spans of white space or empty quote markers counts as empty: `#  `, `` [` `](https://example.org/a) ``, `>>` and `> >`. A line with only a no-break or ideographic space is not a blank line.
|
|
137
137
|
- A quote escaped with a backslash inside a link title, as in `[A](https://example.org/a "Ti\"tle\"")`, is not recognised, so that link is dropped. A title that spans a line break is dropped the same way.
|
|
138
|
-
-
|
|
138
|
+
- A link text may hold a balanced pair of brackets or a backslash-escaped bracket, as in `[A [x] B](https://example.org/a)`. A link text that holds a complete link of its own is not a link, so only the inner link counts, and the line still draws the look-alike warning. An opening bracket that is never closed, as in `[A [x](https://example.org/a)`, leaves only the inner link, and that line draws the warning too. A link text cannot span a blank line.
|
|
139
139
|
- A backslash escape in a target is resolved before the URL test, so `https\://example.org/guide` is read as `https://example.org/guide`.
|
|
140
140
|
- CR and CRLF line endings are read as LF. A setext title, which is a text line underlined with `=`, is read only when it is a single line.
|
|
141
141
|
|
|
@@ -255,12 +255,12 @@ The strict type check found two inputs that could leave `undefined` in a check's
|
|
|
255
255
|
GitHub Actions publishes every version from 0.1.3 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
|
|
256
256
|
|
|
257
257
|
```sh
|
|
258
|
-
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.9.
|
|
258
|
+
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.9.1 --ignore-scripts && npm audit signatures
|
|
259
259
|
```
|
|
260
260
|
|
|
261
261
|
`npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository, the workflow file `.github/workflows/publish.yml` and the commit that produced the tarball. Versions up to and including 0.8.4 were built in `github.com/erekola/llms-txt-validator`, before the repository moved to the turva-dev organization on 2026-11-25. Every later release is built in `github.com/turva-dev/llms-txt-validator`. The npm version page shows them under Provenance.
|
|
262
262
|
|
|
263
|
-
Tag `v0.9.
|
|
263
|
+
Tag `v0.9.1` must point at that same commit, and `gh api repos/turva-dev/llms-txt-validator/commits/v0.9.1 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
|
|
264
264
|
|
|
265
265
|
## Development
|
|
266
266
|
|
package/dist/src/index.js
CHANGED
|
@@ -993,7 +993,8 @@ function collectLinkDefinitions(text, lineBlocks, defAt) {
|
|
|
993
993
|
// nor break one (S3, LV-05). A target may be written in angle brackets and may carry a title in quotes, as CommonMark allows;
|
|
994
994
|
// a plain target keeps balanced parentheses ("a_(b)") and an unbalanced one is no link (S3, WL-12); an empty target is a link
|
|
995
995
|
// with an empty target (S3, LV-07). An image nested in the link text, such as "[a ](y)", is link content and is skipped
|
|
996
|
-
// whole, and the alt text of an image holds no link (S3, LV-08).
|
|
996
|
+
// whole, and the alt text of an image holds no link (S3, LV-08). The text of a link may hold balanced brackets and escaped ones, and it ends at the "]" that
|
|
997
|
+
// closeOf paired with its "[", but a link whose text holds another link is no link, because CommonMark
|
|
997
998
|
// does not allow a link inside a link. A label ends at the paragraph, which the block numbers of the reader say (S3, LV-06). A
|
|
998
999
|
// full or collapsed reference link, "[text][label]" or "[text][]", resolves against collectLinkDefinitions; an unresolved label
|
|
999
1000
|
// is read as plain brackets, and so is a shortcut reference "[text]" after an inline attempt that did not parse (S3, LV-11). A
|
|
@@ -1159,15 +1160,6 @@ function collectLinks(text, defs, lineBlocks) {
|
|
|
1159
1160
|
return { target: text.slice(k, e), end: e };
|
|
1160
1161
|
return e < text.length ? afterTarget(text.slice(k, e), e) : null;
|
|
1161
1162
|
};
|
|
1162
|
-
// The text of a link label from j on, up to the "]" or "[" that ends it or the line break that ends the paragraph. A bracket
|
|
1163
|
-
// inside a code span is code and neither closes nor opens. A backslash before a line break is a hard
|
|
1164
|
-
// line break and escapes nothing, so the break still ends the paragraph it ends (CommonMark); the label scan and closeOf
|
|
1165
|
-
// below used to step over it, and a link label then ran on into the next list item or heading.
|
|
1166
|
-
const scanLabel = (j) => {
|
|
1167
|
-
while (j < text.length && (code[j] || (text[j] !== "]" && text[j] !== "[" && !blankAt(j))))
|
|
1168
|
-
j += !code[j] && text[j] === "\\" && text[j + 1] !== "\n" ? 2 : 1;
|
|
1169
|
-
return j;
|
|
1170
|
-
};
|
|
1171
1163
|
// A definition is decoded once, however many references use it: a long destination used by many labels would otherwise be
|
|
1172
1164
|
// decoded again for each of them.
|
|
1173
1165
|
const decoded = new Map();
|
|
@@ -1253,43 +1245,20 @@ function collectLinks(text, defs, lineBlocks) {
|
|
|
1253
1245
|
}
|
|
1254
1246
|
return i - lineStart <= 64 && DEF_HEAD.test(text.slice(lineStart, i));
|
|
1255
1247
|
};
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
let j = i + 1;
|
|
1266
|
-
for (;;) {
|
|
1267
|
-
j = scanLabel(j);
|
|
1268
|
-
if (j >= text.length || text[j] !== "[")
|
|
1269
|
-
break;
|
|
1270
|
-
if (code[j] || text[j - 1] !== "!" || isEscaped(text, j - 1))
|
|
1271
|
-
break;
|
|
1272
|
-
const after = skipImage(j);
|
|
1273
|
-
if (after === null)
|
|
1274
|
-
break;
|
|
1275
|
-
j = after;
|
|
1276
|
-
}
|
|
1277
|
-
if (j >= text.length)
|
|
1278
|
-
break;
|
|
1279
|
-
if (text[j] === "\n") {
|
|
1280
|
-
i = j;
|
|
1281
|
-
continue;
|
|
1282
|
-
}
|
|
1283
|
-
if (text[j] === "[") {
|
|
1284
|
-
i = j - 1;
|
|
1285
|
-
continue;
|
|
1286
|
-
}
|
|
1248
|
+
// The brackets that closeOf paired and whose "]" has not been reached yet, innermost last. The text of a link may hold
|
|
1249
|
+
// balanced brackets ("[rewrite Optional[T] to T](x)") and backslash-escaped ones, so a label ends at the "]" that closeOf
|
|
1250
|
+
// paired with its "[", and the link is read there, once everything inside has been read. child records that another "[" opened
|
|
1251
|
+
// inside, which keeps a shortcut or collapsed reference from taking a label with brackets in it. Links do not nest: when a
|
|
1252
|
+
// link was found inside the text, the outer one is not a link and its "]" is plain text (CommonMark 0.31.2, section 6.3).
|
|
1253
|
+
const pending = [];
|
|
1254
|
+
// Reads what follows the "]" at j of the link text opened at i: an inline target, a full or collapsed reference, or a
|
|
1255
|
+
// shortcut reference. Returns the index the scan resumes from, or j when no link starts at i.
|
|
1256
|
+
const closeLink = (i, j, plain) => {
|
|
1287
1257
|
if (text[j + 1] === "(") {
|
|
1288
1258
|
const t = readTarget(j + 2);
|
|
1289
1259
|
if (t) {
|
|
1290
1260
|
out.push({ name: text.slice(i + 1, j), target: decodeDestination(t.target), at: i });
|
|
1291
|
-
|
|
1292
|
-
continue;
|
|
1261
|
+
return t.end;
|
|
1293
1262
|
}
|
|
1294
1263
|
// A target that does not parse leaves "[text]" to be read as a shortcut reference below (S3, LV-11).
|
|
1295
1264
|
}
|
|
@@ -1299,16 +1268,17 @@ function collectLinks(text, defs, lineBlocks) {
|
|
|
1299
1268
|
m += text[m] === "\\" ? 2 : 1;
|
|
1300
1269
|
if (m < text.length && text[m] === "]") {
|
|
1301
1270
|
const rawLabel = text.slice(j + 2, m);
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1271
|
+
if (rawLabel !== "" || plain) {
|
|
1272
|
+
const label = normalizeLinkLabel(rawLabel === "" ? text.slice(i + 1, j) : rawLabel);
|
|
1273
|
+
const dest = label ? refs.get(label) : undefined;
|
|
1274
|
+
if (dest !== undefined) {
|
|
1275
|
+
out.push({ name: text.slice(i + 1, j), target: decodeRef(label, dest), at: i });
|
|
1276
|
+
return m;
|
|
1277
|
+
}
|
|
1308
1278
|
}
|
|
1309
1279
|
}
|
|
1310
1280
|
}
|
|
1311
|
-
else {
|
|
1281
|
+
else if (plain) {
|
|
1312
1282
|
// A shortcut reference, "[text]" alone with neither "(" nor "[" right after it, resolves
|
|
1313
1283
|
// against a definition using the link text itself as the label (VN2, round 3 Tek-542).
|
|
1314
1284
|
// Checked last, and only here, so it never overrides the full or collapsed reference
|
|
@@ -1318,11 +1288,35 @@ function collectLinks(text, defs, lineBlocks) {
|
|
|
1318
1288
|
const dest = label ? refs.get(label) : undefined;
|
|
1319
1289
|
if (dest !== undefined) {
|
|
1320
1290
|
out.push({ name: text.slice(i + 1, j), target: decodeRef(label, dest), at: i });
|
|
1321
|
-
|
|
1322
|
-
continue;
|
|
1291
|
+
return j;
|
|
1323
1292
|
}
|
|
1324
1293
|
}
|
|
1325
|
-
|
|
1294
|
+
return j;
|
|
1295
|
+
};
|
|
1296
|
+
for (let i = 0; i < text.length; i++) {
|
|
1297
|
+
while (pending.length > 0 && pending[pending.length - 1].close < i)
|
|
1298
|
+
pending.pop();
|
|
1299
|
+
if (pending.length > 0 && pending[pending.length - 1].close === i) {
|
|
1300
|
+
const p = pending.pop();
|
|
1301
|
+
// Nothing found inside the text: the outer bracket pair may be a link.
|
|
1302
|
+
if (out.length === p.outLen)
|
|
1303
|
+
i = closeLink(p.open, i, !p.child);
|
|
1304
|
+
continue;
|
|
1305
|
+
}
|
|
1306
|
+
if (text[i] !== "[" || code[i] || isEscaped(text, i))
|
|
1307
|
+
continue;
|
|
1308
|
+
if (pending.length > 0)
|
|
1309
|
+
pending[pending.length - 1].child = true;
|
|
1310
|
+
if (i > 0 && text[i - 1] === "!" && !isEscaped(text, i - 1)) {
|
|
1311
|
+
const after = skipImage(i);
|
|
1312
|
+
if (after !== null)
|
|
1313
|
+
i = after - 1;
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1316
|
+
const c = closeOf()[i];
|
|
1317
|
+
if (c >= 0) {
|
|
1318
|
+
pending.push({ open: i, close: c, outLen: out.length, child: false });
|
|
1319
|
+
}
|
|
1326
1320
|
}
|
|
1327
1321
|
return out;
|
|
1328
1322
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turva-llms-txt-validator",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Validate a site's llms.txt structure: eight checks as pass/warn/fail plus two llms.txt v2 discovery checks that read pass or info and never move the summary, JSON output. Same checks as the hosted validator at turva.dev/llms-txt-validator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|