#7: Parse HTML-like tags in paths

This commit is contained in:
mtkennerly 2022-07-22 07:33:17 +08:00
parent 902e5b0e69
commit cf8244580d
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
3 changed files with 320 additions and 46 deletions

View file

@ -317,6 +317,7 @@ function parsePath(path: string): [string, PathType] {
return [
path
.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/")
.replace(/\/(?=$)/g, "")
.replace(/^~(?=($|\/))/, "<home>"),
pathType,
@ -630,6 +631,20 @@ function flattenParameter(nodes: Array<WikiNode>): [string, boolean] {
break;
case "comment":
break;
case "tag":
const [flatT, regularT] = flattenParameter(node.content);
if (!regularT) {
regular = false;
}
if (flatT.includes("/") || flatT.includes("\\")) {
// This is probably an unclosed tag with more path content after it,
// like `.../<game.version>/...`.
composite += `*/${flatT}`;
} else if (flatT.length > 0) {
// This is probably a closed tag, like `.../<sup>user ID</sup>/...`.
composite += "*";
}
break;
default:
regular = false;
break;