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 support? #714

Open
alex-netkachov opened this issue Jun 8, 2023 · 13 comments
Open

WikiLinks support? #714

alex-netkachov opened this issue Jun 8, 2023 · 13 comments

Comments

@alex-netkachov
Copy link

Hi! I'm looking for the WikiLinks support (links within two square brackets, e.g. https://python-markdown.github.io/extensions/wikilinks/). Does this library support it, via plugin maybe?

If it is not supported, I do not mind to implement it. Could you maybe guide me a bit on what would be the right approach?

Kind regards,
Alex

@xoofx xoofx added the question label Jul 8, 2023
@xoofx
Copy link
Owner

xoofx commented Jul 8, 2023

Hi! I'm looking for the WikiLinks support (links within two square brackets, e.g. https://python-markdown.github.io/extensions/wikilinks/). Does this library support it, via plugin maybe?

Not that I'm aware of.

If it is not supported, I do not mind to implement it. Could you maybe guide me a bit on what would be the right approach?

I would start with an existing similar parser like the LinkInlineParser but Wikilinks should be simpler in the end (no image support, no special link rules as in regular links).

@nightroman
Copy link

This feature would be great for parsing Obsidian notes.
No pressure, just wondering, any development or plans?

@alex-netkachov
Copy link
Author

As the topic starter, I feel that I need to inform you that I will not proceed with it further because I no longer use wikilinks. The name clashes in the large knowledge base have become too much of a nuisance.

@djradon
Copy link

djradon commented Oct 9, 2023

I would also love this feature... very useful for Dendron workspaces.

@alex-netkachov FYI, Dendron solves the namespacing issue using hierarchical dot notation, e.g. [[languages.c-sharp]] is distinct from [[tags.c-sharp]]

@QINGCHARLES
Copy link

Describe the basic specification for this.

Take a phrase in your document, e.g. cheese on toast

You add double square brackets around it, e.g. [[cheese on toast]]

It becomes an in the rendered document, with the href set to cheese_on_toast ?

What are the rules to slugify the phrases? How do you deal with punctuation?

Just trying to flesh it out. I'm using markdig for a wiki right now, but I'm forcing the users just to make full links because I've not got it smart enough to do it wiki-style yet.

@djradon
Copy link

djradon commented Oct 18, 2023

Hi @QINGCHARLES. I believe spaces in links are not supported, so it would look like [[cheese-on-toast]] which would set the href to "cheese-on-toast.md".

FWIW, I use the "VS Slug" plugin, which in turn uses https://github.com/sindresorhus/slugify - but I would say slugification shouldn't be necessary for this use case... Just expect the phrase to correspond directly to a filename without the ".md" extension.

@QINGCHARLES
Copy link

@djradon That's a format I've not seen before for "Wiki" style links. The original wikis used a strange CamelCaseFormat like that to create links, which clearly isn't very readable for normal humans. The link at the top of this thread, which I finally remembered to check out, uses basically the same format as WikiMedia, which is close to ideal as it allows spaces and punctuation in links and then does its best to slugify them in a way where they end up looking often identical to the original text.

The one I decided on for my wiki allows spaces in the text, but uses a hyphen instead of an underline in the link, and lower-cases everything, just because that's my personal preference for links.

I'm hard-pressed to see the use case for the one in your post -- is there a specific reason you don't want spaces in the link text? Obviously it makes converting it to a filename even easier, but filenames actually are less restricted than URL slugs as they can more easily have spaces in them.

@QINGCHARLES
Copy link

(p.s. I wish there was a way to hack into the InlineLink function to modify its functionality without having to write a whole new one from scratch)

@djradon
Copy link

djradon commented Oct 22, 2023

@QINGCHARLES My use case is for Dendron, which only allows dashes in filenames, and the wikilink corresponds directly to the filename (without the .md extension), see https://wiki.dendron.so/notes/90mrtp10ucyyvt60qekuj4y/. But supporting spaces would be fine, doesn't affect my use case.

@Temetra
Copy link

Temetra commented Nov 14, 2023

I wrote a simple extension for an Obsidian-based static site generator I'm working on, and thought I'd share it here. It'll probably need tweaking for other use cases, but hopefully someone finds it useful.

@djradon
Copy link

djradon commented Nov 14, 2023

It'll probably need tweaking for other use cases, but hopefully someone finds it useful.

Thanks! Unfortunately, Dendron wikilinks have reversed the page name and the alt text order, so [[UI Components|ui-components]] instead of what I now realize is the standard way of putting the actual page/note title first.

@Temetra
Copy link

Temetra commented Nov 14, 2023

Ah, that's a shame. I think the easiest way to fix that would be to swap the assignments in WikilinkParser.cs, lines 97-98.

@QINGCHARLES
Copy link

Yes, it would be easy to modify your code @Temetra. I checked it out, very nice, thank you. We need more example extensions like this to learn from.

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

No branches or pull requests

6 participants