Skip to content

Commit

Permalink
fix: don't parse . extensions other than .md
Browse files Browse the repository at this point in the history
resolves #46
  • Loading branch information
Feel-ix-343 committed Apr 18, 2024
1 parent e79bf6a commit 302d60f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions TestFiles/2024-03-30.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[2024-04-17]]
17 changes: 17 additions & 0 deletions TestFiles/2024-04-17.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@


![](./img/2024-04-17-15-14-12.md)

![](img/2024-04-17-15-14-12.png)

![](./img/2024-04-17-15-14-12.png)

[First Heading](<Test File#First Headin.png>)

[First Heading](<Test File.md>)
[First Heading](<Test File>)

[Heading 1](<Test#Heading 1>)

[Heading 1](Test)

Binary file added TestFiles/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions src/vault/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,17 @@ impl Vault {
let mut path = self.root_dir().clone();
path.push(&reference.data().reference_text);

Some(Referenceable::UnresovledFile(path, &data.reference_text))
Some(Referenceable::UnresovledFile(path, &data.reference_text))

// match data.reference_text.chars().collect_vec().as_slice() {

// [..,'.','m','d'] =>
// ['.', '/', rest @ ..]
// | ['/', rest @ ..]
// | rest if !rest.contains(&'.') => Some(Referenceable::UnresovledFile(path, &data.reference_text)),
// _ => None
// }

}
Reference::WikiHeadingLink(_data, end_path, heading)
| Reference::MDHeadingLink(_data, end_path, heading) => {
Expand Down Expand Up @@ -724,12 +734,16 @@ impl Reference {
});

static MD_LINK_RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"\[(?<display>[^\[\]\.]*)\]\(<?(?<filepath>(\.?\/)?[^\[\]\|\.\#<>]+)(\.[^\# <>]+)?(\#(?<infileref>[^\[\]\.\|<>]+))?>?\)")
Regex::new(r"\[(?<display>[^\[\]\.]*)\]\(<?(?<filepath>(\.?\/)?[^\[\]\|\.\#<>]+)(?<ending>\.[^\# <>]+)?(\#(?<infileref>[^\[\]\.\|<>]+))?>?\)")
.expect("MD Link Not Constructing")
}); // [display](relativePath)

let md_links = MD_LINK_RE
.captures_iter(text)
.filter(|captures| match captures.name("ending").map(|ending| ending.as_str()) {
Some(".md") | None => true,
_ => false
})
.flat_map(RegexTuple::new)
.flat_map(|regextuple| {
generic_link_constructor::<MDReferenceConstructor>(text, regextuple)
Expand Down

0 comments on commit 302d60f

Please sign in to comment.