Allow for substitutions inside link targets
See original GitHub issueIn https://github.com/jupyterhub/zero-to-jupyterhub-k8s/pull/1968#issuecomment-751473053, @consideRatio mentioned that it’d be useful to be able to use substitutions inside things like inline elements. In this case, for the target of a link. I believe he wanted to do something like:
myst:
substitutions:
version: v3
---
Here is an [inline link with the target version](https://myorg.com/{{ version }}/docs)
I don’t think that this is currently possible, but I could see it being useful (e.g., if you’re linking to the same external documentation that has a regularly-changing root, such as one based on a version).
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Substitutions inside links in reST / Sphinx - Stack Overflow
I am using Sphinx to document a webservice that will be deployed in different servers. The documentation is full of URL ...
Read more >Customize the Substitutions Applied to Blocks - Asciidoctor Docs
The substitutions that get applied to a block (and to certain inline elements) can be changed or modified using the subs element attribute....
Read more >content editor - Setting the target on an internal link field
This is a known issue with the General Link Field . To fix it open the Core database and navigate too:.
Read more >reStructuredText Markup Specification - Docutils - SourceForge
The explicit markup syntax is used for footnotes, citations, hyperlink targets, directives, substitution definitions, and comments. An explicit markup block is ...
Read more >Supply Chain Plan Business Topics - Oracle Help Center
Select the Substitutes button. Please note that multiselects are not allowed. If you select several items, the Substitutes button will be greyed out....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you both @choldgraf and @chrisjsewell!
I ended up with the full link substitution, where markdown for the entire link was decided in conf.py (here). In other words, I ended up doing what @chrisjsewell suggested with the example…
EDIT: Thank you a lot @chrisjsewell for describing this, it was a missing piece of understanding for me:
Ah no this is not how it works, its a bit more nuanced than that:
Firstly the substitutions have to be identified by the markdown-it plugin and converted to a specific syntax token, they can’t just be placed anywhere (as it says in the documentation)
Secondly they don’t just “copy/paste” the text from the substitution definition to the reference; the text from the definition is parsed to AST in isolation (after jinja filters have been applied), then injected into the documents AST.
This, for example, allows for you to inject directives into inline text, e.g. to create this crazy table from https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html#substitutions-with-jinja2:
if you just copied:
into:
you would end up with:
which obviously would not be recognised or rendered as a table.
If you wanted this, its more of just a plain jinja pre-conversion of the source file, that has no concept of the actual document.
or you could do:
(I tested this and it works)
or in the conf.py