Skip to content

Commit

Permalink
feat: Add non-path resolution to wikilinks
Browse files Browse the repository at this point in the history
related to  #2
  • Loading branch information
Feel-ix-343 committed Mar 1, 2024
1 parent 909dfee commit 23e62d1
Showing 1 changed file with 21 additions and 48 deletions.
69 changes: 21 additions & 48 deletions src/vault/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,8 @@ impl Reference {
MDIndexedBlockLink(_, _, _) => false,
},
&Referenceable::File(..) | &Referenceable::UnresovledFile(..) => match self {
WikiFileLink(..) => {
referenceable.get_refname(root_dir).as_deref() == Some(text)
},
MDFileLink(ReferenceData { reference_text: file_ref_text, .. }) => matches_path_or_file(file_ref_text, referenceable.get_refname(root_dir)),
MDFileLink(ReferenceData { reference_text: file_ref_text, .. })
| WikiFileLink(ReferenceData { reference_text: file_ref_text, .. }) => matches_path_or_file(file_ref_text, referenceable.get_refname(root_dir)),
Tag(_) => false,
WikiHeadingLink(_, _, _) => false,
WikiIndexedBlockLink(_, _, _) => false,
Expand All @@ -677,11 +675,9 @@ impl Reference {
| &Referenceable::UnresolvedHeading(.., infile_ref, _)
| &Referenceable::IndexedBlock(.., MDIndexedBlock { index: infile_ref, ..})
| &Referenceable::UnresovledIndexedBlock(.., infile_ref) => match self {
WikiHeadingLink(..)
| WikiIndexedBlockLink(..) => {
referenceable.get_refname(root_dir).as_deref() == Some(text)
}
MDHeadingLink(.., file_ref_text, link_infile_ref)
WikiHeadingLink(.., file_ref_text, link_infile_ref)
| WikiIndexedBlockLink(.., file_ref_text, link_infile_ref)
| MDHeadingLink(.., file_ref_text, link_infile_ref)
| MDIndexedBlockLink(.., file_ref_text, link_infile_ref) =>
matches_path_or_file(file_ref_text, referenceable.get_refname(root_dir)) && link_infile_ref == infile_ref,
Tag(_) => false,
Expand Down Expand Up @@ -1100,57 +1096,34 @@ impl Referenceable<'_> {
..
})
| WikiHeadingLink(.., file_ref_text, _)
| WikiIndexedBlockLink(.., file_ref_text, _) => self
.get_refname(root_dir)
.is_some_and(|refname| *refname == *file_ref_text),



MDFileLink(ReferenceData {
| WikiIndexedBlockLink(.., file_ref_text, _)
| MDFileLink(ReferenceData {
reference_text: file_ref_text,
..
})
| MDHeadingLink(.., file_ref_text, _)
| MDIndexedBlockLink(.., file_ref_text, _) => {
matches_path_or_file(file_ref_text, self.get_refname(root_dir))
}



Tag(_) => false,



Footnote(_) => false,
},


Referenceable::Heading(..) | Referenceable::UnresolvedHeading(..) => match reference {
WikiHeadingLink(data, ..) | MDHeadingLink(data, ..) => {
Some(&data.reference_text) == self.get_refname(root_dir).as_deref()
}
Tag(..) => false,
WikiFileLink(..) => false,
WikiIndexedBlockLink(..) => false,
MDFileLink(..) => false,
MDIndexedBlockLink(..) => false,
Footnote(..) => false,
},


Referenceable::IndexedBlock(..) | Referenceable::UnresovledIndexedBlock(..) => {
match reference {
WikiIndexedBlockLink(..) | MDIndexedBlockLink(..) => {
Some(text) == self.get_refname(root_dir).as_deref()
}
Tag(_) => false,
WikiFileLink(_) => false,
WikiHeadingLink(_, _, _) => false,
MDFileLink(_) => false,
MDHeadingLink(_, _, _) => false,
Footnote(_) => false,
Referenceable::Heading(.., MDHeading { heading_text: ref infile_ref, .. })
| Referenceable::UnresolvedHeading(.., &ref infile_ref)
| Referenceable::IndexedBlock(_, MDIndexedBlock { index: ref infile_ref, .. })
| Referenceable::UnresovledIndexedBlock(_, _, &ref infile_ref) => match reference {
WikiHeadingLink(ReferenceData{reference_text: file_ref_text, ..}, _, ref_infile_ref)
| MDHeadingLink(ReferenceData{reference_text: file_ref_text, ..}, _, ref_infile_ref) => {
matches_path_or_file(file_ref_text, self.get_refname(root_dir)) && infile_ref == ref_infile_ref
},
Tag(..) => false,
WikiFileLink(..) => false,
WikiIndexedBlockLink(..) => false,
MDFileLink(..) => false,
MDIndexedBlockLink(..) => false,
Footnote(..) => false,
}
}
}
}

Expand Down

0 comments on commit 23e62d1

Please sign in to comment.