Convert markdown links to relref link?

Hi, everyone.

I have several markdown files, each with some links like this:


However, I would like to convert all these links to:

[anotherfile]({{< relref "" >}})

Is there any easy approach to do this? I believe this can be done with regular expression, or there is some way to avoid this conversion?


Hm… Maybe try the replace function. But then again that might be a performance hit.

Take a look at the following comment in this Github issue. Someone was able to add a class to a <table> that was inserted with markdown.


Find: \]\(([^)]+)\)
Replace: ]({{< relref "$1" >}})

something like this, but not tested.

1 Like

Thanks very much! I slightly modified it so that the following shell command works in my case.

sed 's/\](\([A-Za-z-]*\.md\))/]({{< relref "\1" >}})/g'


1 Like

Thanks for the hit! There are not too many files so performance is not a problem, however I am not familiar with the template language, but I have solved the problem in my case with regular expression.

Thanks again!

1 Like