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

Markdown: Improve/Customize WikiLinks #860

Closed
Screwtapello opened this issue Feb 20, 2020 · 8 comments
Closed

Markdown: Improve/Customize WikiLinks #860

Screwtapello opened this issue Feb 20, 2020 · 8 comments

Comments

@Screwtapello
Copy link

@Screwtapello Screwtapello commented Feb 20, 2020

General information

  • App version: 2.2.7 (F-Droid)
  • System: Android 10, Nokia 6.1

Description

Please re-enable character-escaping for wiki links

  1. Create an empty directory.

  2. Inside that directory, create foo bar.md with contents:

     Failed
    
  3. Create another file beside it, named foo-bar.md with contents:

     Success
    
  4. Create yet another file, test.md with contents:

     [[foo bar]]
    
  5. Tap the eyeball icon to switch from edit mode to view mode.

  6. Tap the "foo bar" link.

Expected result: a page displaying "Success"

Actual result: a page displaying "Failed"

Notes

On 2019-01-12, issue #486 was created, asking for support for wiki links.

On 2019-03-10, the issue was closed by commit e7a0323, which enabled existing wikilink support in the Markdown renderer Markor already uses.

On 2019-03-18, commit eb709aa configured the wikilink extension to disable all character escaping, so that all the text in the wiki-link is used directly in the generated URL. There doesn't seem to be an associated issue explaining why this change was made, but the 1.8.0 changelog mentions "Disable default escaped characters, so subfolder path is not converted to hyphen".

So far as I can tell, Flexmark's default escaping rules make it basically compatible with GitHub's wiki implementation. For example, Markor's own wiki has a page named "Sync with Syncthing, work with Markor", whose URL is Sync-with-Syncthing,-work-with-Markor - the spaces have been replaced with dashes. That's not just the URL, either - if you clone the wiki's git repo locally, you'll see that's the actual file-name it uses too. I don't actually have an existing wiki that uses a slash in a page-name, but if you try it yourself you'll see GitHub also replaces slashes with dashes in URLs and file-names.

There's a lot of GitHub wikis in the world, and it would be nice if Markor could work with them by default, or at least could be configured to work with them.

@gsantner
Copy link
Owner

@gsantner gsantner commented Feb 25, 2020

set(WikiLinkExtension.LINK_ESCAPE_CHARS, "-") is what you need?

I'm on mobile and no time to look it up, but very sure that somebody told me about some issue that resulted in said change.

I don't use and don't recommend to use WikiLink. It might be a cool addition, but it's not compatible with most Markdown software. why not just use md link syntax?

@Screwtapello
Copy link
Author

@Screwtapello Screwtapello commented Feb 27, 2020

What I'd really like is for Markor to be compatible with whatever GitHub's wiki software does, but unfortunately I can't find any concrete documentation about exactly what it does, and even though it's open-source I'm not good at Ruby so I can't find the relevant part of the code. In lieu of that, I think a minimal change would be something like:

set(WikiLinkExtension.LINK_ESCAPE_CHARS, " ")
set(WikiLinkExtension.LINK_REPLACE_CHARS, "-")

As for the choice of syntax: regular Markdown links give me the power to link to very specific URLs in a way that looks attractive even when unformatted, but they require me to think about low-level details like figuring out what URL the target document will have after it's converted to HTML, and converting that URL to be relative to the source document's eventual URL. Wiki links are more limited, but all I have to do is add square brackets around what I was already writing anyway — everything else is taken care of automatically. When I'm hurriedly taking notes, the more I can concentrate on the actual words I'm writing and the less I have to think about technical details, the better, especially on a tiny phone keyboard!

@gsantner gsantner changed the title Please re-enable character-escaping for wiki links Markdown: Improve/Customize WikiLinks Feb 27, 2020
@gsantner gsantner added this to the Community Contribution milestone Feb 27, 2020
@GlenHertz
Copy link

@GlenHertz GlenHertz commented Apr 4, 2020

I really like the app. It seems that Markor supports the following today:

[[a file name]]

which will lookup a file name.md. But it doesn't seem like there is a way to create these Wiki links. If there was an option for If filename and description are the same use Wiki link then the Insert Link file picker could produce the shorter link. Using these Wiki links makes the raw text much easier to read. As a bonus if the user has a Wiki link then Markor could create the file automatically instead of trying to open up a Share to 3rd party app. Currently it takes a lot of repetitive text typing to do this.

@gsantner
Copy link
Owner

@gsantner gsantner commented Apr 4, 2020

Stay with Markdown links ( [title](link.md) ) as far possible. This "extension" is not supported by most other markdown applications, hence not suggested.

@GlenHertz
Copy link

@GlenHertz GlenHertz commented Apr 5, 2020

Thanks for the tip and I would prefer to keep with standards as much as possible. My issue is I'm using Markdown for Zettelkasten and many of the Zettelkasten apps use [[another file]] format for internal links. See here. The regular Markdown links are external and don't search the directories for local files. I only use one directory so the internal links work in Markor as it is the best Android app and I still want to use it. Thanks again. Your app is really nice.

@aisbergde
Copy link

@aisbergde aisbergde commented Jun 6, 2020

I also support these 2 ideas:

  • allow space to be converted into "-", maybe as an option and not hard coded
  • ask to create the file or just create it, if the link doesn't exists.
    this is the more important feature for me as I can force me to use "-"

I found a corresponding VSC extension which support the wikilinks on desktop:

https://marketplace.visualstudio.com/items?itemName=kortina.vscode-markdown-notes

Use [[wiki-links]], backlinks, and #tags for fast-navigation of markdown notes.

Automatically create notes from new inline [[wiki-links]].

@aisbergde
Copy link

@aisbergde aisbergde commented Jun 6, 2020

Stay with Markdown links ( [title](link.md) ) as far possible. This "extension" is not supported by most other markdown applications, hence not suggested.

To follow this advice I could also imagine to use wikilink style to easy create links but to use any tool to convert them in a standard link [title](link.md). This could also be a tool outside Markor. Maybe some PowerShell Skript. Maybe something already exists.

I agree they are harder to read, but some editors do not support them and some support them in a different way. Having them converted no different interpretation is possible, but title and link are clear defined.

Currently I think about how to build a link system with "stable" which will not broken when the linked file will be renamed. This is not possible with wikilinks, but it would be possible to detect missing linked files and to keep the title with [title](link.md). The title would not change but the underlying link. There could also be some batch processing outside Markor.

Anyway I want to keep the idea to easy create files for missing links. But this will be related not only to wikilinks but it is a general request. I would call this

missing file handling:
if a link not exists the user should get a warning and several options

  • replace link by an existing file
  • create new file
  • do nothing

@gsantner
Copy link
Owner

@gsantner gsantner commented Sep 20, 2020

Hey, I'm closing this ticket.

As I've said already many times by email, chats etc: I want Markor to be have best interoptability. WikiLinks not works at most other Markdown Software, so it doesn't fit to that.

Said, if somebody wants something with wikilinks improved, send a PR. Otherwise, WikiLinks stays as is and I won't make changes on it as it is now. See it as a little bonus feature, but don't expect fixes/support for WikiLinks.

In general: Use plain Markdown links, that works everywhere.

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

Successfully merging a pull request may close this issue.

None yet
4 participants