You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It sounds like you need to apply both :ignore and :target=_self to a link. From what I can see, docsify currently supports one or the other, but not both.
It would be nice if docsify had a generic method of applying attributes and docsify-specific flags. For example:
To render this HTML (which I believe is what you're looking for):
<ahref="/dev.web/" target="_self">Inicio</a>
As far as your issue is concerned, adding the link to the document using HTML instead of markdown would be another way to work around the docsify's markdown limitations.
plugins: [function(hook){hook.beforeEach(function(content){//enabling relative pathsvarurl=window.location.href;// Returns full URLvarlidx=url.lastIndexOf("/");varxurl=url.substring(0,lidx);varidx=xurl.indexOf("#");varpurl=xurl.substring(idx+1,xurl.length);returncontent.replace(/\[([^\]]*)\]\(([^)]*)\)/g,function(x){if(!x.includes("](/")){returnx.replace("](","]("+purl+"/")}returnx;})})}]
I mainly changed 2 things
I made sure the rewritten urls don't open a new window/tab and I made the detection of the relative page dynamic based if the urls startswith / or not
Reacted by Waldo, Igor García Olaizola and Vaishak Kallore
i just included an exception when the Docsify label "ignore" is used.
varurl=window.location.href;// Returns full URLlidx=url.lastIndexOf("/");xurl=url.substring(0,lidx);varidx=xurl.indexOf("#");varpurl=xurl.substring(idx+1,xurl.length);varroot_url=xurl.substring(0,idx-1);content=content.replace(/\[([^\]]*)\]\(([^)]*)\)/g,//enabling relative paths as they should be (by adding "/" in the beginning)function(x){if(!x.includes("](/")){if(x.includes(":ignore")){returnx.replace("](","]("+root_url+purl+"/");}returnx.replace("](","]("+purl+"/");}returnx;})
enables the use of "../" to go upwards in the directory tree
detects all no ".md" extensions or folders ("/") to automatically "ignore" the rest of content.
does not process external links ("http://" or "https://)
hook.beforeEach(function(content){//enabling relative paths (".." not allowed by now)varurl=window.location.href;// Returns full URLlidx=url.lastIndexOf("/");xurl=url.substring(0,lidx);varidx=xurl.indexOf("#");varpurl=xurl.substring(idx+1,xurl.length);varroot_url=xurl.substring(0,idx-1);content=content.replace(/(.)?\[([^\]]*)\]\(([^)]*)\)/g,//enabling relative paths as they should be (by adding "/" in the beginning)function(x){if(x.includes("){//enable relative pathsif((x.includes("\":ignore\""))||(x.includes("\":ignore\""))){returnx.replace("](","]("+root_url+purl+"/");}returnx.replace("](","]("+purl+"/");}else{if(x.includes(":ignore")){returnx.replace("](","]("+root_url);}}returnx;//just in case})returncontent;})
Activity
jhildenbiddle commentedon Apr 12, 2018
Perhaps I am misunderstanding, but wouldn't
/swaggerdo the trick?SidVal commentedon May 11, 2018
Hello, now I understand what he is trying to say.
Check this repo: https://github.com/SidVal/dev.web/tree/master/docs
Structure:
Site: https://sidval.github.io/dev.web/#/
Well., check this...
The
_sidebar.mdin the/clases/'s folder, is trying to link the "root" ... how can I do that?https://github.com/SidVal/dev.web/blame/master/docs/clases/_sidebar.md#L1
I tried with:
[Inicio](/dev.web)goes to: https://sidval.github.io/dev.web/#/dev.web (404 error)[Inicio](https://sidval.github.io/dev.web/#/?id=devweb)goes to "new page", so... did not work.[Inicio](../#devweb)goes to: https://sidval.github.io/dev.web/#/clases/../#dev.web (404 error)How can I do it?
jhildenbiddle commentedon May 11, 2018
If docsify's markdown conversion is the issue, try the link
:ignorehelper:Markdown:
HTML Output:
SidVal commentedon May 11, 2018
Thanks for replay @jhildenbiddle
With that tip the results were:
* [Inicio](../ ':ignore')➡️ https://sidval.github.io/ (open new tab, so no).* [Inicio](/dev.web/#devweb ':ignore')➡️ https://sidval.github.io/dev.web/#/devweb (new tab, 404)* [Inicio](/dev.web/?id=devweb ':ignore')➡️ https://sidval.github.io/dev.web/?id=devweb#/ (new tab, so no)Any way to linking the docs root without opening new tab?
QingWei-Li commentedon May 12, 2018
@SidVal https://docsify.js.org/#/configuration?id=externallinktarget
SidVal commentedon May 12, 2018
Thanks for replay @QingWei-Li ... but, if I change the
externalLinkTarget, all the site would link to_self, and that is not the idea.I need that ONE link goes to the root of the site, without opening a new tab
QingWei-Li commentedon May 13, 2018
@SidVal https://docsify.js.org/#/helpers?id=set-target-attribute-for-link
SidVal commentedon May 13, 2018
Thanks @QingWei-Li ... that should work., but...
I put this:
[Inicio](https://sidval.github.io/dev.web/ ':target=_self')Now you can check the site, and press "Inicio":
<a href="https://sidval.github.io/dev.web/" target="_blank">Inicio</a>jhildenbiddle commentedon May 13, 2018
It sounds like you need to apply both
:ignoreand:target=_selfto a link. From what I can see, docsify currently supports one or the other, but not both.It would be nice if docsify had a generic method of applying attributes and docsify-specific flags. For example:
The docsify flag wouldn't be represented in the HTML output, but the attributes would:
This method would allow the following markdown:
To render this HTML (which I believe is what you're looking for):
As far as your issue is concerned, adding the link to the document using HTML instead of markdown would be another way to work around the docsify's markdown limitations.
SidVal commentedon May 13, 2018
This
<a href="/dev.web/" target="_self">Inicio</a>works! 🎉Last version (v3)
Thanks @jhildenbiddle !
iolaizola commentedon Jun 6, 2018
In order to create absolute paths, I created a hook that makes the work when ":relative" is added to the links. E.g:
This is the hook:
SidVal commentedon Jun 7, 2018
Great @iolaizola can you explain how to add that hook please?
iolaizola commentedon Jun 8, 2018
Sure,
you have to edit the index.html where there is :
you have to create the environment for plugins if it does not exist:
and then you add the aforementioned function.
Hope it helps,
grimpy commentedon Nov 27, 2018
An adapted version of the above
I mainly changed 2 things
I made sure the rewritten urls don't open a new window/tab and I made the detection of the relative page dynamic based if the urls startswith / or not
jhildenbiddle commentedon Dec 5, 2018
@SidVal, @iolaizola, @grimpy --
Friendly docsify compatibility reminder:
The code listed above will break IE due to the use of String.prototype.includes(). Fortunately,
includes()can be easily swapped out forregex.test()orindexOf()for IE compatibility.iolaizola commentedon Dec 30, 2018
Great job @grimpy
i just included an exception when the Docsify label "ignore" is used.
iolaizola commentedon Jan 14, 2019
Here again,
I let a complete hook that:
SteveShaffer commentedon Feb 13, 2019
^ I tried this solution mutates and it appears to work for the first array on the page but these lines mutate
purlso subsequent relative links on the same page end up with an incorrect URL.