Files
nuwiki/crates/nuwiki-core/src/ast/link.rs
T
gffranco 8ab6015405
CI / cargo fmt --check (push) Successful in 33s
CI / cargo clippy (push) Successful in 23s
CI / cargo test (push) Successful in 33s
CI / editor keymaps (push) Successful in 1m25s
Major clean up and improvements to vimwiki compatibility and documentation.
Reviewed-on: #1
2026-05-30 18:35:40 +00:00

67 lines
1.4 KiB
Rust

//! Link-related AST nodes and supporting types.
//!
//! All nodes here are inline (`InlineNode` variants);
//! they live in their own module because the link model has enough surface
//! area (kinds, anchors, interwiki indirection) to warrant separation.
use std::collections::HashMap;
use super::inline::InlineNode;
use super::span::Span;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LinkKind {
Wiki,
Interwiki,
Diary,
File,
Local,
Raw,
AnchorOnly,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
pub struct LinkTarget {
pub kind: LinkKind,
pub path: Option<String>,
pub wiki_index: Option<usize>,
pub wiki_name: Option<String>,
pub anchor: Option<String>,
pub is_absolute: bool,
pub is_directory: bool,
}
impl Default for LinkKind {
fn default() -> Self {
Self::Wiki
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WikiLinkNode {
pub span: Span,
pub target: LinkTarget,
pub description: Option<Vec<InlineNode>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExternalLinkNode {
pub span: Span,
pub url: String,
pub description: Option<Vec<InlineNode>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TransclusionNode {
pub span: Span,
pub url: String,
pub alt: Option<String>,
pub attrs: HashMap<String, String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RawUrlNode {
pub span: Span,
pub url: String,
}