fn render_latex(&self) -> String;
fn render_html(&self) -> String;
fn render_gemtext(&self) -> String;
+ fn render_plaintext(&self) -> String;
}
}
full_text
}
+
+ fn render_plaintext(&self) -> String {
+ let mut full_text = String::new();
+ for element in &self.elements {
+ full_text.push_str(&(String::from("\t") + &element.render_gemtext()));
+ }
+ full_text
+ }
}
This is where the Table of Contents will go.\n\n")
}
+
+ fn render_plaintext(&self) -> String {
+ String::new()
+ }
}
+use std::collections::HashMap;
+
use crate::types::metadata::Metadata;
use crate::types::reference_list::ReferenceList;
use crate::types::Renderable;
}
full_text
}
+
+ fn render_plaintext(&self) -> String {
+ let mut full_text = String::new();
+ for element in &self.body {
+ full_text.push_str(&element.render_plaintext());
+ }
+ full_text
+ }
}
impl Document{
data.insert(String::from("author"), self.metadata.author.to_string());
data.insert(String::from("date"), self.metadata.date.to_string());
- data.insert(String::from("elements"), format!("{}", self.body.len()));
+ data.insert(String::from("elements"), self.body.len().to_string());
+ let text = self.render_plaintext();
+ let word_count = text.split_whitespace().collect::<Vec<&str>>().iter().len();
+ data.insert(String::from("word_count"), word_count.to_string());
+ let character_count = text.split_whitespace().map(|s| s.chars()).flatten().collect::<Vec<char>>().len();
+ data.insert(String::from("character_count"), character_count.to_string());
format!("{data:?}")
}
use crate::types::Renderable;
-use crate::inline::{parse_inline_latex, parse_inline_html, parse_inline_gemtext};
+use crate::inline::{parse_inline_gemtext, parse_inline_html, parse_inline_latex, parse_inline_remove};
// submodule for handling headings
};
format!("{section} {text}\n\n")
}
+
+ fn render_plaintext (&self) -> String {
+ let text = parse_inline_remove(self.text.trim()).to_uppercase();
+ format!("{text}\n\n")
+ }
}
#[cfg(test)]
}
full_text + "\n"
}
+
+ fn render_plaintext(&self) -> String {
+ let mut full_text = String::new();
+ for item in &self.items {
+ full_text.push_str(&item.render_gemtext());
+ }
+ full_text + "\n"
+ }
}
pub struct Item {
fn render_gemtext(&self) -> String {
format!("* {}\n", parse_inline_gemtext(self.text.trim()))
}
+
+ fn render_plaintext(&self) -> String {
+ parse_inline_gemtext(self.text.trim()) + "\n"
+ }
}
format!("\
# {title}\n
{author} - {date}\n\n",
- title = self.title.trim(),
- author = self.author.trim(),
- date = self.date.trim()
+ title = self.title.trim(),
+ author = self.author.trim(),
+ date = self.date.trim()
+ )
+ }
+
+ fn render_plaintext (&self) -> String {
+ format!("\
+{title}\n
+{author} - {date}\n\n",
+ title = self.title.trim(),
+ author = self.author.trim(),
+ date = self.date.trim()
)
}
}
use crate::types::Renderable;
-use crate::inline::{parse_inline_latex, parse_inline_html, parse_inline_gemtext};
+use crate::inline::{parse_inline_latex, parse_inline_html, parse_inline_gemtext, parse_inline_remove};
// submodule for handling paragraphs
fn render_gemtext (&self) -> String {
parse_inline_gemtext(&self.text.trim()) + "\n\n"
}
+
+ fn render_plaintext (&self) -> String {
+ parse_inline_remove(&self.text.trim()) + "\n\n"
+ }
}
#[cfg(test)]
fn render_gemtext(&self) -> String {
String::from("```\n") + &self.text.trim() + "\n```\n\n"
}
+
+ fn render_plaintext(&self) -> String {
+ String::from(self.text.trim()) + "\n\n"
+ }
}
}
full_text
}
+
fn render_html(&self) -> String {
let mut full_text = String::from("<section><h2>Bibliography</h2>");
for reference in &self.list {
}
full_text + "</section>"
}
+
fn render_gemtext(&self) -> String {
let mut full_text = String::from("## Bibliography\n\n");
for reference in &self.list {
}
full_text
}
+
+ fn render_plaintext(&self) -> String {
+ String::new()
+ }
}
impl Clone for ReferenceList {
full_text
}
+
+ fn render_plaintext(&self) -> String {
+ String::new()
+ }
}
impl Clone for Reference {
full_text
}
+ fn render_plaintext(&self) -> String {
+ String::new()
+ }
}
impl Clone for Work {