moving to fem.mint
This commit is contained in:
parent
df24de61cf
commit
11fb670a64
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -810,6 +810,9 @@ dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"glob",
|
"glob",
|
||||||
"roxy_core",
|
"roxy_core",
|
||||||
|
"roxy_markdown_parser",
|
||||||
|
"roxy_markdown_tera_goop",
|
||||||
|
"roxy_tera_parser",
|
||||||
"serde",
|
"serde",
|
||||||
"syntect",
|
"syntect",
|
||||||
"tera",
|
"tera",
|
||||||
|
@ -825,6 +828,29 @@ dependencies = [
|
||||||
"tera",
|
"tera",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "roxy_markdown_parser"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"pulldown-cmark",
|
||||||
|
"roxy_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "roxy_markdown_tera_goop"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"roxy_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "roxy_tera_parser"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"roxy_core",
|
||||||
|
"tera",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.16"
|
version = "1.0.16"
|
||||||
|
|
|
@ -6,6 +6,10 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glob = "0.3.1"
|
glob = "0.3.1"
|
||||||
syntect = "5.1.0"
|
syntect = "5.1.0"
|
||||||
|
#roxy_core = { path = "../roxy-core/" }
|
||||||
|
roxy_markdown_parser = { path = "../roxy-markdown-parser/" }
|
||||||
|
roxy_tera_parser = { path = "../roxy-tera-parser/" }
|
||||||
|
roxy_markdown_tera_goop = { path = "../roxy-markdown-tera-goop/" }
|
||||||
roxy_core = { git = "https://github.com/kitsunecafe/roxy-core.git" }
|
roxy_core = { git = "https://github.com/kitsunecafe/roxy-core.git" }
|
||||||
clap = { version = "4.4.17", features = ["derive"] }
|
clap = { version = "4.4.17", features = ["derive"] }
|
||||||
toml = "0.8.8"
|
toml = "0.8.8"
|
||||||
|
|
32
src/main.rs
32
src/main.rs
|
@ -1,4 +1,7 @@
|
||||||
use clap::Parser as Clap;
|
use clap::Parser as Clap;
|
||||||
|
use roxy_markdown_parser::MarkdownParser;
|
||||||
|
use roxy_tera_parser::TeraParser;
|
||||||
|
use roxy_markdown_tera_goop::MarkdownTeraParser;
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{BufReader, Error, ErrorKind, Read},
|
io::{BufReader, Error, ErrorKind, Read},
|
||||||
|
@ -7,7 +10,7 @@ use std::{
|
||||||
use toml::Table;
|
use toml::Table;
|
||||||
|
|
||||||
use glob::{glob, PatternError};
|
use glob::{glob, PatternError};
|
||||||
use roxy_core::roxy::{Html, Markdown, Parser, Roxy};
|
use roxy_core::roxy::{Parse, Parser, Roxy};
|
||||||
|
|
||||||
#[derive(Clap)]
|
#[derive(Clap)]
|
||||||
#[command(name = "Roxy")]
|
#[command(name = "Roxy")]
|
||||||
|
@ -120,15 +123,21 @@ impl Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert<P: AsRef<Path>>(&mut self, path: &P, meta: Table) {
|
fn normalize_path<P: AsRef<Path>>(path: &P) -> String {
|
||||||
let path = path
|
path.as_ref()
|
||||||
.as_ref()
|
|
||||||
.with_extension("")
|
.with_extension("")
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.split(path::MAIN_SEPARATOR_STR)
|
.split(path::MAIN_SEPARATOR_STR)
|
||||||
.fold(String::new(), |a, b| format!("{a}.{b}"));
|
.fold(String::new(), |a, b| format!("{a}.{b}"))
|
||||||
|
}
|
||||||
|
|
||||||
self.inner.insert(path.trim_start_matches('.'), &meta);
|
fn insert<P: AsRef<Path>>(&mut self, path: &P, meta: Table) {
|
||||||
|
self.inner
|
||||||
|
.insert(Self::normalize_path(path).trim_start_matches('.'), &meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get<P: AsRef<Path>>(&self, path: &P) -> Option<&tera::Value> {
|
||||||
|
self.inner.get(&Self::normalize_path(path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,14 +162,19 @@ fn main() -> Result<(), RoxyError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut parser = Parser::new();
|
let mut parser = Parser::new();
|
||||||
parser.push(Markdown::new());
|
parser.push(MarkdownParser::new());
|
||||||
|
|
||||||
let html = Html::new(tera::Tera::default(), context.inner);
|
let goop = MarkdownTeraParser::new();
|
||||||
|
parser.push(goop);
|
||||||
|
|
||||||
|
let tera = tera::Tera::default();
|
||||||
|
let html = TeraParser::new(tera, context.inner);
|
||||||
parser.push(html);
|
parser.push(html);
|
||||||
|
|
||||||
|
|
||||||
for file in files {
|
for file in files {
|
||||||
let file_name = file.with_extension("html");
|
let file_name = file.with_extension("html");
|
||||||
let _ = Roxy::process_file(&file, &(&file_path.to_output(&file_name)?), &mut parser);
|
Roxy::process_file(&file, &(&file_path.to_output(&file_name)?), &mut parser).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue