diff --git a/plugin/contents_conversion/convertLinks.ts b/plugin/contents_conversion/convertLinks.ts index 11fb763c..0ba6ebc7 100644 --- a/plugin/contents_conversion/convertLinks.ts +++ b/plugin/contents_conversion/convertLinks.ts @@ -104,6 +104,10 @@ export function convertLinkCitation( if (matchedLink) { for (const link of matchedLink) { const regToReplace = new RegExp(`${linkedFile.linkFrom}`); + const block_link = linkedFile.linkFrom.match(/#.*/) + if (block_link) { + pathInGithub += block_link[0]; + } const newLink = link.replace(regToReplace, pathInGithub); //strict replacement of link fileContent = fileContent.replace(link, newLink); } diff --git a/plugin/publishing/filesManagement.ts b/plugin/publishing/filesManagement.ts index 8cf575d1..302601f5 100644 --- a/plugin/publishing/filesManagement.ts +++ b/plugin/publishing/filesManagement.ts @@ -93,7 +93,7 @@ export class FilesManagement extends Publisher { if (imageEmbedded != undefined) { for (const image of imageEmbedded) { try { - const imageLink = this.metadataCache.getFirstLinkpathDest(image.link, file.path) + const imageLink = this.metadataCache.getFirstLinkpathDest(image.link.replace(/#.*/, ''), file.path) if (imageLink !== null) { if (imageLink.extension === 'md') { const checkFrontmatter = this.metadataCache.getCache(imageLink.path).frontmatter; @@ -101,7 +101,7 @@ export class FilesManagement extends Publisher { linkedFiles.push({ linked: imageLink, //TFile found linkFrom: image.link, //path of the founded file - altText: image.displayText //alt text if exists, filename otherwise + altText: image.displayText, //alt text if exists, filename otherwise }) } } else { @@ -167,7 +167,7 @@ export class FilesManagement extends Publisher { for (const embed of embedCaches) { try { const imageLink = this.metadataCache.getFirstLinkpathDest( - embed.link, + embed.link.replace(/#(.*)/, ''), file.path );