Same article on GitHub Gist
TL;DR
Here’s my configuraiton (in data.json):
{
“entry”: “/ (\^\w+)$/gm”,
“replace”: ” <a id=“$1“></a>”,
“flags”: “”,
“after”: true
},
{
“entry”: “/#(\^\w+)\)/gm”,
“replace”: “#user-content-$1)”,
“flags”: “”,
“after”: true
}
],
Background
A link to a block in a note of Obsidian
Obsidian GitHub Publisher (the plugin)
What I miss
The plugin does not convert a unique block identifier ^identifier to an HTML anchor <a id=”^identifier”></a>.
Thus, a link to a block in a note [[note#^identifier]] or [text](note#^identifier) does not work.
1st try
I configured the plugin to replace a unique block identifier to an HTML anchor:
Regular expression to match: / (^w+)$/gm
Text to substitue: <a id=”$1″></a>
Surprise by GitHub Markdown renderer
Later, I found that GitHub Markdown renderer adds a prefix user-content- to each HTML ID,
e.g. id=”^identifier” becomes id=”user-content-^identifier”.
2nd try
I configured the plugin to add the prefix to each link:
Regular expression to match: /#(^w+))/gm
Text to substitute: #user-content-$1)
And everything is okay now.