Links in .lit
are comprised of two main types Standard and wiki-links.
much of the complexity is a result of considering the second type.
Standard and Anchored/Section§, wiki-links, inline references↗ and [undefined refs], footnotes1§ and external↗ links
Standard links
Should for the most part behave as expected, with the recommendation being that you should link to the source for other .lit
/Mardown documents and the resultant html
should convert to .html
extention automatically for you.
For most sub types (I.e relative links, fragments, and external links) this introduces no additional complexity but for absolute links an assumption has to be made that either a. the file is served from the root of the host domain ie /example/absolute.md
or b. that the rendered page includes a baseUrl
mechanism.
WikiLinks
These are a convention introduced by Wiki↗ and rely on a few assumptions.
- There is a canonical item to link to
- Or a system for handling disambiguation
Many Markdown implementations tackle this by either
- assuming an entirely Flat directory structure
- or providing a set of known permalinks to the resolver
Interesting alternative solutions
- [Describe Agora.org approach]
- behave as search links [find reference]
To Do
- with slashes: utils/fs
- with fragments: utils/uri#fragments
- only fragments like #Wikilinks
- Hoist fragment
Bonus
- Resolve index file links without the need for excessive duplication. ie parser/parser or testing/index instead should just be able to write parser and testing.
Testing
Implementation is at ../parser/parser
return lit.parser.utils.links;
const { wikiLinkOptions, linkToUrl, decorateLinkNode } = lit.parser.utils.links
const resolve = wikiLinkOptions().pageResolver;
// console.info(resolve.toString())
// console.info(linkToUrl.toString())
const root = "/";
const type = "wikiLink";
const example = "testing/Links?foo=bar#baz|Title";
const resolved = resolve(example);
const link = {
type,
data: { permalink: resolved[0] },
url: example,
value: example,
};
const url = linkToUrl(link, root);
console.log({ root, example, resolved, link , url});
const decorated = decorateLinkNode(link);
return JSON.stringify(decorated, null, 2);
- footnote
With multi line
content
↩§