//! 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, pub wiki_index: Option, pub wiki_name: Option, pub anchor: Option, 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>, } #[derive(Debug, Clone, PartialEq, Eq)] pub struct ExternalLinkNode { pub span: Span, pub url: String, pub description: Option>, } #[derive(Debug, Clone, PartialEq, Eq)] pub struct TransclusionNode { pub span: Span, pub url: String, pub alt: Option, pub attrs: HashMap, } #[derive(Debug, Clone, PartialEq, Eq)] pub struct RawUrlNode { pub span: Span, pub url: String, }