Adopt and apply nightly rustfmt configuration
This commit is contained in:
parent
a7770e1486
commit
d7d034757a
45 changed files with 431 additions and 474 deletions
|
|
@ -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<String> {
|
||||
self.destination.clone()
|
||||
}
|
||||
pub fn destination(&self) -> Option<String> { 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<Node> {
|
||||
self.node.clone()
|
||||
}
|
||||
pub fn node(&self) -> Option<Node> { self.node.clone() }
|
||||
|
||||
pub fn set_node(&mut self, node: &Node) {
|
||||
self.node = Some(node.to_owned());
|
||||
}
|
||||
|
||||
pub fn node_id(&self) -> Option<String> {
|
||||
self.node_id.clone()
|
||||
}
|
||||
pub fn node_id(&self) -> Option<String> { 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#"<a class="detached" title="" href="/node/AnchorDest">AnchorText</a>"#
|
||||
concat!(
|
||||
r#"<a class="detached" title="" "#,
|
||||
r#"href="/node/AnchorDest">AnchorText</a>"#,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -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")]
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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#"<input type="checkbox"{toggle}/>"#)
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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<bool>,
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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("<br>")
|
||||
}
|
||||
fn render(&self) -> String { String::from("<br>") }
|
||||
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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</blockquote>\n")
|
||||
}
|
||||
|
||||
fn flatten(&self) -> String {
|
||||
String::default()
|
||||
}
|
||||
fn flatten(&self) -> String { String::default() }
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Quote {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ impl Table {
|
|||
self.headers.push(header.trim().to_string());
|
||||
}
|
||||
|
||||
pub fn add_row(&mut self, row: Vec<String>) {
|
||||
self.contents.push(row);
|
||||
}
|
||||
pub fn add_row(&mut self, row: Vec<String>) { 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<table>\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 {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue