Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wikilink handler interface #104

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 0 additions & 307 deletions src/arc/mod.rs

This file was deleted.

7 changes: 5 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub enum Error {
/// An error for when an arc destination is not found.
InvalidArcDestination(String),

#[error("Could not format the value: {0}")]
FormatError(#[from] serde_json::Error),
#[error("Could not format the value as JSON: {0}")]
JsonError(#[from] serde_json::Error),

#[error("IO error: {0}")]
Io(#[from] std::io::Error),
Expand All @@ -33,6 +33,9 @@ pub enum Error {
#[error("Path error: {0}")]
PathError(#[from] std::path::StripPrefixError),

#[error("Format error: {0}")]
FormatError(#[from] std::fmt::Error),

#[cfg(feature = "ssg")]
#[error("Template error: {0}")]
TemplateError(#[from] sailfish::RenderError),
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate pest;
#[macro_use]
extern crate pest_derive;

mod arc;
pub mod wikilink;
pub mod error;
mod hash;
mod note;
Expand All @@ -14,6 +14,8 @@ pub use hash::{HashMap, IdMap};
pub use note::{Note, NoteId};
#[doc(inline)]
pub use vault::{Vault, VaultBuilder};
#[doc(inline)]
pub use wikilink::{Anchor, WikilinkContext, WikilinkPreprocessor, WikilinkRenderer};

#[cfg(feature = "ssg")]
pub mod ssg;
4 changes: 3 additions & 1 deletion src/note/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub(crate) mod ser;

use crate::{
arc::Arc,
vault::Arc,
utils::{string::fix_link, time::parse_datestring},
IdMap,
};
Expand Down Expand Up @@ -44,6 +44,8 @@ pub type NoteId = u64;
/// ```
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Note {
/// The ID of the note
pub id: NoteId,
/// The title of a note.
pub title: String,
/// The path to the note, if it exists.
Expand Down
16 changes: 16 additions & 0 deletions src/vault/arc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::ops::Range;

#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Arc {
Connected(Vec<Range<usize>>),
NotConnected,
}

impl Arc {
pub fn push_link_range(&mut self, range: Range<usize>) {
match self {
Arc::Connected(ranges) => ranges.push(range),
Arc::NotConnected => *self = Arc::Connected(vec![range]),
}
}
}
Loading