Skip to content

Commit

Permalink
fix: Link generation when # block
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Sep 19, 2022
1 parent e51d45e commit 5cadc8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions plugin/contents_conversion/convertLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions plugin/publishing/filesManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ 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;
if (checkFrontmatter && checkFrontmatter[this.settings.shareKey] === true) {
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 {
Expand Down Expand Up @@ -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
);

Expand Down

0 comments on commit 5cadc8f

Please sign in to comment.