#7: Parse HTML-like tags in paths
This commit is contained in:
parent
902e5b0e69
commit
cf8244580d
3 changed files with 320 additions and 46 deletions
15
src/wiki.ts
15
src/wiki.ts
|
@ -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;
|
||||
|
|
Reference in a new issue