Open pbaret opened 5 years ago
Suggested quick fix:
in helpers.js
_createClass(Helpers, null, [{
key: 'getPageIdFromFilenameOrLink',
value: function getPageIdFromFilenameOrLink(filename) {
var base = path.basename(filename);
if (base.substr(-3) === '.md') {
base = base.substr(0, base.length - 3);
}
var sp = base.split('#') // the problem comes from #PageId#AnchorId
if (sp.length == 2)
{
base = sp[1]
}
return base.replace(/([^a-z0-9\-_~.]+)/gi, '');
}
}]);
Special case for TOC links in mardown.js line 105
key: 'convertTocMarkdownString',
value: function convertTocMarkdownString(markdown) {
markdown = markdown.replace(/ *\([^)]*\) */g, function (allPattern, link) {
var sp = allPattern.split('#');
if (sp.length == 2)
{
allPattern = '(#' + sp[1]
}
return allPattern;
});
return {
tocHtml: this.convertMarkdownString(markdown, this.tocRenderer),
tocItems: this.tocItems
};
I precise I am not a JS developper nor familiar with node.js so this is really a quick tuning fix that worked for after digging into the sources.
I just found a bug in this package with anchors.
Let's say I have two md files in my wiki that I want to convert to html.
File1.md
GitHub automatically sets up anchors for the titles that I can reference in other wiki files to have a direct link.
File2.md
The thing is that when generating the html, because there is only one html page, this doesn't work. The reference put in the link in the html in my example is #File1title-1-of-file-1 instead of the expected #title-1-of-file-1