mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-26 21:00:17 +08:00
Fix relative Markdown links
While implementing Wiki Links, I seem to have accidentally broken them.
This commit is contained in:
@ -9,11 +9,14 @@ class LinkResolver {
|
||||
|
||||
Note resolve(String link) {
|
||||
var spec = link;
|
||||
var rootFolder = inputNote.parent.rootFolder;
|
||||
var folder = inputNote.parent;
|
||||
|
||||
if (link.startsWith('[[') && link.endsWith(']]') && link.length > 4) {
|
||||
// FIXME: What if the case is different?
|
||||
spec = link.substring(2, link.length - 2).trim();
|
||||
|
||||
// In the case of Wiki Links we always resolve from the Root Folder
|
||||
folder = inputNote.parent.rootFolder;
|
||||
}
|
||||
|
||||
if (link.startsWith('./')) {
|
||||
@ -24,20 +27,20 @@ class LinkResolver {
|
||||
spec = p.normalize(spec);
|
||||
}
|
||||
|
||||
var linkedNote = rootFolder.getNoteWithSpec(spec);
|
||||
var linkedNote = folder.getNoteWithSpec(spec);
|
||||
if (linkedNote != null) {
|
||||
return linkedNote;
|
||||
}
|
||||
|
||||
if (!spec.endsWith('.md')) {
|
||||
linkedNote = rootFolder.getNoteWithSpec(spec + '.md');
|
||||
linkedNote = folder.getNoteWithSpec(spec + '.md');
|
||||
if (linkedNote != null) {
|
||||
return linkedNote;
|
||||
}
|
||||
}
|
||||
|
||||
if (!spec.endsWith('.txt')) {
|
||||
linkedNote = rootFolder.getNoteWithSpec(spec + '.txt');
|
||||
linkedNote = folder.getNoteWithSpec(spec + '.txt');
|
||||
if (linkedNote != null) {
|
||||
return linkedNote;
|
||||
}
|
||||
|
Reference in New Issue
Block a user