MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.72k stars 38 forks source link

feature: additional link element for the Vimwiki link #117

Closed greyHairChooseLife closed 3 months ago

greyHairChooseLife commented 3 months ago

Is your feature request related to a problem? Please describe.

I might be able to say it's a problem.

The Vimwiki users have different kinds of links. I, as a noob, use 2 of them. Links for another wiki(.md) and for a URL.

It would be great if we can select icons and highlight for each of them.

Describe the solution you'd like

Links can be identified with simple regex. They start with 'http' or 'file' or something like that.

Describe alternatives you've considered

I am 100% sure that above is simple solution!!

Additional information

No response

MeanderingProgrammer commented 3 months ago

What kind of link are you referring to?

Is it the standard markdown link syntax: [link](https://example.com), and you want to be able to set a different icon based on the value looking like a URL?

I'm confused on what part of this is related to Vimwiki.

MeanderingProgrammer commented 3 months ago

Feature added here: https://github.com/MeanderingProgrammer/markdown.nvim/commit/d5b57b32397c0be1f511f4cdf2b876c5b1f01144

Uses lua patterns.

greyHairChooseLife commented 2 months ago

@MeanderingProgrammer Thank you so much, and I apologize for any confusion.

You've managed to address my issue even though I didn't clearly explain what I was asking for.

I've just applied the changes to my config, and I'm really pleased with the result. Here's a screenshot of how it looks:

2024-08-14-155800_429x159_scrot


What kind of link are you referring to?

Is it the standard markdown link syntax: [link](https://example.com), and you want to be able to set a different icon based on the value looking like a URL?

I'm confused on what part of this is related to Vimwiki.

Sorry for the delayed response. I'm copying a part of the Vimwiki help doc, just in case.

vimwiki syntax links from :help doc ``` 5.2. Links *vimwiki-syntax-links* Wikilinks~ Plain link: > [[This is a link]] With description: > [[This is a link source|Description of the link]] Wiki files don't need to be in the root directory of your wiki, you can put them in subdirectories as well: > [[projects/Important Project 1]] To jump from that file back to the index file, use this link: > [[../index]] or: > [[/index]] The latter works because wiki links starting with "/" are considered to be absolute to the wiki root directory, that is, the link [[/index]] always opens the file /path/to/your/wiki/index.wiki, no matter in which subdirectory you are currently in. If you want to use an absolute path to a wiki page on your local filesystem, you can prefix the path with // > [[//absolute_path]] For example: > [[///tmp/in_root_tmp]] [[//~/in_home_dir]] [[//$HOME/in_home_dir]] In a wiki with the default wiki extension, this link: > [[///tmp/foo]] Links to the file: > /tmp/foo.wiki Links to subdirectories inside the wiki directory are also supported. They end with a "/": > [[a subdirectory/|Other files]] Use |g:vimwiki_dir_link| to control the behavior when opening directories. Typing wikilinks can be simplified by using Vim's omni completion (see |compl-omni|) like so: > [[ind which opens up a popup menu with all the wiki files starting with "ind". When |vimwiki-option-maxhi| equals 1, a distinct highlighting style is used to identify wikilinks whose targets are not found. Interwiki~ If you maintain more than one wiki, you can create interwiki links between them by adding a numbered prefix "wikiX:" in front of a link: > [[wiki1:This is a link]] or: > [[wiki1:This is a link source|Description of the link]] The number behind "wiki" is in the range 0..N-1 and identifies the destination wiki in |g:vimwiki_list|. Named interwiki links are also supported in the format "wn.name:link" > [[wn.My Name:This is a link]] or: > [[wn.MyWiki:This is a link source|Description of the link]] See |vimwiki-option-name| to set a per wiki name. Diary~ The "diary:" scheme is used to link to diary entries: > [[diary:2012-03-05]] Anchors~ A wikilink, interwiki link or diary link can be followed by a '#' and the name of an anchor. When opening a link, the cursor jumps to the anchor. > [[Todo List#Tomorrow|Tasks for tomorrow]] To jump inside the current wiki file you can omit the file: > [[#Tomorrow]] See |vimwiki-anchors| for how to set an anchor. Raw URLs~ Raw URLs are also supported: > https://github.com/vimwiki/vimwiki.git mailto:habamax@gmail.com ftp://vim.org External files~ The "file:" and "local:" schemes allow you to directly link to arbitrary resources using absolute or relative paths: > [[file:/home/somebody/a/b/c/music.mp3]] [[file:C:/Users/somebody/d/e/f/music.mp3]] [[file:~/a/b/c/music.mp3]] [[file:../assets/data.csv|Important Data]] [[local:C:/Users/somebody/d/e/f/music.mp3]] [[file:/home/user/documents/|Link to a directory]] These links are opened with the system command, i.e. !xdg-open (Linux), !open (Mac), or !start (Windows). To customize this behavior, see |VimwikiLinkHandler|. In Vim, "file:" and "local:" behave the same, i.e. you can use them with both relative and absolute links. When converted to HTML, however, "file:" links will become absolute links, while "local:" links become relative to the HTML output directory. The latter can be useful if you copy your HTML files to another computer. To customize the HTML conversion of links, see |VimwikiLinkConverter|. Transclusion (Wiki-Include) Links~ Links that use "{{" and "}}" delimiters signify content that is to be included into the HTML output, rather than referenced via hyperlink. Wiki-include URLs may use any of the supported schemes, may be absolute or relative, and need not end with an extension. The primary purpose for wiki-include links is to include images. Transclude from a local URL: > {{file:../../images/vimwiki_logo.png}} or from a universal URL: > {{https://raw.githubusercontent.com/vimwiki/vimwiki/master/doc/splash.png}} Transclude image with alternate text: > {{https://raw.githubusercontent.com/vimwiki/vimwiki/master/doc/splash.png|Vimwiki}} in HTML: > Vimwiki Transclude image with alternate text and some style: > {{https://.../vimwiki_logo.png|cool stuff|style="width:150px;height:120px;"}} in HTML: > cool stuff Transclude image _without_ alternate text and with a CSS class: > {{https://.../vimwiki_logo.png||class="center flow blabla"}} in HTML: > A trial feature allows you to supply your own handler for wiki-include links. See |VimwikiWikiIncludeHandler|. Thumbnail links~ > Thumbnail links are constructed like this: > [[https://someaddr.com/bigpicture.jpg|{{https://someaddr.com/thumbnail.jpg}}]] in HTML: > [Id]: URL then the URL is opened with the system default handler. Otherwise, Vimwiki treats the reference-style link as a Wikilink, interpreting the Id field as a wiki page name. Highlighting of existing links when |vimwiki-option-maxhi| is activated identifies links whose Id field is not defined, either as a reference-link or as a wiki page. To scan the page for new or changed definitions for reference-links, simply re-open the page ":e". Extract title from external links~ It is possible to automagically extract the title of a web page to create a link. The function #vimwiki#base#linkify() will get the URL under the cursor and replace the url with a markdown link. If the URL cannot be retrieved, nothing is changed. If the html tag cannot be extracted, the url is used as the link title. Suggested mapping: > nnoremap <silent> <leader>uu :call vimwiki#base#linkify()<cr> ``` </details> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>