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
Configure external link recognition (and handling) #193
Comments
Same as #215? |
yep I guess so, and more or less #361 |
although with #215 it is more than just leaving it as an external link, but turning it into a download link. |
This made it very easy to make custom urls be parsed into whatever end result. Including stuff like |
errr, it may be possible to do that here.
Or you could create a new sphinx role for special links: |
@chrisjsewell
The |
I personally just use Sphinx's extlinks extension, which I assume is essentially what @chrisjsewell is referring to as new Sphinx roles. Sure, you might prefer the syntax to be |
@jpmckinney I don't expect For Myst to be a replacement for |
Well myst has already replaced recommonmark 😉: readthedocs/recommonmark#221 its not out of the question, but I feel this is more of a "power-user" feature, that could be easily replicated with an external transform: e.g. simply add to you conf.py # available in the next release
myst_all_links_external = True
# or
myst_url_schemes = ("http", "https", "mailto", "ftp", "issue")
from docutils import nodes
from sphinx.transforms import SphinxTransform
class MyTransform(SphinxTransform):
default_priority = 1
def apply(self, **kwargs) -> None:
for node in self.document.traverse(nodes.reference):
if "refuri" in node and node["refuri"].startswith("issue:"):
node["refuri"] = "whatever you want"
node["classes"].append("my-class")
def setup(app):
app.add_transform(MyTransform) |
You'll see in my example above, as well as being more inline with how sphinx operates, you can even set CSS classes on the node and really do whatever you want with it |
Is it accurate to say this issue is why |
Yep, and that will change in myst-parser 0.17 |
Currently, if a link (
[text](link)
) does not match a URL scheme (e.g. 'http://...') then it is treated as an internal cross-reference (to a reference target or sphinx document, etc):MyST-Parser/myst_parser/docutils_renderer.py
Lines 412 to 415 in 3d5ae4f
In some use cases a configuration option could be useful, such that links with certain extensions (or regexes) are converted to external links, rather than attempting to resolve them as internal links
Originally posted by @chrisjsewell in executablebooks/jupyter-book#823 (comment)
The text was updated successfully, but these errors were encountered: