How to hyperlink with myST substitute

133 Views Asked by At

I am building documentation of my project using Sphinx, Doxygen and CMake.

In my project, there are several markdown files where I have to hyperlink different links. There is a common style in these links, they are from a common source.

https://common/source/html/a.html
https://common/source/html/b.html
https://common/source/html/c.html

So, right now I am hyperlinking as like as follows:

[This is a](https://common/source/html/a.html)
[This is b](https://common/source/html/b.html)
[This is c](https://common/source/html/c.html)

My desire is to use a variable which will hold this common addres https://common/source/html/ and then I can just modify the previous code snippet as lie as follows:

[This is a](COMMON_ADDRESSa.html)
[This is b](COMMON_ADDRESSb.html)
[This is c](COMMON_ADDRESSc.html)

I have gone through myST docs and git issue and find some approached but failed

  • Approach 1
    Here, in sphinx's conf.pyI have added
myst_enable_extensions = [
    # ...
    'substitution'
]

myst_substitutions = {
 "a_link": f"[TARGET NAME](https://common/source/html/)",
}

This takes me to index.html if I add in my markdown file {{a_link}}. But my desire is to concatenate html files from markdown file and have no idea how to do it. I have tried {{a_link}}/a.html but it does not work.

  • Approach 2
    Here also the target name and complete link address is written. No way to concatenate link address is described

  • I have also tried to replace common address by using rst_prolog which is also failed

I guess that I am not understanding how the hyperlinking process is working in markdown file.

So, I am searching for a way where I can parse the long address which will be assigned in a variable and can concatenate required html file name with it to perform hyperlinking.

0

There are 0 best solutions below