From d7d034757a48926827dc437dd161fc65c3f4369e Mon Sep 17 00:00:00 2001
From: jutty
Date: Mon, 16 Feb 2026 16:17:10 -0300
Subject: [PATCH] Adopt and apply nightly rustfmt configuration
---
.rustfmt.toml | 52 +++---
src/graph.rs | 28 +--
src/graph/edge.rs | 2 +-
src/graph/meta.rs | 19 +-
src/graph/node.rs | 6 +-
src/lib.rs | 11 +-
src/log.rs | 14 +-
src/router.rs | 18 +-
src/router/handlers/error.rs | 6 +-
src/router/handlers/fixed.rs | 11 +-
src/router/handlers/graph.rs | 14 +-
src/router/handlers/navigation.rs | 6 +-
src/router/handlers/raw.rs | 2 +-
src/router/handlers/template.rs | 5 +-
src/syntax/content.rs | 9 +-
src/syntax/content/parser.rs | 30 +--
src/syntax/content/parser/context.rs | 4 +-
src/syntax/content/parser/context/anchor.rs | 187 ++++++++++++++-----
src/syntax/content/parser/context/block.rs | 14 +-
src/syntax/content/parser/context/inline.rs | 5 +-
src/syntax/content/parser/context/list.rs | 10 +-
src/syntax/content/parser/context/table.rs | 19 +-
src/syntax/content/parser/lexeme.rs | 26 +--
src/syntax/content/parser/lexer.rs | 9 +-
src/syntax/content/parser/point.rs | 26 ++-
src/syntax/content/parser/segment.rs | 13 +-
src/syntax/content/parser/state.rs | 13 +-
src/syntax/content/parser/token.rs | 25 ++-
src/syntax/content/parser/token/anchor.rs | 65 +++----
src/syntax/content/parser/token/bold.rs | 23 +--
src/syntax/content/parser/token/checkbox.rs | 15 +-
src/syntax/content/parser/token/code.rs | 23 +--
src/syntax/content/parser/token/header.rs | 14 +-
src/syntax/content/parser/token/item.rs | 13 +-
src/syntax/content/parser/token/linebreak.rs | 19 +-
src/syntax/content/parser/token/list.rs | 7 +-
src/syntax/content/parser/token/literal.rs | 11 +-
src/syntax/content/parser/token/oblique.rs | 23 +--
src/syntax/content/parser/token/paragraph.rs | 20 +-
src/syntax/content/parser/token/preformat.rs | 24 +--
src/syntax/content/parser/token/quote.rs | 8 +-
src/syntax/content/parser/token/strike.rs | 19 +-
src/syntax/content/parser/token/table.rs | 16 +-
src/syntax/content/parser/token/underline.rs | 19 +-
src/syntax/content/parser/token/verse.rs | 4 +-
45 files changed, 432 insertions(+), 475 deletions(-)
diff --git a/.rustfmt.toml b/.rustfmt.toml
index f55bf01..a09015c 100644
--- a/.rustfmt.toml
+++ b/.rustfmt.toml
@@ -1,27 +1,33 @@
unstable_features = true
-match_block_trailing_comma = true
max_width = 80
-reorder_imports = false
-reorder_modules = false
-use_field_init_shorthand = true
-use_try_shorthand = true
+inline_attribute_width = 40
+
skip_macro_invocations = ["concat"]
-# not stabilized yet
-# blank_lines_lower_bound = 1
-# where_single_line = true
-# overflow_delimited_expr = true
-# normalize_doc_attributes = true
-# normalize_comments = true
-# inline_attribute_width = 40
-# imports_granularity = "Crate"
-# hex_literal_case = "Lower"
-# group_imports = "StdExternalCrate"
-# format_strings = true
-# force_multiline_blocks = true
-# error_on_unformatted = true
-# error_on_line_overflow = true
-# condense_wildcard_suffixes = true
-# doc_comment_code_block_width = 70
-# format_code_in_doc_comments = true
-# wrap_comments = true
+imports_granularity = "Crate"
+group_imports = "StdExternalCrate"
+
+fn_single_line = true
+match_block_trailing_comma = true
+use_field_init_shorthand = true
+use_try_shorthand = true
+hex_literal_case = "Lower"
+where_single_line = true
+condense_wildcard_suffixes = true
+combine_control_expr = false
+empty_item_single_line = true
+reorder_impl_items = true
+trailing_semicolon = false
+
+wrap_comments = true
+normalize_comments = true
+normalize_doc_attributes = true
+format_code_in_doc_comments = true
+doc_comment_code_block_width = 70
+
+error_on_unformatted = true
+error_on_line_overflow = true
+
+ignore = [
+ "tests/mocks",
+]
diff --git a/src/graph.rs b/src/graph.rs
index 709859f..ca64d65 100644
--- a/src/graph.rs
+++ b/src/graph.rs
@@ -1,24 +1,24 @@
use std::{collections::HashMap, path::PathBuf};
-use serde::{Serialize, Deserialize};
+pub use edge::Edge;
+pub use meta::{Config, Meta};
+pub use node::Node;
+use serde::{Deserialize, Serialize};
-use crate::syntax::{
- command::Arguments,
- content::{
- self,
- parser::{flatten, Token, token::Anchor},
+use crate::{
+ prelude::*,
+ syntax::{
+ command::Arguments,
+ content::{
+ self,
+ parser::{Token, flatten, token::Anchor},
+ },
},
};
-use crate::prelude::*;
-pub use {
- node::Node,
- edge::Edge,
- meta::{Meta, Config},
-};
-pub mod node;
pub mod edge;
pub mod meta;
+pub mod node;
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
pub struct Graph {
@@ -399,7 +399,7 @@ impl Graph {
} else {
log!(
VERBOSE,
- "Chasing candidate for query {query}, collapsed {collapsed_query}"
+ "Chasing candidate: query {query}, collapsed {collapsed_query}"
);
}
diff --git a/src/graph/edge.rs b/src/graph/edge.rs
index 02961ac..1c34bca 100644
--- a/src/graph/edge.rs
+++ b/src/graph/edge.rs
@@ -1,4 +1,4 @@
-use serde::{Serialize, Deserialize};
+use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
pub struct Edge {
diff --git a/src/graph/meta.rs b/src/graph/meta.rs
index 56664e8..f3669fb 100644
--- a/src/graph/meta.rs
+++ b/src/graph/meta.rs
@@ -1,6 +1,6 @@
-use crate::prelude::*;
+use serde::{Deserialize, Serialize};
-use serde::{Serialize, Deserialize};
+use crate::prelude::*;
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct Meta {
@@ -105,15 +105,9 @@ impl Default for Config {
}
// See: https://github.com/serde-rs/serde/issues/368
-fn mktrue() -> bool {
- true
-}
-fn mkfalse() -> bool {
- false
-}
-fn mk8() -> u16 {
- 8
-}
+fn mktrue() -> bool { true }
+fn mkfalse() -> bool { false }
+fn mk8() -> u16 { 8 }
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct Version {
@@ -314,9 +308,8 @@ impl std::fmt::Display for VersionErrorCause {
#[cfg(test)]
mod tests {
- use crate::graph::Graph;
-
use super::*;
+ use crate::graph::Graph;
#[test]
fn empty_footer_text() {
diff --git a/src/graph/node.rs b/src/graph/node.rs
index 672f835..ff0c719 100644
--- a/src/graph/node.rs
+++ b/src/graph/node.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;
-use serde::{Serialize, Deserialize};
+use serde::{Deserialize, Serialize};
use super::edge::Edge;
@@ -118,7 +118,9 @@ mod tests {
assert_eq!(
format!("{node}"),
format!(
- "Node 404 [title:'Not Found' text:15l summary:{} redirect:{redirect}]",
+ "Node 404 [title:'Not Found' \
+ text:15l summary:{} \
+ redirect:{redirect}]",
summary.len(),
)
);
diff --git a/src/lib.rs b/src/lib.rs
index 2a71d03..2cbd04c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,16 +1,17 @@
use std::{sync, time};
pub mod prelude {
- pub use crate::log;
- pub use crate::tlog;
- pub use crate::log::Level::*;
- pub use crate::log::now;
+ pub use crate::{
+ log,
+ log::{Level::*, now},
+ tlog,
+ };
}
pub mod graph;
+pub mod log;
pub mod router;
pub mod syntax;
-pub mod log;
pub static ONSET: sync::LazyLock =
sync::LazyLock::new(time::Instant::now);
diff --git a/src/log.rs b/src/log.rs
index 4f1c85e..a079d1e 100644
--- a/src/log.rs
+++ b/src/log.rs
@@ -32,7 +32,7 @@ impl Data {
let path = make_display_path(captured_path, &env_level);
let is_silent = env_level <= Level::SILENT;
- let message_level_is_within_env_level = message_level <= env_level;
+ let level_within_env_level = message_level <= env_level;
let excluded_in_code =
!EXCLUSIONS.iter().all(|&s| !trace_string.contains(s));
let excluded_by_env =
@@ -41,7 +41,7 @@ impl Data {
filter.is_empty() || captured_path.contains(&filter);
let should_log = !is_silent
- && message_level_is_within_env_level
+ && level_within_env_level
&& !excluded_in_code
&& !excluded_by_env
&& matches_filter;
@@ -51,7 +51,7 @@ impl Data {
eprintln!(
"Log decision for message from {path}: {should_log} given\n\
is_silent: {is_silent} (expected false)\n\
- message_level_is_within_env_level: {message_level_is_within_env_level}\n\
+ level_within_env_level: {level_within_env_level}\n\
excluded_in_code: {excluded_in_code} (expected false)\n\
excluded_by_env: {excluded_by_env} (expected false)\n\
matches_filter: {matches_filter}\n\
@@ -118,9 +118,7 @@ macro_rules! tlog {
}};
}
-pub fn now() -> Instant {
- Instant::now()
-}
+pub fn now() -> Instant { Instant::now() }
#[allow(clippy::print_stderr)]
pub fn elog(function: &str, message: &str) {
@@ -211,9 +209,7 @@ pub fn wrap(s: &str) -> String {
}
}
- fn escape(s: &str) -> String {
- s.escape_debug().collect()
- }
+ fn escape(s: &str) -> String { s.escape_debug().collect() }
symbolize("e(&escape(s)))
}
diff --git a/src/router.rs b/src/router.rs
index 4617e47..791faa9 100644
--- a/src/router.rs
+++ b/src/router.rs
@@ -3,13 +3,13 @@ use axum::{Router, routing::get};
use crate::graph::Graph;
mod handlers {
- pub mod graph;
- pub mod template;
- pub mod raw;
- pub mod navigation;
- pub mod fixed;
pub mod error;
+ pub mod fixed;
+ pub mod graph;
pub mod mime;
+ pub mod navigation;
+ pub mod raw;
+ pub mod template;
}
#[derive(Clone)]
@@ -49,11 +49,6 @@ pub fn new(graph: Graph) -> Router {
#[cfg(test)]
mod tests {
- use crate::{
- graph::{Graph, Config, Meta},
- };
-
- use super::*;
use axum::{
body::Body,
http::{Request, StatusCode},
@@ -61,6 +56,9 @@ mod tests {
};
use tower::ServiceExt as _;
+ use super::*;
+ use crate::graph::{Config, Graph, Meta};
+
async fn request(uri: &str, config: Option<&Config>) -> Response {
let default_graph = Graph::load();
let graph = Graph {
diff --git a/src/router/handlers/error.rs b/src/router/handlers/error.rs
index 5367f8b..fdb938d 100644
--- a/src/router/handlers/error.rs
+++ b/src/router/handlers/error.rs
@@ -68,10 +68,8 @@ pub async fn not_found(State(state): State) -> Response {
#[cfg(test)]
mod tests {
- use axum::{
- http::{StatusCode},
- extract::State,
- };
+ use axum::{extract::State, http::StatusCode};
+
use super::*;
#[tokio::test]
diff --git a/src/router/handlers/fixed.rs b/src/router/handlers/fixed.rs
index 67a764a..ac66951 100644
--- a/src/router/handlers/fixed.rs
+++ b/src/router/handlers/fixed.rs
@@ -1,16 +1,13 @@
use axum::{
+ body::Body,
+ extract::{Path, State},
http::{HeaderValue, Response, StatusCode, header},
- {
- body::Body,
- extract::{Path, State},
- },
};
-use crate::prelude::*;
use crate::{
graph::{Format, Graph, SerialErrorCause},
- router::{GlobalState, handlers},
- router::handlers::mime::Mime,
+ prelude::*,
+ router::{GlobalState, handlers, handlers::mime::Mime},
};
pub async fn file(
diff --git a/src/router/handlers/graph.rs b/src/router/handlers/graph.rs
index a1912c7..349efb7 100644
--- a/src/router/handlers/graph.rs
+++ b/src/router/handlers/graph.rs
@@ -1,7 +1,8 @@
use axum::{
- extract::State,
- response::IntoResponse as _,
- {body::Body, extract::Path, http::Response, response::Redirect},
+ body::Body,
+ extract::{Path, State},
+ http::Response,
+ response::{IntoResponse as _, Redirect},
};
use crate::{
@@ -49,13 +50,10 @@ pub async fn node(
#[cfg(test)]
mod tests {
- use axum::{
- http::{HeaderName, StatusCode},
- };
-
- use crate::graph::{Format, Graph};
+ use axum::http::{HeaderName, StatusCode};
use super::*;
+ use crate::graph::{Format, Graph};
async fn wrap_node(query: &str) -> Response {
let state = GlobalState {
diff --git a/src/router/handlers/navigation.rs b/src/router/handlers/navigation.rs
index 12bd617..f799416 100644
--- a/src/router/handlers/navigation.rs
+++ b/src/router/handlers/navigation.rs
@@ -1,4 +1,6 @@
-use axum::{Form, body::Body, extract::State, http::Response, response::Redirect};
+use axum::{
+ Form, body::Body, extract::State, http::Response, response::Redirect,
+};
use crate::{
prelude::*,
@@ -58,9 +60,9 @@ pub struct Query {
#[cfg(test)]
mod tests {
use axum::http::StatusCode;
- use crate::graph::Graph;
use super::*;
+ use crate::graph::Graph;
async fn wrap_page(path: &str) -> Response {
let state = GlobalState {
diff --git a/src/router/handlers/raw.rs b/src/router/handlers/raw.rs
index 789e4c2..a593cbe 100644
--- a/src/router/handlers/raw.rs
+++ b/src/router/handlers/raw.rs
@@ -1,6 +1,6 @@
use axum::{
body::Body,
- http::{header, HeaderValue, Response, StatusCode},
+ http::{HeaderValue, Response, StatusCode, header},
};
use crate::prelude::*;
diff --git a/src/router/handlers/template.rs b/src/router/handlers/template.rs
index c590424..a2290d5 100644
--- a/src/router/handlers/template.rs
+++ b/src/router/handlers/template.rs
@@ -1,6 +1,6 @@
use axum::{
body::Body,
- http::{header, Response, StatusCode},
+ http::{Response, StatusCode, header},
};
use crate::{
@@ -135,9 +135,8 @@ fn emergency_wrap(error: &tera::Error) -> String {
#[cfg(test)]
mod tests {
- use crate::graph::Graph;
-
use super::*;
+ use crate::graph::Graph;
#[test]
fn by_filename_forced_error() {
diff --git a/src/syntax/content.rs b/src/syntax/content.rs
index 0cd700b..29ef886 100644
--- a/src/syntax/content.rs
+++ b/src/syntax/content.rs
@@ -1,6 +1,6 @@
use std::mem::discriminant;
-use parser::{Token, Lexeme};
+use parser::{Lexeme, Token};
use crate::graph::Graph;
@@ -43,9 +43,7 @@ impl TokenOutput {
}
}
-pub fn parse(text: &str, graph: &Graph) -> String {
- parser::read(text, graph)
-}
+pub fn parse(text: &str, graph: &Graph) -> String { parser::read(text, graph) }
pub fn rich_parse(text: &str, graph: &Graph) -> TokenOutput {
parser::rich_read(text, graph)
@@ -53,9 +51,8 @@ pub fn rich_parse(text: &str, graph: &Graph) -> TokenOutput {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::token::{Bold, Oblique};
-
use super::*;
+ use crate::syntax::content::parser::token::{Bold, Oblique};
#[test]
fn only() {
diff --git a/src/syntax/content/parser.rs b/src/syntax/content/parser.rs
index 0a3c0f0..2640edf 100644
--- a/src/syntax/content/parser.rs
+++ b/src/syntax/content/parser.rs
@@ -1,15 +1,18 @@
-use crate::{prelude::*, graph::Graph, syntax::content::TokenOutput};
use context::{Block, Inline};
+pub use lexeme::Lexeme;
use lexer::{LEXMAP, lex};
-pub use {lexeme::Lexeme, token::Token, state::State};
+pub use state::State;
+pub use token::Token;
+
+use crate::{graph::Graph, prelude::*, syntax::content::TokenOutput};
-pub mod token;
-pub mod lexer;
-pub mod lexeme;
-pub mod segment;
pub mod context;
+pub mod lexeme;
+pub mod lexer;
pub mod point;
+pub mod segment;
pub mod state;
+pub mod token;
fn parse(tokens: &[Token]) -> String {
tokens.iter().map(Token::render).collect::()
@@ -46,16 +49,10 @@ pub fn flatten(input: &str, graph: &Graph) -> String {
#[cfg(test)]
mod tests {
- use crate::{
- graph::Graph,
- syntax::content::parser::{token::header::Level},
- };
-
use super::*;
+ use crate::{graph::Graph, syntax::content::parser::token::header::Level};
- fn read_noconfig(input: &str) -> String {
- read(input, &Graph::default())
- }
+ fn read_noconfig(input: &str) -> String { read(input, &Graph::default()) }
#[test]
fn empty_render_is_empty() {
@@ -65,7 +62,10 @@ mod tests {
#[test]
fn mixed_sample() {
let en = "`this |test|` tries ## to |brea|k|: things";
- let html = r#"this |test| tries ## to brea : things
"#;
+ let html = concat!(
+ r#"this |test| tries ## to brea : things
"#,
+ );
assert_eq!(read_noconfig(en), html);
}
diff --git a/src/syntax/content/parser/context.rs b/src/syntax/content/parser/context.rs
index 861b9c1..6320a5d 100644
--- a/src/syntax/content/parser/context.rs
+++ b/src/syntax/content/parser/context.rs
@@ -3,9 +3,9 @@ use crate::syntax::content::parser::{
token::{Header, Paragraph, PreFormat, Verse},
};
+pub mod anchor;
pub mod block;
pub mod inline;
-pub mod anchor;
pub mod list;
pub mod quote;
pub mod table;
@@ -68,7 +68,7 @@ pub fn close(state: &State, tokens: &mut Vec) {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::{context::Block, State};
+ use crate::syntax::content::parser::{State, context::Block};
#[test]
#[should_panic(expected = "End of input with open list")]
diff --git a/src/syntax/content/parser/context/anchor.rs b/src/syntax/content/parser/context/anchor.rs
index d9a861a..1407385 100644
--- a/src/syntax/content/parser/context/anchor.rs
+++ b/src/syntax/content/parser/context/anchor.rs
@@ -1,7 +1,7 @@
use crate::{
- prelude::*,
- syntax::content::parser::{context::Inline, Lexeme, State, Token},
graph::Graph,
+ prelude::*,
+ syntax::content::parser::{Lexeme, State, Token, context::Inline},
};
/// Handles open anchor contexts until an anchor token is fully parsed.
@@ -162,11 +162,9 @@ fn push(
#[cfg(test)]
mod tests {
- use crate::{syntax::content::parser, graph::Graph};
+ use crate::{graph::Graph, syntax::content::parser};
- fn read(input: &str) -> String {
- parser::read(input, &Graph::default())
- }
+ fn read(input: &str) -> String { parser::read(input, &Graph::default()) }
#[test]
fn flanking() {
@@ -188,7 +186,10 @@ mod tests {
fn flanking_with_trailing_comma_and_space() {
assert_eq!(
read("|Node|, at"),
- r#"Node , at
"#
+ concat!(
+ r#"Node , at
"#,
+ )
);
}
@@ -204,7 +205,8 @@ mod tests {
fn needless_three_pipe_anchor() {
assert_eq!(
read("|Node|Destination|"),
- r#"Node
"#
+ concat!(r#"Node
"#)
);
}
@@ -212,7 +214,10 @@ mod tests {
fn nonleading_second_pipe() {
assert_eq!(
read("Go to Node|Destination|, here"),
- r#"Go to Node , here
"#,
+ concat!(
+ r#"Go to Node , here
"#
+ ),
);
}
@@ -220,7 +225,9 @@ mod tests {
fn anchor_to_node_s() {
assert_eq!(
read("The |letter s|s|'s node: |s|!"),
- r#"The letter s 's node: s !
"#
+ concat!(r#"The letter s 's node: "#,
+ r#"s !
"#)
);
}
@@ -228,7 +235,10 @@ mod tests {
fn nonleading_plural_anchor() {
assert_eq!(
read("The flower|s bloomed"),
- r#"The flowers bloomed
"#
+ concat!(
+ r#"The flowers bloomed
"#,
+ )
);
}
@@ -236,7 +246,9 @@ mod tests {
fn leading_plural_anchor() {
assert_eq!(
read("Interfaces are |element|s of |system|s."),
- r#"Interfaces are elements of systems .
"#
+ concat!(r#"Interfaces are elements of systems .
"#)
);
}
@@ -244,7 +256,11 @@ mod tests {
fn leading_multiword_anchor() {
assert_eq!(
read("interactions are |basic elements| of systems"),
- r#"interactions are basic elements of systems
"#
+ concat!(
+ r#"interactions are basic elements "#,
+ r#"of systems
"#,
+ ),
);
}
@@ -252,7 +268,9 @@ mod tests {
fn explicit_end_of_destination() {
assert_eq!(
read("interactions are |basic elements|BasicElements| of systems"),
- r#"interactions are basic elements of systems
"#
+ concat!(r#"interactions are basic elements of "#,
+ r#"systems
"#)
);
}
@@ -260,7 +278,11 @@ mod tests {
fn explicit_end_of_external_destination() {
assert_eq!(
read("this |anchor example|https://example.com| is external"),
- r#"this anchor example is external
"#
+ concat!(
+ r#"this anchor example is "#,
+ r#"external
"#
+ )
);
}
@@ -276,7 +298,10 @@ mod tests {
fn external_anchor_destination_at_eoi() {
assert_eq!(
read("a b|https://example.com"),
- r#"a b
"#
+ concat!(
+ r#"a b
"#,
+ )
);
}
@@ -284,7 +309,10 @@ mod tests {
fn nonleading_plural_anchor_at_eoi() {
assert_eq!(
read("element|s"),
- r#"elements
"#
+ concat!(
+ r#"elements
"#,
+ )
);
}
@@ -292,17 +320,22 @@ mod tests {
fn leading_plural_anchor_at_eoi() {
assert_eq!(
read("|element|s"),
- r#"elements
"#
+ concat!(
+ r#"elements
"#,
+ )
);
}
#[test]
fn http_external_anchor() {
assert_eq!(
- read(
- "a |false dichotomy|https://en.wikipedia.org/wiki/False_dilemma|."
+ read("a |false dichotomy|https://wikipedia.org/False_dilemma|."),
+ concat!(
+ r#"a "#,
+ r#"false dichotomy .
"#,
),
- r#"a false dichotomy .
"#
);
}
@@ -315,7 +348,8 @@ mod tests {
"at rustup.rs",
)),
concat!(
- r#"Rust toolchain "#,
+ r#"
Rust toolchain "#,
"\n",
"at rustup.rs
",
)
@@ -326,7 +360,11 @@ mod tests {
fn http_external_anchor_leading_no_third_then_space() {
assert_eq!(
read("|Rust toolchain|https://rustup.rs/ at rustup.rs"),
- r#"Rust toolchain at rustup.rs
"#
+ concat!(
+ r#"Rust toolchain "#,
+ r#"at rustup.rs
"#,
+ ),
);
}
@@ -334,7 +372,10 @@ mod tests {
fn http_external_anchor_leading_no_third_then_eoi() {
assert_eq!(
read("|Rust toolchain|https://rustup.rs/"),
- r#"Rust toolchain
"#
+ concat!(
+ r#"Rust toolchain
"#,
+ )
);
}
@@ -344,7 +385,10 @@ mod tests {
read("\n|SomeAnchor|\n"),
concat!(
"\n",
- r#"SomeAnchor
"#
+ concat!(
+ r#"SomeAnchor
"#,
+ )
),
);
}
@@ -354,9 +398,11 @@ mod tests {
assert_eq!(
read("|SomeAnchor|\n|SomeOtherAnchor|\n"),
concat!(
- r#"SomeAnchor "#,
+ r#"
SomeAnchor "#,
"\n",
- r#"SomeOtherAnchor
"#
+ r#"SomeOtherAnchor
"#,
)
);
}
@@ -366,10 +412,12 @@ mod tests {
assert_eq!(
read("|SomeAnchor|\n\n|SomeOtherAnchor|\n"),
concat!(
- r#"SomeAnchor
"#,
+ r#"SomeAnchor
"#,
"\n",
"\n",
- r#"SomeOtherAnchor
"#
+ r#"SomeOtherAnchor
"#,
),
);
}
@@ -378,7 +426,10 @@ mod tests {
fn trailing_anchor() {
assert_eq!(
read("see acks|acks"),
- r#"see acks
"#
+ concat!(
+ r#"see acks
"#,
+ )
);
}
@@ -388,8 +439,9 @@ mod tests {
read("\nsee acks|acks\n"),
concat!(
"\n",
- r#"see acks
"#
- )
+ r#"see acks
"#,
+ ),
);
}
@@ -417,7 +469,10 @@ mod tests {
fn anchor_with_trailing_single_quote() {
assert_eq!(
read("the |lion|'s mouth"),
- r#"the lion 's mouth
"#,
+ concat!(
+ r#"the lion 's mouth
"#,
+ )
);
}
@@ -425,7 +480,10 @@ mod tests {
fn anchor_with_trailing_double_quote() {
assert_eq!(
read(r#"the "|real|" motive"#),
- r#"the "real " motive
"#,
+ concat!(
+ r#"the "real " motive
"#,
+ )
);
}
@@ -433,7 +491,10 @@ mod tests {
fn anchor_with_trailing_parenthesis() {
assert_eq!(
read("this (though |true|) was questioned"),
- r#"this (though true ) was questioned
"#,
+ concat!(
+ r#"this (though true ) was questioned
"#,
+ )
);
}
@@ -441,7 +502,10 @@ mod tests {
fn anchor_with_leading_single_quote() {
assert_eq!(
read("the 'real|Reality' motive"),
- r#"the 'real ' motive
"#,
+ concat!(
+ r#"the 'real ' motive
"#,
+ )
);
}
@@ -449,7 +513,10 @@ mod tests {
fn anchor_with_leading_double_quote() {
assert_eq!(
read(r#"the "real|Reality" motive"#),
- r#"the "real " motive
"#,
+ concat!(
+ r#"the "real " motive
"#,
+ )
);
}
@@ -457,7 +524,10 @@ mod tests {
fn anchor_with_leading_parenthesis() {
assert_eq!(
read("her (last|Surname) name"),
- r#"her (last ) name
"#,
+ concat!(
+ r#"her (last ) name
"#,
+ )
);
}
@@ -465,7 +535,10 @@ mod tests {
fn anchor_with_internal_apostrophe() {
assert_eq!(
read("the |lion's mouth|album was released"),
- r#"the lion's mouth was released
"#
+ concat!(
+ r#"the lion's mouth was released
"#,
+ )
);
}
@@ -473,7 +546,10 @@ mod tests {
fn nonleading_anchor_with_internal_apostrophe() {
assert_eq!(
read("they decided to stay at Jane's|YellowHouse that night"),
- r#"they decided to stay at Jane's that night
"#
+ concat!(
+ r#"they decided to stay at Jane's that night
"#,
+ )
);
}
@@ -481,7 +557,10 @@ mod tests {
fn nonleading_anchor_with_internal_apostrophe_at_eoi() {
assert_eq!(
read("they decided to stay at Jane's|YellowHouse"),
- r#"they decided to stay at Jane's
"#
+ concat!(
+ r#"they decided to stay at Jane's
"#,
+ )
);
}
@@ -489,7 +568,10 @@ mod tests {
fn nonleading_anchor_with_internal_apostrophe_at_soi() {
assert_eq!(
read("Jane's|YellowHouse that night"),
- r#"Jane's that night
"#
+ concat!(
+ r#"Jane's that night
"#,
+ )
);
}
@@ -497,7 +579,10 @@ mod tests {
fn anchor_with_internal_double_quotes() {
assert_eq!(
read(r#"the |"real"|Truth motive"#),
- r#"the "real" motive
"#,
+ concat!(
+ r#"the "real" motive
"#,
+ )
);
}
@@ -505,7 +590,10 @@ mod tests {
fn anchor_with_internal_double_quotes_wrapping_spaced_words() {
assert_eq!(
read(r#"the |"bare reality"|Ideology they believed"#),
- r#"the "bare reality" they believed
"#,
+ concat!(
+ r#"the "bare reality" they believed
"#,
+ )
);
}
@@ -513,7 +601,10 @@ mod tests {
fn anchor_with_internal_parenthesis() {
assert_eq!(
read("her |last (name)|Surname was Amad"),
- r#"her last (name) was Amad
"#,
+ concat!(
+ r#"her last (name) was Amad
"#,
+ )
);
}
@@ -521,7 +612,11 @@ mod tests {
fn anchor_with_internal_parenthesis_wrapping_spaced_words() {
assert_eq!(
read("this |truth (though questionable) was fine|Absurd to them "),
- r#"this truth (though questionable) was fine to them
"#
+ concat!(
+ r#"this truth (though questionable) was "#,
+ r#"fine to them
"#,
+ )
);
}
}
diff --git a/src/syntax/content/parser/context/block.rs b/src/syntax/content/parser/context/block.rs
index 292bdf0..63a3ac9 100644
--- a/src/syntax/content/parser/context/block.rs
+++ b/src/syntax/content/parser/context/block.rs
@@ -8,7 +8,7 @@ use crate::{
parser::{
Block, Lexeme, State, Token,
token::{
- Header, List, LineBreak, Literal, Paragraph, PreFormat, Quote,
+ Header, LineBreak, List, Literal, Paragraph, PreFormat, Quote,
Table, Verse,
},
},
@@ -124,16 +124,14 @@ pub fn parse(
mod tests {
use crate::{
- syntax::content::parser::{
- self, Block, Token, context, State,
- token::{Header, header::Level, PreFormat},
- },
graph::Graph,
+ syntax::content::parser::{
+ self, Block, State, Token, context,
+ token::{Header, PreFormat, header::Level},
+ },
};
- fn read(input: &str) -> String {
- parser::read(input, &Graph::default())
- }
+ fn read(input: &str) -> String { parser::read(input, &Graph::default()) }
#[test]
fn pre() {
diff --git a/src/syntax/content/parser/context/inline.rs b/src/syntax/content/parser/context/inline.rs
index 27c4675..b4412cc 100644
--- a/src/syntax/content/parser/context/inline.rs
+++ b/src/syntax/content/parser/context/inline.rs
@@ -1,17 +1,16 @@
use std::{iter::Peekable, slice::Iter};
use crate::{
+ graph::Graph,
prelude::*,
syntax::content::{
Parseable as _,
parser::{
- Lexeme, State,
+ Inline, Lexeme, State, Token, context,
state::AnchorBuffer,
- Inline, context, Token,
token::{Anchor, Code, Literal},
},
},
- graph::Graph,
};
pub fn parse(
diff --git a/src/syntax/content/parser/context/list.rs b/src/syntax/content/parser/context/list.rs
index 1fc938a..7c72103 100644
--- a/src/syntax/content/parser/context/list.rs
+++ b/src/syntax/content/parser/context/list.rs
@@ -1,11 +1,11 @@
use std::{iter::Peekable, slice::Iter};
use crate::{
+ graph::Graph,
prelude::*,
syntax::content::parser::{
- context::Block, Token, Lexeme, State, state, token::Item, format,
+ Lexeme, State, Token, context::Block, format, state, token::Item,
},
- graph::Graph,
};
/// Handles open list contexts until a list is fully parsed.
@@ -88,13 +88,11 @@ pub fn parse(
#[cfg(test)]
mod tests {
use crate::{
- syntax::content::parser::{self, context::list::parse, Lexeme, State},
graph::Graph,
+ syntax::content::parser::{self, Lexeme, State, context::list::parse},
};
- fn read(input: &str) -> String {
- parser::read(input, &Graph::default())
- }
+ fn read(input: &str) -> String { parser::read(input, &Graph::default()) }
#[test]
fn unordered_list() {
diff --git a/src/syntax/content/parser/context/table.rs b/src/syntax/content/parser/context/table.rs
index 357f599..a64d136 100644
--- a/src/syntax/content/parser/context/table.rs
+++ b/src/syntax/content/parser/context/table.rs
@@ -117,11 +117,9 @@ pub fn parse(
#[cfg(test)]
mod tests {
- use crate::{syntax::content::parser, graph::Graph};
+ use crate::{graph::Graph, syntax::content::parser};
- fn read(input: &str) -> String {
- parser::read(input, &Graph::default())
- }
+ fn read(input: &str) -> String { parser::read(input, &Graph::default()) }
fn read_loaded(input: &str) -> String {
parser::read(input, &Graph::load())
@@ -250,11 +248,13 @@ mod tests {
"", "\n",
" ", "\n",
" a ", "\n",
- r#" Node "#, "\n",
+ r#" Node "#, "\n",
" c ", "\n",
" ", "\n",
"
", "\n",
- ));
+ )
+ );
}
#[test]
@@ -270,11 +270,14 @@ mod tests {
"", "\n",
" ", "\n",
" a ", "\n",
- r#" Node "#, "\n",
+ r#" Node "#, "\n",
" c ", "\n",
" ", "\n",
"
", "\n",
- ));
+ )
+ );
}
#[test]
diff --git a/src/syntax/content/parser/lexeme.rs b/src/syntax/content/parser/lexeme.rs
index acaf378..b361fb1 100644
--- a/src/syntax/content/parser/lexeme.rs
+++ b/src/syntax/content/parser/lexeme.rs
@@ -1,6 +1,6 @@
use std::fmt;
-use crate::{syntax::content::parser::segment::delimiter::Delimiters};
+use crate::syntax::content::parser::segment::delimiter::Delimiters;
#[derive(Clone, Debug, Default)]
pub struct Lexeme {
@@ -22,25 +22,15 @@ impl Lexeme {
}
}
- pub fn text(&self) -> String {
- self.text.clone()
- }
+ pub fn text(&self) -> String { self.text.clone() }
- pub fn next(&self) -> String {
- self.next.clone()
- }
+ pub fn next(&self) -> String { self.next.clone() }
- pub fn last(&self) -> bool {
- self.last
- }
+ pub fn last(&self) -> bool { self.last }
- pub fn first(&self) -> bool {
- self.first
- }
+ pub fn first(&self) -> bool { self.first }
- pub fn mutate_text(&mut self, new: &str) {
- self.text = new.to_string();
- }
+ pub fn mutate_text(&mut self, new: &str) { self.text = new.to_string(); }
pub fn as_char(&self) -> Option {
if self.text.chars().count() == 1 {
@@ -141,9 +131,7 @@ impl Lexeme {
.is_some_and(|c| delimiters.is_delimiter(c))
}
- pub fn next_first_char(&self) -> Option {
- self.next.chars().nth(0)
- }
+ pub fn next_first_char(&self) -> Option { self.next.chars().nth(0) }
pub fn match_first_char(&self, query: char) -> bool {
self.text.chars().nth(0).is_some_and(|c| c == query)
diff --git a/src/syntax/content/parser/lexer.rs b/src/syntax/content/parser/lexer.rs
index b87d868..e9a0d40 100644
--- a/src/syntax/content/parser/lexer.rs
+++ b/src/syntax/content/parser/lexer.rs
@@ -1,13 +1,14 @@
use crate::{
- prelude::*,
graph::Graph,
+ prelude::*,
syntax::content::{
- TokenOutput, Parseable as _, LexMap,
+ LexMap, Parseable as _, TokenOutput,
parser::{
+ context,
lexeme::Lexeme,
- token::{Token, LineBreak, Literal},
+ point, segment,
state::State,
- segment, context, point,
+ token::{LineBreak, Literal, Token},
},
},
};
diff --git a/src/syntax/content/parser/point.rs b/src/syntax/content/parser/point.rs
index 38aaec0..b97b2e1 100644
--- a/src/syntax/content/parser/point.rs
+++ b/src/syntax/content/parser/point.rs
@@ -58,17 +58,18 @@ pub fn parse(
#[cfg(test)]
mod tests {
- use crate::{syntax::content::parser, graph::Graph};
+ use crate::{graph::Graph, syntax::content::parser};
- fn read(input: &str) -> String {
- parser::read(input, &Graph::default())
- }
+ fn read(input: &str) -> String { parser::read(input, &Graph::default()) }
#[test]
fn oblique_anchor() {
assert_eq!(
read("w _|S|_ w"),
- r#"w S w
"#
+ concat!(
+ r#"w S w
"#,
+ )
);
}
@@ -76,7 +77,8 @@ mod tests {
fn oblique_anchor_with_trailing_comma() {
assert_eq!(
read("w _|S|_, w"),
- r#"w S , w
"#
+ concat!(r#"w S , w
"#)
);
}
@@ -84,9 +86,17 @@ mod tests {
fn oblique() {
assert_eq!(
read(
- "_|this anchor is oblique|o as are these literals_ but not these _just these_, not this _and these with an |anc80r| again_"
+ "_|this anchor is oblique|o as are these literals_ but not \
+ these _just these_, not this _and these with an |anc80r| \
+ again_"
),
- r#"this anchor is oblique as are these literals but not these just these , not this and these with an anc80r again
"#
+ concat!(
+ r#""#,
+ r#"this anchor is oblique as are these literals "#,
+ r#"but not these just these , not this and these "#,
+ r#"with an anc80r again
"#,
+ )
);
}
diff --git a/src/syntax/content/parser/segment.rs b/src/syntax/content/parser/segment.rs
index 8a8ea76..1ee853e 100644
--- a/src/syntax/content/parser/segment.rs
+++ b/src/syntax/content/parser/segment.rs
@@ -1,6 +1,4 @@
-pub fn segment(text: &str) -> Vec {
- delimiter::atomize(text)
-}
+pub fn segment(text: &str) -> Vec { delimiter::atomize(text) }
pub mod delimiter {
@@ -146,7 +144,8 @@ pub mod delimiter {
fn atomize_flankign_sentence() {
assert_eq!(
atomize(
- "about_colors: the colors _amber_, _orange_ and _yellow mustard_ to `jane_bishop@mail.com`."
+ "about_colors: the colors _amber_, _orange_ and \
+ _yellow mustard_ to `jane_bishop@mail.com`."
),
vec![
"about_colors",
@@ -188,7 +187,8 @@ pub mod delimiter {
#[test]
fn atomize_words() {
let actual = atomize(
- " justification for the actions of those who hold authority inevitably dwindles ",
+ " justification for the actions of those who hold \
+ authority inevitably dwindles ",
);
let expected = vec![
" ",
@@ -285,7 +285,8 @@ pub mod delimiter {
#[test]
fn atomize_pipes_and_ticks() {
let actual = atomize(
- "every other |time| as `it could or |perhaps somehow|then or now| it was` perceived",
+ "every other |time| as `it could or |perhaps somehow|then or \
+ now| it was` perceived",
);
let expected = vec![
"every",
diff --git a/src/syntax/content/parser/state.rs b/src/syntax/content/parser/state.rs
index cea6f6f..aa42f68 100644
--- a/src/syntax/content/parser/state.rs
+++ b/src/syntax/content/parser/state.rs
@@ -101,24 +101,24 @@ mod tests {
#[test]
fn anchor_buffer_display_with_text_set() {
let mut buffer = AnchorBuffer::default();
- buffer.text = String::from("mX8Z7yWmsK");
+ buffer.text = String::from("mX8Z7sK");
println!("{buffer:#?}");
println!("{buffer}");
assert_eq!(
format!("{buffer}"),
- r#"AnchorBuffer [text: "mX8Z7yWmsK"] >> Anchor -> "#
+ r#"AnchorBuffer [text: "mX8Z7sK"] >> Anchor -> "#
);
}
#[test]
fn anchor_buffer_display_with_destination_set() {
let mut buffer = AnchorBuffer::default();
- buffer.destination = String::from("VP2aqGngAq");
+ buffer.destination = String::from("VP2gAq");
println!("{buffer:#?}");
println!("{buffer}");
assert_eq!(
format!("{buffer}"),
- r#"AnchorBuffer [, dest: "VP2aqGngAq"] >> Anchor -> "#
+ r#"AnchorBuffer [, dest: "VP2gAq"] >> Anchor -> "#
);
}
@@ -131,7 +131,10 @@ mod tests {
println!("{buffer}");
assert_eq!(
format!("{buffer}"),
- r#"AnchorBuffer [text: "ECJrzgkBHg", dest: "9dy6gQ2g3E"] >> Anchor -> "#
+ concat!(
+ r#"AnchorBuffer [text: "ECJrzgkBHg", dest: "9dy6gQ2g3E"] "#,
+ r#">> Anchor -> "#,
+ )
);
}
}
diff --git a/src/syntax/content/parser/token.rs b/src/syntax/content/parser/token.rs
index cfbb39b..a1f9a70 100644
--- a/src/syntax/content/parser/token.rs
+++ b/src/syntax/content/parser/token.rs
@@ -1,4 +1,4 @@
-use crate::syntax::content::{Parseable as _};
+use crate::syntax::content::Parseable as _;
pub mod anchor;
pub mod bold;
@@ -18,12 +18,23 @@ pub mod table;
pub mod underline;
pub mod verse;
-pub use {
- anchor::Anchor, bold::Bold, checkbox::CheckBox, code::Code, header::Header,
- item::Item, linebreak::LineBreak, list::List, literal::Literal,
- oblique::Oblique, paragraph::Paragraph, preformat::PreFormat, quote::Quote,
- strike::Strike, table::Table, underline::Underline, verse::Verse,
-};
+pub use anchor::Anchor;
+pub use bold::Bold;
+pub use checkbox::CheckBox;
+pub use code::Code;
+pub use header::Header;
+pub use item::Item;
+pub use linebreak::LineBreak;
+pub use list::List;
+pub use literal::Literal;
+pub use oblique::Oblique;
+pub use paragraph::Paragraph;
+pub use preformat::PreFormat;
+pub use quote::Quote;
+pub use strike::Strike;
+pub use table::Table;
+pub use underline::Underline;
+pub use verse::Verse;
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum Token {
diff --git a/src/syntax/content/parser/token/anchor.rs b/src/syntax/content/parser/token/anchor.rs
index 0eb2570..644dc2e 100644
--- a/src/syntax/content/parser/token/anchor.rs
+++ b/src/syntax/content/parser/token/anchor.rs
@@ -1,6 +1,6 @@
use crate::{
- syntax::content::{Parseable, parser::Lexeme},
graph::Node,
+ syntax::content::{Parseable, parser::Lexeme},
};
#[derive(Default, Debug, Clone, Eq, PartialEq)]
@@ -15,58 +15,36 @@ pub struct Anchor {
}
impl Anchor {
- pub fn text(&self) -> String {
- self.text.clone()
- }
+ pub fn text(&self) -> String { self.text.clone() }
- pub fn set_text(&mut self, text: &str) {
- self.text = String::from(text);
- }
+ pub fn set_text(&mut self, text: &str) { self.text = String::from(text); }
- pub fn text_push(&mut self, text: &str) {
- self.text.push_str(text);
- }
+ pub fn text_push(&mut self, text: &str) { self.text.push_str(text); }
- pub fn destination(&self) -> Option {
- self.destination.clone()
- }
+ pub fn destination(&self) -> Option { self.destination.clone() }
pub fn set_destination(&mut self, destination: Option<&str>) {
self.destination = destination.map(str::to_string);
self.route();
}
- pub fn balanced(&self) -> bool {
- self.balanced
- }
+ pub fn balanced(&self) -> bool { self.balanced }
- pub fn set_balanced(&mut self, balanced: bool) {
- self.balanced = balanced;
- }
+ pub fn set_balanced(&mut self, balanced: bool) { self.balanced = balanced; }
- pub fn external(&self) -> bool {
- self.external
- }
+ pub fn external(&self) -> bool { self.external }
- pub fn set_external(&mut self, external: bool) {
- self.external = external;
- }
+ pub fn set_external(&mut self, external: bool) { self.external = external; }
- pub fn set_leading(&mut self, leading: bool) {
- self.leading = leading;
- }
+ pub fn set_leading(&mut self, leading: bool) { self.leading = leading; }
- pub fn node(&self) -> Option {
- self.node.clone()
- }
+ pub fn node(&self) -> Option { self.node.clone() }
pub fn set_node(&mut self, node: &Node) {
self.node = Some(node.to_owned());
}
- pub fn node_id(&self) -> Option {
- self.node_id.clone()
- }
+ pub fn node_id(&self) -> Option { self.node_id.clone() }
pub fn set_node_id(&mut self, id: &str) {
self.node_id = Some(id.to_owned());
@@ -105,7 +83,8 @@ impl Parseable for Anchor {
fn render(&self) -> String {
let Some(destination) = &self.destination else {
panic!(
- "Attempt to render anchor {self:#?} without knowing its destination."
+ "Attempt to render anchor {self:#?} without knowing \
+ its destination."
)
};
@@ -131,9 +110,7 @@ impl Parseable for Anchor {
)
}
- fn flatten(&self) -> String {
- self.text.clone()
- }
+ fn flatten(&self) -> String { self.text.clone() }
}
impl std::fmt::Display for Anchor {
@@ -177,9 +154,8 @@ impl std::fmt::Display for Anchor {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render_anchor() {
@@ -188,7 +164,10 @@ mod tests {
anchor.set_destination(Some("AnchorDest"));
assert_eq!(
anchor.render(),
- r#"AnchorText "#
+ concat!(
+ r#"AnchorText "#,
+ )
);
}
@@ -196,9 +175,7 @@ mod tests {
#[should_panic(
expected = "Attempt to lex an anchor directly from a lexeme"
)]
- fn lex() {
- Anchor::lex(&Lexeme::default());
- }
+ fn lex() { Anchor::lex(&Lexeme::default()); }
#[test]
#[should_panic(expected = "without knowing its destination")]
diff --git a/src/syntax/content/parser/token/bold.rs b/src/syntax/content/parser/token/bold.rs
index 0252a67..558e091 100644
--- a/src/syntax/content/parser/token/bold.rs
+++ b/src/syntax/content/parser/token/bold.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, Lexeme},
-};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Bold {
@@ -8,15 +6,11 @@ pub struct Bold {
}
impl Bold {
- pub fn new(open: bool) -> Bold {
- Bold { open }
- }
+ pub fn new(open: bool) -> Bold { Bold { open } }
}
impl Parseable for Bold {
- fn probe(lexeme: &Lexeme) -> bool {
- lexeme.text() == "*"
- }
+ fn probe(lexeme: &Lexeme) -> bool { lexeme.text() == "*" }
fn lex(_lexeme: &Lexeme) -> Bold {
panic!("Attempt to lex a bold tag directly from a lexeme")
@@ -30,9 +24,7 @@ impl Parseable for Bold {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Bold {
@@ -44,9 +36,8 @@ impl std::fmt::Display for Bold {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render() {
@@ -61,9 +52,7 @@ mod tests {
#[should_panic(
expected = "Attempt to lex a bold tag directly from a lexeme"
)]
- fn lex() {
- Bold::lex(&Lexeme::default());
- }
+ fn lex() { Bold::lex(&Lexeme::default()); }
#[test]
fn token_display() {
diff --git a/src/syntax/content/parser/token/checkbox.rs b/src/syntax/content/parser/token/checkbox.rs
index 777e499..b740e2b 100644
--- a/src/syntax/content/parser/token/checkbox.rs
+++ b/src/syntax/content/parser/token/checkbox.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, Lexeme},
-};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct CheckBox {
@@ -8,9 +6,7 @@ pub struct CheckBox {
}
impl CheckBox {
- pub fn new(checked: bool) -> CheckBox {
- CheckBox { checked }
- }
+ pub fn new(checked: bool) -> CheckBox { CheckBox { checked } }
}
impl Parseable for CheckBox {
@@ -34,9 +30,7 @@ impl Parseable for CheckBox {
format!(r#" "#)
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for CheckBox {
@@ -48,9 +42,8 @@ impl std::fmt::Display for CheckBox {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render() {
diff --git a/src/syntax/content/parser/token/code.rs b/src/syntax/content/parser/token/code.rs
index 4aef324..35a6fd3 100644
--- a/src/syntax/content/parser/token/code.rs
+++ b/src/syntax/content/parser/token/code.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, Lexeme},
-};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Code {
@@ -8,15 +6,11 @@ pub struct Code {
}
impl Code {
- pub fn new(open: bool) -> Code {
- Code { open }
- }
+ pub fn new(open: bool) -> Code { Code { open } }
}
impl Parseable for Code {
- fn probe(lexeme: &Lexeme) -> bool {
- lexeme.text() == "`"
- }
+ fn probe(lexeme: &Lexeme) -> bool { lexeme.text() == "`" }
fn lex(_lexeme: &Lexeme) -> Code {
panic!("Attempt to lex a code tag directly from a lexeme")
@@ -30,9 +24,7 @@ impl Parseable for Code {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Code {
@@ -44,9 +36,8 @@ impl std::fmt::Display for Code {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render() {
@@ -61,9 +52,7 @@ mod tests {
#[should_panic(
expected = "Attempt to lex a code tag directly from a lexeme"
)]
- fn lex() {
- Code::lex(&Lexeme::default());
- }
+ fn lex() { Code::lex(&Lexeme::default()); }
#[test]
fn token_display() {
diff --git a/src/syntax/content/parser/token/header.rs b/src/syntax/content/parser/token/header.rs
index e18603c..88f1643 100644
--- a/src/syntax/content/parser/token/header.rs
+++ b/src/syntax/content/parser/token/header.rs
@@ -1,15 +1,14 @@
use std::{
collections::{HashMap, hash_map::Entry},
+ fmt::Display,
};
use crate::{
- prelude::*,
graph::Config,
- syntax::content::{Parseable, Lexeme},
+ prelude::*,
+ syntax::content::{Lexeme, Parseable},
};
-use std::fmt::Display;
-
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Header {
open: Option,
@@ -113,9 +112,7 @@ impl Parseable for Header {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Header {
@@ -195,9 +192,8 @@ impl Display for Level {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn make_id() {
diff --git a/src/syntax/content/parser/token/item.rs b/src/syntax/content/parser/token/item.rs
index 7652898..a0b8321 100644
--- a/src/syntax/content/parser/token/item.rs
+++ b/src/syntax/content/parser/token/item.rs
@@ -1,4 +1,4 @@
-use crate::syntax::content::{Parseable, Lexeme};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Default, Debug, Clone, Eq, PartialEq)]
pub struct Item {
@@ -7,9 +7,7 @@ pub struct Item {
}
impl Parseable for Item {
- fn probe(_: &Lexeme) -> bool {
- false
- }
+ fn probe(_: &Lexeme) -> bool { false }
fn lex(_: &Lexeme) -> Item {
panic!("Attempt to lex an item directly from a lexeme")
@@ -19,9 +17,7 @@ impl Parseable for Item {
panic!("Items should only be rendered by a list's render method")
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl Item {
@@ -50,9 +46,8 @@ impl std::fmt::Display for Item {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
#[should_panic(
diff --git a/src/syntax/content/parser/token/linebreak.rs b/src/syntax/content/parser/token/linebreak.rs
index 6996815..25e3d80 100644
--- a/src/syntax/content/parser/token/linebreak.rs
+++ b/src/syntax/content/parser/token/linebreak.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, parser::Lexeme},
-};
+use crate::syntax::content::{Parseable, parser::Lexeme};
#[derive(Default, Debug, Clone, Eq, PartialEq)]
pub struct LineBreak {}
@@ -10,17 +8,11 @@ impl Parseable for LineBreak {
lexeme.match_char('<') && lexeme.match_next_char('\n')
}
- fn lex(_lexeme: &Lexeme) -> LineBreak {
- LineBreak {}
- }
+ fn lex(_lexeme: &Lexeme) -> LineBreak { LineBreak {} }
- fn render(&self) -> String {
- String::from(" ")
- }
+ fn render(&self) -> String { String::from(" ") }
- fn flatten(&self) -> String {
- String::from('\n')
- }
+ fn flatten(&self) -> String { String::from('\n') }
}
impl std::fmt::Display for LineBreak {
@@ -31,9 +23,8 @@ impl std::fmt::Display for LineBreak {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn token_display() {
diff --git a/src/syntax/content/parser/token/list.rs b/src/syntax/content/parser/token/list.rs
index 82deb46..fa2817e 100644
--- a/src/syntax/content/parser/token/list.rs
+++ b/src/syntax/content/parser/token/list.rs
@@ -27,8 +27,8 @@ impl Parseable for List {
/// - Strict division is performed but related panics are unreachable given
/// the guarantees described in `List::scale_indent`
/// - Saturates subtractions from indent levels at zero. This is not
- /// unreachable, but a difference of zero is a no-op considering it
- /// would cause an iteration of zero times (over an empty range).
+ /// unreachable, but a difference of zero is a no-op considering it would
+ /// cause an iteration of zero times (over an empty range).
fn render(&self) -> String {
let tag = if self.ordered { "ol" } else { "ul" };
let mut output = String::new();
@@ -122,9 +122,8 @@ impl std::fmt::Display for List {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render_flat_list() {
diff --git a/src/syntax/content/parser/token/literal.rs b/src/syntax/content/parser/token/literal.rs
index ca521ae..6991fb0 100644
--- a/src/syntax/content/parser/token/literal.rs
+++ b/src/syntax/content/parser/token/literal.rs
@@ -16,13 +16,9 @@ impl Parseable for Literal {
}
}
- fn render(&self) -> String {
- self.text.clone()
- }
+ fn render(&self) -> String { self.text.clone() }
- fn flatten(&self) -> String {
- self.text.clone()
- }
+ fn flatten(&self) -> String { self.text.clone() }
}
impl std::fmt::Display for Literal {
@@ -33,9 +29,8 @@ impl std::fmt::Display for Literal {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn token_display() {
diff --git a/src/syntax/content/parser/token/oblique.rs b/src/syntax/content/parser/token/oblique.rs
index 0d69468..124e8fa 100644
--- a/src/syntax/content/parser/token/oblique.rs
+++ b/src/syntax/content/parser/token/oblique.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, Lexeme},
-};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Oblique {
@@ -8,15 +6,11 @@ pub struct Oblique {
}
impl Oblique {
- pub fn new(open: bool) -> Oblique {
- Oblique { open }
- }
+ pub fn new(open: bool) -> Oblique { Oblique { open } }
}
impl Parseable for Oblique {
- fn probe(lexeme: &Lexeme) -> bool {
- lexeme.text() == "_"
- }
+ fn probe(lexeme: &Lexeme) -> bool { lexeme.text() == "_" }
fn lex(_lexeme: &Lexeme) -> Oblique {
panic!("Attempt to lex an oblique tag directly from a lexeme")
@@ -30,9 +24,7 @@ impl Parseable for Oblique {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Oblique {
@@ -44,9 +36,8 @@ impl std::fmt::Display for Oblique {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render() {
@@ -61,9 +52,7 @@ mod tests {
#[should_panic(
expected = "Attempt to lex an oblique tag directly from a lexeme"
)]
- fn lex() {
- Oblique::lex(&Lexeme::default());
- }
+ fn lex() { Oblique::lex(&Lexeme::default()); }
#[test]
fn token_display() {
diff --git a/src/syntax/content/parser/token/paragraph.rs b/src/syntax/content/parser/token/paragraph.rs
index 1c51d87..963bfe3 100644
--- a/src/syntax/content/parser/token/paragraph.rs
+++ b/src/syntax/content/parser/token/paragraph.rs
@@ -6,9 +6,7 @@ pub struct Paragraph {
}
impl Paragraph {
- pub fn new(open: bool) -> Paragraph {
- Paragraph { open: Some(open) }
- }
+ pub fn new(open: bool) -> Paragraph { Paragraph { open: Some(open) } }
pub fn probe_end(lexeme: &Lexeme) -> bool {
lexeme.match_char('\n') && lexeme.match_next_char('\n')
@@ -21,9 +19,7 @@ impl Parseable for Paragraph {
!lexeme.is_whitespace()
}
- fn lex(_lexeme: &Lexeme) -> Paragraph {
- Paragraph { open: None }
- }
+ fn lex(_lexeme: &Lexeme) -> Paragraph { Paragraph { open: None } }
fn render(&self) -> String {
if let Some(open) = self.open {
@@ -39,9 +35,7 @@ impl Parseable for Paragraph {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Paragraph {
@@ -62,9 +56,8 @@ impl std::fmt::Display for Paragraph {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn lex() {
@@ -73,9 +66,8 @@ mod tests {
}
#[test]
- #[should_panic(
- expected = "Attempt to render a paragraph tag while open state is unknown"
- )]
+ #[should_panic(expected = "Attempt to render a paragraph tag while \
+ open state is unknown")]
fn render_state_unknown() {
let p = Paragraph::lex(&Lexeme::default());
drop(p.render());
diff --git a/src/syntax/content/parser/token/preformat.rs b/src/syntax/content/parser/token/preformat.rs
index 89e71dc..fbddf8a 100644
--- a/src/syntax/content/parser/token/preformat.rs
+++ b/src/syntax/content/parser/token/preformat.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, Lexeme},
-};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct PreFormat {
@@ -8,9 +6,7 @@ pub struct PreFormat {
}
impl PreFormat {
- pub fn new(open: bool) -> PreFormat {
- PreFormat { open: Some(open) }
- }
+ pub fn new(open: bool) -> PreFormat { PreFormat { open: Some(open) } }
}
impl std::fmt::Display for PreFormat {
@@ -29,9 +25,7 @@ impl Parseable for PreFormat {
lexeme.match_first_char('`') && (lexeme.next() == "\n" || lexeme.last())
}
- fn lex(_lexeme: &Lexeme) -> PreFormat {
- PreFormat { open: None }
- }
+ fn lex(_lexeme: &Lexeme) -> PreFormat { PreFormat { open: None } }
fn render(&self) -> String {
if let Some(o) = self.open {
@@ -47,16 +41,13 @@ impl Parseable for PreFormat {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn lex() {
@@ -68,9 +59,8 @@ mod tests {
}
#[test]
- #[should_panic(
- expected = "Attempt to render a preformat tag while open state is unknown"
- )]
+ #[should_panic(expected = "Attempt to render a preformat tag while \
+ open state is unknown")]
fn render() {
let from_empty_lexeme = PreFormat::lex(&Lexeme::default());
from_empty_lexeme.render();
diff --git a/src/syntax/content/parser/token/quote.rs b/src/syntax/content/parser/token/quote.rs
index ab0bd36..a6d144d 100644
--- a/src/syntax/content/parser/token/quote.rs
+++ b/src/syntax/content/parser/token/quote.rs
@@ -26,9 +26,7 @@ impl Parseable for Quote {
lexeme.match_char('>') && lexeme.match_next_char(' ')
}
- fn lex(_lexeme: &Lexeme) -> Quote {
- Quote::default()
- }
+ fn lex(_lexeme: &Lexeme) -> Quote { Quote::default() }
fn render(&self) -> String {
let opening = if let Some(url) = &self.url {
@@ -49,9 +47,7 @@ impl Parseable for Quote {
format!("\n{opening}\n{content}\n\n")
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Quote {
diff --git a/src/syntax/content/parser/token/strike.rs b/src/syntax/content/parser/token/strike.rs
index 14b4407..ae2f9e3 100644
--- a/src/syntax/content/parser/token/strike.rs
+++ b/src/syntax/content/parser/token/strike.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, Lexeme},
-};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Strike {
@@ -8,9 +6,7 @@ pub struct Strike {
}
impl Strike {
- pub fn new(open: bool) -> Strike {
- Strike { open }
- }
+ pub fn new(open: bool) -> Strike { Strike { open } }
}
impl Parseable for Strike {
@@ -27,9 +23,7 @@ impl Parseable for Strike {
String::from(tag)
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Strike {
@@ -41,9 +35,8 @@ impl std::fmt::Display for Strike {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render() {
@@ -58,9 +51,7 @@ mod tests {
#[should_panic(
expected = "Attempt to lex a strike tag directly from a lexeme"
)]
- fn lex() {
- Strike::lex(&Lexeme::default());
- }
+ fn lex() { Strike::lex(&Lexeme::default()); }
#[test]
fn token_display() {
diff --git a/src/syntax/content/parser/token/table.rs b/src/syntax/content/parser/token/table.rs
index cf5cb51..2eb29e3 100644
--- a/src/syntax/content/parser/token/table.rs
+++ b/src/syntax/content/parser/token/table.rs
@@ -15,9 +15,7 @@ impl Table {
self.headers.push(header.trim().to_string());
}
- pub fn add_row(&mut self, row: Vec) {
- self.contents.push(row);
- }
+ pub fn add_row(&mut self, row: Vec) { self.contents.push(row); }
pub fn add_cell(&mut self, content: &str) {
if let Some(last) = self.contents.last_mut() {
@@ -37,13 +35,9 @@ impl Table {
}
impl Parseable for Table {
- fn probe(lexeme: &Lexeme) -> bool {
- lexeme.match_char_sequence('%', '\n')
- }
+ fn probe(lexeme: &Lexeme) -> bool { lexeme.match_char_sequence('%', '\n') }
- fn lex(_lexeme: &Lexeme) -> Table {
- Table::default()
- }
+ fn lex(_lexeme: &Lexeme) -> Table { Table::default() }
fn render(&self) -> String {
let mut xml = String::from("\n\n");
@@ -73,9 +67,7 @@ impl Parseable for Table {
xml
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Table {
diff --git a/src/syntax/content/parser/token/underline.rs b/src/syntax/content/parser/token/underline.rs
index 2da61b7..1fbbdda 100644
--- a/src/syntax/content/parser/token/underline.rs
+++ b/src/syntax/content/parser/token/underline.rs
@@ -1,6 +1,4 @@
-use crate::{
- syntax::content::{Parseable, Lexeme},
-};
+use crate::syntax::content::{Lexeme, Parseable};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Underline {
@@ -8,9 +6,7 @@ pub struct Underline {
}
impl Underline {
- pub fn new(open: bool) -> Underline {
- Underline { open }
- }
+ pub fn new(open: bool) -> Underline { Underline { open } }
}
impl Parseable for Underline {
@@ -30,9 +26,7 @@ impl Parseable for Underline {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Underline {
@@ -44,9 +38,8 @@ impl std::fmt::Display for Underline {
#[cfg(test)]
mod tests {
- use crate::syntax::content::parser::Token;
-
use super::*;
+ use crate::syntax::content::parser::Token;
#[test]
fn render() {
@@ -61,9 +54,7 @@ mod tests {
#[should_panic(
expected = "Attempt to lex an underline tag directly from a lexeme"
)]
- fn lex() {
- Underline::lex(&Lexeme::default());
- }
+ fn lex() { Underline::lex(&Lexeme::default()); }
#[test]
fn token_display() {
diff --git a/src/syntax/content/parser/token/verse.rs b/src/syntax/content/parser/token/verse.rs
index 6dbeb9b..b690b57 100644
--- a/src/syntax/content/parser/token/verse.rs
+++ b/src/syntax/content/parser/token/verse.rs
@@ -43,9 +43,7 @@ impl Parseable for Verse {
}
}
- fn flatten(&self) -> String {
- String::default()
- }
+ fn flatten(&self) -> String { String::default() }
}
impl std::fmt::Display for Verse {