11import { Plugin , WorkspaceLeaf , Notice } from 'obsidian' ;
22import { getAPI , Page } from 'obsidian-dataview' ;
33import * as PIXI from 'pixi.js' ;
4+ import extractLinks from 'markdown-link-extractor' ;
45
56export default class GraphLinkTypesPlugin extends Plugin {
67 // Retrieve the Dataview API
@@ -272,6 +273,7 @@ export default class GraphLinkTypesPlugin extends Plugin {
272273 break ;
273274 case LinkType . MarkdownLink :
274275 if ( this . extractPathFromMarkdownLink ( value ) === targetId ) {
276+ console . log ( targetId ) ;
275277 return key ;
276278 }
277279 break ;
@@ -281,6 +283,7 @@ export default class GraphLinkTypesPlugin extends Plugin {
281283 return key ;
282284 }
283285 if ( this . determineLinkType ( item ) === LinkType . MarkdownLink && this . extractPathFromMarkdownLink ( item ) === targetId ) {
286+ console . log ( targetId ) ;
284287 return key ;
285288 }
286289 }
@@ -293,10 +296,13 @@ export default class GraphLinkTypesPlugin extends Plugin {
293296
294297 // Utility function to extract the file path from a Markdown link
295298 private extractPathFromMarkdownLink ( markdownLink : string ) : string {
296- const match = markdownLink . match ( / \[ .* \] \( ( .* ?) \) / ) ;
297- return match ? match [ 1 ] : '' ;
299+ const links = extractLinks ( markdownLink ) . links ;
300+ console . log ( links [ 0 ] ) ;
301+ // The package returns an array of links. Assuming you want the first link.
302+ return links . length > 0 ? links [ 0 ] : '' ;
298303 }
299304
305+
300306 // Utility function to check if a value is a Markdown link
301307 isMarkdownLink ( value : any , targetId : string ) : boolean {
302308 if ( typeof value === 'string' ) {
0 commit comments