mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 00:29:20 +08:00
OrgMode: Add images with the correct markup
It was using the markdown syntax. Related to #145
This commit is contained in:
@ -492,20 +492,29 @@ class Note with NotesNotifier {
|
|||||||
var absImagePath = _buildImagePath(file);
|
var absImagePath = _buildImagePath(file);
|
||||||
await file.copy(absImagePath);
|
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);
|
var relativeImagePath = p.relative(absImagePath, from: parent.folderPath);
|
||||||
if (!relativeImagePath.startsWith('.')) {
|
if (!relativeImagePath.startsWith('.')) {
|
||||||
relativeImagePath = './$relativeImagePath';
|
relativeImagePath = './$relativeImagePath';
|
||||||
}
|
}
|
||||||
var imageMarkdown = "\n";
|
var imageMarkdown = "\n";
|
||||||
if (body.isEmpty) {
|
body = body.isEmpty ? imageMarkdown : "$body\n$imageMarkdown";
|
||||||
body = imageMarkdown;
|
|
||||||
} else {
|
|
||||||
body = "$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) {
|
String _buildImagePath(File file) {
|
||||||
|
Reference in New Issue
Block a user