Skip to content

Commit

Permalink
Added embedded imageg support
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Varotsis committed Oct 31, 2024
1 parent fc44a19 commit db0cc3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
File renamed without changes.
10 changes: 8 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ export default class ObsidianToQuartoPlugin extends Plugin {
}
}


convertObsidianImages(content: string): string {
// Convert Obsidian image syntax (![[image.png]]) to standard Markdown (![](<image.png>))
return content.replace(/!\[\[([^\]]+?)\]\]/g, '![]($1)');
}

async convertToQuarto(content: string, file: TFile): Promise<string> {
// Extract frontmatter if it exists
Expand Down Expand Up @@ -136,6 +139,9 @@ export default class ObsidianToQuartoPlugin extends Plugin {
convertedContent = convertedContent.slice(firstHeaderIndex);
}

// Convert Obsidian image syntax before other conversions
convertedContent = this.convertObsidianImages(convertedContent);

convertedContent = await this.convertEmbeddedNotes(convertedContent);

// Add line breaks before headers
Expand Down Expand Up @@ -368,4 +374,4 @@ declare module 'obsidian' {
workspace: Workspace;
metadataCache: MetadataCache;
}
}
}

0 comments on commit db0cc3b

Please sign in to comment.