diff --git a/src/constants.ts b/src/constants.ts index 08348a6..d12f086 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,8 +1,8 @@ export const MM_VIEW_TYPE = 'mindmap'; -export const MD_VIEW_TYPE = 'markdown'; +export const MD_VIEW_TYPE = 'markdown'; -// https://regex101.com/r/gw85cc/2 -export const INTERNAL_LINK_REGEX = /\[\[(?.*)\]\]|(?.*)<\/a>/gim; +// https://regex101.com/r/aWdgvf/1 +export const INTERNAL_LINK_REGEX = /\[\[(?.*?)((\|)(?.*)\]\]|\]\])|(?.*)<\/a>/gim; // https://regex101.com/r/Yg7HuO/2 -export const FRONT_MATTER_REGEX = /^(---)$.+?^(---)$.+?/ims; \ No newline at end of file +export const FRONT_MATTER_REGEX = /^(---)$.+?^(---)$.+?/ims; diff --git a/src/obsidian-markmap-plugin.ts b/src/obsidian-markmap-plugin.ts index c3fab71..ac194e2 100644 --- a/src/obsidian-markmap-plugin.ts +++ b/src/obsidian-markmap-plugin.ts @@ -21,8 +21,14 @@ export default class ObsidianMarkmap { for (let i = 0; i < matches.length; i++) { const match = matches[i]; const isWikiLink = match.groups['wikitext']; - const linkText = isWikiLink ? match.groups['wikitext'] : match.groups['mdtext']; - const linkPath = isWikiLink ? linkText : match.groups['mdpath']; + var linkText, linkPath; + if (isWikiLink) { + linkText = match.groups['wikialias'] ? match.groups['wikialias'] : match.groups['wikitext']; + linkPath = match.groups['wikitext']; + } else { + linkText = match.groups['mdtext']; + linkPath = match.groups['mdpath']; + } if(linkPath.startsWith('http')){ continue; } @@ -41,4 +47,4 @@ export default class ObsidianMarkmap { return matches; } -} \ No newline at end of file +}