Break up 'types' module
This commit is contained in:
parent
c6f9ea667d
commit
db8c02df04
36 changed files with 382 additions and 329 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
syntax::content::{Parseable, parser::lexeme::Lexeme},
|
||||
types::Node,
|
||||
syntax::content::{Parseable, parser::Lexeme},
|
||||
graph::Node,
|
||||
};
|
||||
|
||||
#[derive(Default, Debug, Clone, Eq, PartialEq)]
|
||||
|
|
@ -79,6 +79,10 @@ impl Anchor {
|
|||
self.leading = leading;
|
||||
}
|
||||
|
||||
pub fn node(&self) -> Option<Node> {
|
||||
self.node.clone()
|
||||
}
|
||||
|
||||
pub fn set_node(&mut self, node: &Node) {
|
||||
self.node = Some(node.to_owned());
|
||||
}
|
||||
|
|
@ -87,6 +91,10 @@ impl Anchor {
|
|||
self.node_id.clone()
|
||||
}
|
||||
|
||||
pub fn set_node_id(&mut self, id: &str) {
|
||||
self.node_id = Some(id.to_owned());
|
||||
}
|
||||
|
||||
fn route(&mut self) {
|
||||
self.destination = if let Some(destination) = self.destination.clone() {
|
||||
if destination.contains(":") || destination.contains("/") {
|
||||
|
|
@ -118,7 +126,7 @@ impl Parseable for Anchor {
|
|||
}
|
||||
|
||||
fn render(&self) -> String {
|
||||
let Some(ref destination) = self.destination else {
|
||||
let Some(destination) = &self.destination else {
|
||||
panic!(
|
||||
"Attempt to render anchor {self:#?} without knowing its destination."
|
||||
)
|
||||
|
|
@ -162,8 +170,8 @@ impl std::fmt::Display for Anchor {
|
|||
wrapped_text.as_str()
|
||||
};
|
||||
|
||||
let display_destination = match self.destination {
|
||||
Some(ref destination) => {
|
||||
let display_destination = match &self.destination {
|
||||
Some(destination) => {
|
||||
if destination.is_empty() {
|
||||
String::from("<empty>")
|
||||
} else {
|
||||
|
|
@ -192,7 +200,7 @@ impl std::fmt::Display for Anchor {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl std::fmt::Display for Bold {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ impl std::fmt::Display for CheckBox {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl std::fmt::Display for Code {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
|
||||
use crate::{
|
||||
prelude::*,
|
||||
types::Config,
|
||||
graph::Config,
|
||||
syntax::content::{Parseable, Lexeme},
|
||||
};
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ impl Parseable for Header {
|
|||
|
||||
fn render(&self) -> String {
|
||||
if let Some(open) = self.open {
|
||||
if open && let Some(ref id) = self.dom_id {
|
||||
if open && let Some(id) = &self.dom_id {
|
||||
format!(r#"<h{} id="{}">"#, self.level, id)
|
||||
} else if open {
|
||||
format!("<h{}>", self.level)
|
||||
|
|
@ -126,8 +126,8 @@ impl std::fmt::Display for Header {
|
|||
"unknown"
|
||||
};
|
||||
|
||||
let display_dom_id = match self.dom_id {
|
||||
Some(ref dom_id) => format!(" DOM ID {dom_id}"),
|
||||
let display_dom_id = match &self.dom_id {
|
||||
Some(dom_id) => format!(" DOM ID {dom_id}"),
|
||||
None => String::default(),
|
||||
};
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ impl Display for Level {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl std::fmt::Display for Item {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
syntax::content::{Parseable, parser::lexeme::Lexeme},
|
||||
syntax::content::{Parseable, parser::Lexeme},
|
||||
};
|
||||
|
||||
#[derive(Default, Debug, Clone, Eq, PartialEq)]
|
||||
|
|
@ -31,7 +31,7 @@ impl std::fmt::Display for LineBreak {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
use crate::{
|
||||
syntax::content::{Lexeme, Parseable, parser::token::item::Item},
|
||||
syntax::content::{
|
||||
Parseable,
|
||||
parser::{Lexeme, token::Item},
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Default, Debug, Clone, Eq, PartialEq)]
|
||||
|
|
@ -94,7 +97,7 @@ impl std::fmt::Display for List {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
||||
use crate::syntax::content::{Parseable, parser::Lexeme};
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct Literal {
|
||||
|
|
@ -33,7 +33,7 @@ impl std::fmt::Display for Literal {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl std::fmt::Display for Oblique {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
||||
use crate::syntax::content::{Parseable, parser::Lexeme};
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct Paragraph {
|
||||
|
|
@ -62,7 +62,7 @@ impl std::fmt::Display for Paragraph {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ impl Parseable for PreFormat {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ impl std::fmt::Display for Strike {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl std::fmt::Display for Underline {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::syntax::content::parser::token::Token;
|
||||
use crate::syntax::content::parser::Token;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue