"#)
);
}
@@ -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#"
"#,
+ )
);
}
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..3702d77 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,42 @@ 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 const fn balanced(&self) -> bool { self.balanced }
- pub fn set_balanced(&mut self, balanced: bool) {
+ pub const fn set_balanced(&mut self, balanced: bool) {
self.balanced = balanced;
}
- pub fn external(&self) -> bool {
- self.external
- }
+ pub const fn external(&self) -> bool { self.external }
- pub fn set_external(&mut self, external: bool) {
+ pub const fn set_external(&mut self, external: bool) {
self.external = external;
}
- pub fn set_leading(&mut self, leading: bool) {
+ pub const 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());
@@ -74,7 +58,7 @@ impl Anchor {
fn route(&mut self) {
self.destination = if let Some(destination) = self.destination.clone() {
- if destination.contains(":") || destination.contains("/") {
+ if destination.contains(':') || destination.contains('/') {
Some(destination)
} else if destination.is_empty() && self.text.is_empty() {
None
@@ -105,7 +89,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 +116,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 +160,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 +170,10 @@ mod tests {
anchor.set_destination(Some("AnchorDest"));
assert_eq!(
anchor.render(),
- r#"AnchorText"#
+ concat!(
+ r#"AnchorText"#,
+ )
);
}
@@ -196,9 +181,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..6ef5bd3 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 const 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..c2597b7 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 const 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..a6f6977 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 const 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..1f5fe02 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,
@@ -33,7 +32,7 @@ impl Header {
) -> String {
let base_id = if !config.ascii_dom_ids || next_lexeme.next().is_ascii()
{
- next_lexeme.next().clone()
+ next_lexeme.next()
} else {
String::from("h")
};
@@ -61,7 +60,7 @@ impl Header {
}
}
- pub fn level(&self) -> u8 {
+ pub const fn level(&self) -> u8 {
match self.level {
Level::One => 1,
Level::Two => 2,
@@ -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 {
@@ -150,7 +147,7 @@ pub enum Level {
}
impl Level {
- fn from_u8(u: u8) -> Level {
+ const fn from_u8(u: u8) -> Level {
if u <= 1 {
Level::One
} else if u == 2 {
@@ -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..023efd7 100644
--- a/src/syntax/content/parser/token/linebreak.rs
+++ b/src/syntax/content/parser/token/linebreak.rs
@@ -1,26 +1,18 @@
-use crate::{
- syntax::content::{Parseable, parser::Lexeme},
-};
+use crate::syntax::content::{Parseable, parser::Lexeme};
#[derive(Default, Debug, Clone, Eq, PartialEq)]
-pub struct LineBreak {}
+pub struct LineBreak;
impl Parseable for LineBreak {
fn probe(lexeme: &Lexeme) -> bool {
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..db7aff1 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();
@@ -43,19 +43,19 @@ impl Parseable for List {
.unwrap_or(0)
.strict_div(scale);
- output.push_str(&format!("
{}", item.text));
+ write_log!(output, "
{}", item.text);
if next_level > level {
// open nested lists
for _ in 0..(next_level.saturating_sub(level)) {
- output.push_str(&format!("<{tag}>\n"));
+ write_log!(output, "<{tag}>\n");
}
} else {
// close current item
output.push_str("
");
// close nested lists
for _ in 0..(level.saturating_sub(next_level)) {
- output.push_str(&format!("{tag}>"));
+ write_log!(output, "{tag}>");
}
output.push('\n');
}
@@ -70,7 +70,7 @@ impl Parseable for List {
}
impl List {
- pub fn new(ordered: bool) -> List {
+ pub const fn new(ordered: bool) -> List {
List {
ordered,
items: vec![],
@@ -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() {
@@ -203,7 +202,7 @@ mod tests {
fn token_display() {
let list = List::new(false);
assert_eq!(
- format!("{}", Token::List(list.clone())),
+ format!("{}", Token::List(list)),
"Tk:List [0 unordered items]"
);
}
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..fa12ba2 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 const 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..ab635d2 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 const 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..1ca0128 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 const 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..4aadc56 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 const 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..bf60f1d 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 const 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..919929a 100644
--- a/src/syntax/content/parser/token/verse.rs
+++ b/src/syntax/content/parser/token/verse.rs
@@ -7,7 +7,7 @@ pub struct Verse {
}
impl Verse {
- pub fn new(open: bool) -> Verse {
+ pub const fn new(open: bool) -> Verse {
Verse {
open: Some(open),
citation: None,
@@ -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 {
diff --git a/static/graph.toml b/static/graph.toml
index fe3a3c7..daa7c3d 100644
--- a/static/graph.toml
+++ b/static/graph.toml
@@ -314,7 +314,7 @@ b
c
`
-You still get "a b c" as a result. This is the case for paragraphs, but not for lists, verse blocks and preformatted text. Blockquotes support both modes.
+You still get "a b c" as a result. This is the case for paragraphs, but not for lists, verse blocks, tables and preformatted text. Blockquotes support both modes.
This is useful when editing your text, allowing you to break some thoughts and special syntax without losing control over where your paragraph ends, particularly when handling huge paragraphs.
@@ -418,7 +418,7 @@ If you have a more complex citation, you can use multiple lines starting with `-
-- Benedita da Silva,
-- |Speech on the Federal Senate|https://www25.senado.leg.br/web/atividade/pronunciamentos/-/p/pronunciamento/165765|,
-- March 3rd, 1995, <
--- International Day for the Elimination of Racial Discrimination.
+-- International Day for the Elimination of Racial Discrimination
`
> Dois grandes mitos dominam a história oficial do Brasil:
@@ -426,7 +426,7 @@ If you have a more complex citation, you can use multiple lines starting with `-
-- Benedita da Silva,
-- |Speech on the Federal Senate|https://www25.senado.leg.br/web/atividade/pronunciamentos/-/p/pronunciamento/165765|,
-- March 3rd, 1995, <
--- Dia Internacional para a Eliminação da Discriminação Racial.
+-- International Day for the Elimination of Racial Discrimination
The first URL found in your citation will be used as the blockquote element's `cite` value.
@@ -456,6 +456,50 @@ Lines starting with a `+` character will create numbered lists instead:
+ ni
+ san
+### Tables
+
+Tables are blocks delimited by a sole `%` on its own line:
+
+`
+%
+ Country ! Capital
+ Colombia | Bogotá
+ Belgium | Brussels
+ Palestine | Jerusalem
+ Zambia | Lusaka
+%
+`
+
+%
+ Country ! Capital
+ Colombia | Bogotá
+ Belgium | Brussels
+ Palestine | Jerusalem
+ Zambia | Lusaka
+%
+
+Table cells are delimited by either a `!` for headers or `|` for common cells. These delimiters must be surrounded by at least one space to each side and are optional at the first and last position of each line.
+
+This means you can use any of the following formats:
+
+`
+%
+ middle | only
+ tail | only |
+ | lead | only
+ | fully | wrapped |
+%
+`
+
+%
+ middle | only
+ tail | only |
+ | lead | only
+ | fully | wrapped |
+%
+
+Because at least one space is required around each delimiter, you must indent the table inside the surrounding `%` markers by at least one space.
+
## Rendering unformatted text
The backtick character `\\`` can be used to render unformatted blocks and inline text:
@@ -482,25 +526,23 @@ Finally, you can precede any character with a `\\\\` to fully _escape_ that char
## Raw HTML
-If you need some more advanced feature that is not supported directly by en's markup snytax, you can always just write plain HTML and it will be passed along. For example, you could render a table:
+If you need some more advanced feature that is not supported directly by en's markup snytax, you can always just write plain HTML and it will be passed along. For example, you could render a form:
`
-<table>
- <tr>
- <td> Hi, </td>
- <td> *HTML*! </td>
- </tr>
-</table>
+<form style="text-align: center;">
+ <label for="name"> *__Name__* </label>
+ <input type="text" id="name"/>
+ <input type="submit"/>
+</form>
`
-
-
-
Hi,
-
*HTML*!
-
-
+
-Notice that, as shown in this example, you can mix en syntax and HTML. You might want to add a space between your HTML tags and en special syntax so the boundary is clearer, but otherwise they don't tend to overlap since the symbols most used in HTML are not special in en.
+Notice that, as shown in this example, you can mix en syntax and HTML. You might want to add a space between your HTML tags and en special syntax so the boundary is clearer, but otherwise they don't tend to overlap since the symbols most used in HTML are not special in en with the exception of `<`, which is interpreted specially only at the end of lines.
If you want to avoid either one of these syntaxes from being interpreted specially, you should escape the relevant characters as explained in the previous section.
"""
@@ -723,11 +765,7 @@ text = """
- [ ] Invert where redirects are set
- [x] Formatting
- [x] Blockquotes
- - [ ] Tables
- - `%` block
- - newline for rows
- - indented, space-surrounded `!` wrap for headers
- - indented, space-surrounded `|` wrap for cells
+ - [x] Tables
- [x] Nested formatting
- [x] Headers
- [x] Preformatted blocks
diff --git a/static/public/assets/style.css b/static/public/assets/style.css
index 519fb8d..8242120 100644
--- a/static/public/assets/style.css
+++ b/static/public/assets/style.css
@@ -1,4 +1,5 @@
:root {
+ color-scheme: light dark;
--base-font-size: 1em;
}
@@ -15,6 +16,8 @@ body {
line-height: 1.75;
box-sizing: border-box;
min-width: 0;
+ background: light-dark(#eee, #222);
+ color: light-dark(#000, #f1e9e5);
}
main {
@@ -61,14 +64,14 @@ code:hover {
}
pre, code {
+ background: light-dark(#e0e0e0, #333);
font-family: mono, monospace;
- background: #e0e0e0;
- border: solid 2px #d0d0d0;
+ border: solid 2px light-dark(#d0d0d0, #434343);
border-radius: 6px;
}
a {
- color: #0f6366;
+ color: light-dark(#0f6366, #1dd7d7);
text-decoration: underline dotted #159b9b;
text-decoration-thickness: 2.5px;
text-underline-offset: 3px;
@@ -78,27 +81,27 @@ a {
a.attached:hover,
#nav-main a:hover
{
- color: #117c7c;
+ color: light-dark(#117c7c, #00ffff);
text-shadow: 0px 0px 22px #10afaf;
transition: 1500ms;
}
a.detached {
- color: #595959;
- text-decoration-color: #444444;
+ color: light-dark(#595959, #acacac);
+ text-decoration-color: light-dark(#444444, #777);
}
a.external {
- color: #1958a7;
- text-decoration-color: #2A7CDF;
+ color: light-dark(#1958a7, #2fbae4);
+ text-decoration-color: light-dark(#2A7CDF, #46c1e7);
text-decoration-style: solid;
text-decoration-thickness: 1.5px;
transition: 1500ms;
}
a.external:hover {
- color: #0393b2;
- text-decoration-color: #1ed4f1;
+ color: light-dark(#0393b2, #74e5ff);
+ text-decoration-color: light-dark(#1ed4f1, #aeffff);
transition: 1500ms;
}
@@ -106,7 +109,7 @@ a:visited,
a.detached:visited,
a.external:visited
{
- text-decoration-color: #bbb;
+ text-decoration-color: light-dark(#bbb, #999);
transition: 1500ms;
}
@@ -143,14 +146,14 @@ span.root-label {
span.id-label {
font-family: mono, monospace;
- background: #e0e0e0;
- border: solid 1px #d0d0d0;
+ background: light-dark(#e0e0e0, #444);
+ border: solid 1px light-dark(#d0d0d0, #666);
}
span.hidden-label {
- background: #888;
- color: #eee;
- border: solid 1px #d0d0d0;
+ background: light-dark(#888, #000);
+ color: light-dark(#eee, #969696);
+ border: solid 1px light-dark(#d0d0d0, #555);
}
h1 {
@@ -276,8 +279,8 @@ button
border-radius: 5px;
padding: 5px 8px;
margin-right: 3px;
- background: #eeeeff00;
- border-color: #216767;
+ background: light-dark(#eeeeff00, #002020);
+ border-color: light-dark(#216767, #138e8e);
border-width: 0.5px;
transition: 1500ms;
}
@@ -287,7 +290,7 @@ input[type="submit"]:hover,
select:hover,
button:hover
{
- border-color: #36a9a9;
+ border-color: light-dark(#36a9a9, #00ffff);
box-shadow: 2px 2px #36a9a9ee;
}
@@ -315,9 +318,9 @@ table {
}
table th {
- background: #099;
+ background: light-dark(#099, #002929);
color: #fff;
- border-color: #222;
+ border-color: light-dark(#222, #666);
}
td, th {
@@ -362,92 +365,9 @@ p.verse {
}
@media (prefers-color-scheme: dark) {
- * {
- background: #222222;
- color: #f1e9e5;
- }
-
- pre, code {
- background: #333333;
- border: solid 1px #434343;
- }
-
- a {
- color: #1dd7d7;
- transition: 1500ms;
- }
-
- a.attached:hover,
- #nav-main a:hover
- {
- color: #00ffff;
- transition: 1500ms;
- }
-
- a.external {
- color: #2fbae4;
- text-decoration-color: #46c1e7;
- transition: 1500ms;
- }
-
- a.external:hover {
- color: #74e5ff;
- text-decoration-color: #aeffff;
- transition: 1500ms;
- }
-
- a.detached {
- color: #acacac;
- text-decoration-color: #777;
- transition: 1500ms;
- }
-
- span.id-label {
- background: #444;
- border-color: #666;
- }
-
- span.hidden-label {
- background: #000;
- border-color: #555;
- color: #969696;
- }
-
-
- a:visited,
- a.detached:visited,
- a.external:visited
- {
- text-decoration-color: #999;
- transition: 1500ms;
- }
-
- input[type="text"],
- input[type="submit"],
- select,
- button
- {
- background: #002020;
- border-color: #138e8e;
- }
-
- input[type="text"]:hover,
- input[type="submit"]:hover,
- select:hover,
- button:hover
- {
- border-color: #00ffff;
- }
-
span.root-label {
border-width: 1px;
}
-
- table th {
- background: #002929;
- border-color: #666;
- }
-
}
@media (max-width: 600px) {