#[derive(Debug, Clone, PartialEq)]
pub struct ReferenceInline {
pub raw: String,
pub reference_type: ReferenceType,
pub word_anchor: Option<WordAnchor>,
}
impl ReferenceInline {
pub fn new(raw: String) -> Self {
Self {
raw,
reference_type: ReferenceType::NotSure,
word_anchor: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WordAnchor {
pub word: String,
pub direction: AnchorDirection,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AnchorDirection {
Preceding,
Following,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AnchorKind {
WholeLineCapable,
MarkerOnly,
}
#[derive(Debug, Clone, PartialEq)]
pub enum ReferenceType {
ToCome { identifier: Option<String> },
Citation(CitationData),
AnnotationReference { label: String },
FootnoteNumber { number: u32 },
Session { target: String },
Url { target: String },
File { target: String },
General { target: String },
NotSure,
}
impl ReferenceType {
pub fn anchoring(&self) -> AnchorKind {
match self {
ReferenceType::Url { .. }
| ReferenceType::File { .. }
| ReferenceType::Session { .. }
| ReferenceType::General { .. } => AnchorKind::WholeLineCapable,
ReferenceType::FootnoteNumber { .. }
| ReferenceType::Citation(_)
| ReferenceType::AnnotationReference { .. }
| ReferenceType::ToCome { .. }
| ReferenceType::NotSure => AnchorKind::MarkerOnly,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CitationData {
pub keys: Vec<String>,
pub locator: Option<CitationLocator>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct CitationLocator {
pub format: PageFormat,
pub ranges: Vec<PageRange>,
pub raw: String,
}
#[derive(Debug, Clone, PartialEq)]
pub enum PageFormat {
P,
Pp,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PageRange {
pub start: u32,
pub end: Option<u32>,
}