-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link resolution is more predictable and less overall stupid (#47)
* Link resolution is more predictable and less overall stupid * Update typedoc link mapping * Go back to resolving hashed mapped links correctly * Fixes for mapped links
- Loading branch information
Showing
5 changed files
with
359 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,47 @@ | ||
import { resolveRelativePath } from "./linkRewritingPlugin.js"; | ||
import { Doc } from "@djot/djot"; | ||
import { | ||
MappableLinkTarget, | ||
resolveRelativeRefPath, | ||
} from "./linkRewritingPlugin.js"; | ||
|
||
test("Resolves explicit relative links", () => { | ||
expect(resolveRelativePath("a/b/c.txt", "./d.txt")).toEqual("/a/b/d.txt"); | ||
expect(resolveRelativePath("a/b/c.txt", "./../d.txt")).toEqual("/a/d.txt"); | ||
expect(resolveRelativePath("a/b/c.txt", "../d.txt")).toEqual("/a/d.txt"); | ||
expect(resolveRelativeRefPath("a/b/c.txt", "./d.txt")).toEqual("/a/b/d.txt"); | ||
expect(resolveRelativeRefPath("a/b/c.txt", "./../d.txt")).toEqual("/a/d.txt"); | ||
expect(resolveRelativeRefPath("a/b/c.txt", "../d.txt")).toEqual("/a/d.txt"); | ||
}); | ||
|
||
test("MappableLinkTarget has expected values", () => { | ||
const stubDoc: Doc = { | ||
tag: "doc", | ||
references: {}, | ||
autoReferences: {}, | ||
footnotes: {}, | ||
children: [], | ||
}; | ||
const t = new MappableLinkTarget( | ||
{ | ||
docs: { | ||
content: stubDoc, | ||
}, | ||
title: "The Doc", | ||
titleAST: [], | ||
originalExtension: ".djot", | ||
fsPath: "/fsroot/input/subdir/the_doc.djot", | ||
refPath: "subdir/the_doc", | ||
filename: "the_doc", | ||
frontMatter: {}, | ||
data: {}, | ||
}, | ||
"the-hash" | ||
); | ||
|
||
expect(t.aliases).toEqual([ | ||
"#the-hash", | ||
"the_doc#the-hash", | ||
"the_doc.djot#the-hash", | ||
"subdir/the_doc#the-hash", | ||
"subdir/the_doc.djot#the-hash", | ||
"/subdir/the_doc#the-hash", | ||
"/subdir/the_doc.djot#the-hash", | ||
]); | ||
}); |
Oops, something went wrong.