Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wikilinks #26

Open
jgm opened this issue Jul 31, 2022 · 16 comments
Open

Wikilinks #26

jgm opened this issue Jul 31, 2022 · 16 comments

Comments

@jgm
Copy link
Owner

jgm commented Jul 31, 2022

It would be good to support wikilinks, in the style of obsidian:

[[Page Name|optional description]]
@uvtc
Copy link
Contributor

uvtc commented Aug 1, 2022

Whenever I have a pile of files (directory of directories of files, possibly a few levels deep), and I want to link to one doc from another, I've always just written my links like [whatev](../path/to/whatev.html). That is, I'm familiar with where the other doc is relative to the current doc, so it's no trouble to explicitly write out the link like usual. I'm probably missing something here --- what is the rationale for having a wikilinks-style linking syntax?

@jgm
Copy link
Owner Author

jgm commented Aug 1, 2022

It's not really necessary, but in heavily-interlinked systems of documents, like notes, it is more convenient to write see [[Tigers]] than see [Tigers](tigers.html).

@uvtc
Copy link
Contributor

uvtc commented Aug 1, 2022

Ah. I see. For wiki's:

  • all docs/pages are at the same level, and
  • doc names / page names often have spaces in them,

so that shortcut syntax is convenient. For my "nested piles of notes", I don't often want to write

  • [path/to/foo-bar-tomatoes](path/to/foo-bar-tomatoes.html) anyway, but rather
  • [how to grow tomatoes](path/to/foo-bar-tomatoes.html).

Also though, since djot doesn't use double characters for markup (e.g., there's no **bold**), I don't think [[foo]] would be consistent with djot's syntax. And djot doesn't use any left-right matching double-char syntax anywhere, I don't think.

I see that gitit uses [foo]() as a shortcut for [foo](foo.html). This might be useful if you're writing a wiki using djot.

@bpj
Copy link

bpj commented Aug 1, 2022

I agree that [[page]] seems inconsistent with djot principles and that [page]() or something like [description](:page)could be used. However different wikis will normalize whitespace/punctuation/case differently, so that would have to be addressed somehow; perhaps a callback which receives the stringified link text?

@jgm
Copy link
Owner Author

jgm commented Aug 1, 2022

[[page]] seems inconsistent with djot principles

Which principles?

@bpj
Copy link

bpj commented Aug 1, 2022

No double delimiters

@jgm
Copy link
Owner Author

jgm commented Aug 1, 2022

I think the worry was not about double delimiters per se, but about ambiguities arising from their interaction with single delimiters. I don't think this case poses a serious problem, especially because we have directional delimiters here [ vs ].

@uvtc
Copy link
Contributor

uvtc commented Aug 1, 2022

@jgm , in your example

[[Page Name|optional description]]

What purpose does "optional description" serve? That is, if [[Page Name|optional description]] were rendered at html, how does "optional description" show up? Is it a tooltip if you hover on that link? (Hm, I seem to often mix up the "alt" and "title" attributes here.)

Incidentally, whenever a syntax has two things in a row like that, I always find it difficult to remember what the order is. I think it's more readable to have [[Page Name]]{alt="alt desc" title="the title"} if that's what's desired (erg... would that mean [[Page Name]] is short for [Page Name](Page%20Name.html)?).

@jgm
Copy link
Owner Author

jgm commented Aug 1, 2022

It's the link text.
And yes: the order is an issue; in fact, different wiki engines treat the order differently.

@wrvsrx
Copy link

wrvsrx commented Aug 8, 2022

Would you consider supporting path and anchor in wiki link. For example

  1. [[Tiger]] means a link to Tiger.djot.
  2. [[folder/a|Tiger]] means a link to folder/a.djot with description Tiger.
  3. [[a#anchor|Tiger]] means a link to an anchor point named anchor in a.djot.

@wrvsrx
Copy link

wrvsrx commented Aug 9, 2022

Maybe there should be a clear spec about whether we should use either path or path without extension in wiki link. If djot file has a specified extension (such as .djot), I think using path without extension will be more concise.

@uvtc
Copy link
Contributor

uvtc commented Aug 10, 2022

@wrvsrx , the idea is that [[foo]] would potentially render to link to foo.html, not to foo.djot (since the human reader would presumably want to see the rendered html page). In the less common case of wanting to link to foo.djot, you'd have to write out [foo](foo.djot).

Anyhow, sorry about the confusion above re double-delimiters vs double matching (left-right) delimiters. I missed that distinction when I wrote my comment.

Personally, I've never found the need for a [[foo]] syntax. For one thing, my file names often contain hyphens, but I don't want the link text to have the hyphen, e.g.:

[chocolate vs. vanilla](chocolate-vs-vanilla.html)

And another reason I haven't felt the need for them: most of the time I'm wanting to give a more descriptive link, as in [yes, I'm not kidding, cashew cheese nachos](cashew-nachos.html).

But, like I mentioned earlier, I can see it being useful specifically for implementing a wiki.

@bpj
Copy link

bpj commented Aug 10, 2022

Given the many uncertainties surrounding wikilinks, not least of which is what goes before and after the pipe1 perhaps some convention for interpreting a regular link would be better. Assuming there is metadata (#35) one could have

+++
: baseurl

/wiki/

: default-extension

.html
+++

The article about [Tigers](*).

The article about [striped cats](Tigers*).

[What tigers eat](Tigers*#food)

Where by convention a lone * as the URL means "take the link text, possibly apply some transformation to it, append the default extension and prepend the baseurl and use that as URL" and an URL containinh an * means "replace the * with the default extension, and if the URL is relative prepend the baseurl".

That way the whole thing could potentially be handled by the host program and/or a filter. I have a filter for Pandoc which does this (and more).

Footnotes

  1. Personally I'm in favor of having the text before the pipe because that is the part which is always included.

@wrvsrx
Copy link

wrvsrx commented Aug 12, 2022

@wrvsrx , the idea is that [[foo]] would potentially render to link to foo.html, not to foo.djot (since the human reader would presumably want to see the rendered html page). In the less common case of wanting to link to foo.djot, you'd have to write out [foo](foo.djot).

Anyhow, sorry about the confusion above re double-delimiters vs double matching (left-right) delimiters. I missed that distinction when I wrote my comment.

Personally, I've never found the need for a [[foo]] syntax. For one thing, my file names often contain hyphens, but I don't want the link text to have the hyphen, e.g.:

[chocolate vs. vanilla](chocolate-vs-vanilla.html)

And another reason I haven't felt the need for them: most of the time I'm wanting to give a more descriptive link, as in [yes, I'm not kidding, cashew cheese nachos](cashew-nachos.html).

But, like I mentioned earlier, I can see it being useful specifically for implementing a wiki.

@uvtc When I say "a link to Tiger.djot", I mean a link in souce code level, so that a editor can know there's a link and we can jump between them. When converting to other format or rendering, the extension being added should be changed accordingly.

By the way, I just think we need a unambiguous standard to represent the link between source file, no matter using the wiki format or the format suggested by @bpj .

@jgm
Copy link
Owner Author

jgm commented Aug 13, 2022

@bpj's suggestion about conventions is a good one (and similar to what I did with gitit, where wikilinks were [Like This]()).
This would not require a change to the syntax; processors could simply implement this convention.

@waldyrious
Copy link
Contributor

Another advantage of [foo]() is consistency with the way label-less reference links already work in Djot — i.e., [foo][] is equivalent to [foo][foo].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants