From 4d1dff32fa48567891cf25275f3ce4624b92d25d Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 4 Aug 2021 08:39:57 +0200 Subject: [PATCH] OrgMode: Add images with the correct markup It was using the markdown syntax. Related to #145 --- lib/core/note.dart | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/core/note.dart b/lib/core/note.dart index 1867605b..347cdfef 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -492,20 +492,29 @@ class Note with NotesNotifier { var absImagePath = _buildImagePath(file); await file.copy(absImagePath); - addImageMarkdown(absImagePath); + if (_fileFormat == NoteFileFormat.OrgMode) { + _addImageOrgMode(absImagePath); + return; + } + _addImageMarkdown(absImagePath); } - void addImageMarkdown(String absImagePath) { + void _addImageMarkdown(String absImagePath) { var relativeImagePath = p.relative(absImagePath, from: parent.folderPath); if (!relativeImagePath.startsWith('.')) { relativeImagePath = './$relativeImagePath'; } var imageMarkdown = "![Image]($relativeImagePath)\n"; - if (body.isEmpty) { - body = imageMarkdown; - } else { - body = "$body\n$imageMarkdown"; + body = body.isEmpty ? imageMarkdown : "$body\n$imageMarkdown"; + } + + void _addImageOrgMode(String absImagePath) { + var relativeImagePath = p.relative(absImagePath, from: parent.folderPath); + if (!relativeImagePath.startsWith('.')) { + relativeImagePath = './$relativeImagePath'; } + var imageMarkdown = "[[$relativeImagePath]]\n"; + body = body.isEmpty ? imageMarkdown : "$body\n$imageMarkdown"; } String _buildImagePath(File file) {