enable most md options; resolves #6

This commit is contained in:
Rowan 2024-12-05 00:38:40 -06:00
parent 920041184b
commit 247f39e7ec
3 changed files with 24 additions and 16 deletions

17
Cargo.lock generated
View file

@ -735,16 +735,23 @@ dependencies = [
[[package]]
name = "pulldown-cmark"
version = "0.9.6"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
checksum = "f86ba2052aebccc42cbbb3ed234b8b13ce76f75c3551a303cb2bcffcff12bb14"
dependencies = [
"bitflags 2.6.0",
"getopts",
"memchr",
"pulldown-cmark-escape",
"unicase",
]
[[package]]
name = "pulldown-cmark-escape"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae"
[[package]]
name = "quick-xml"
version = "0.32.0"
@ -824,7 +831,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "roxy_cli"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"anyhow",
"clap",
@ -853,9 +860,9 @@ dependencies = [
[[package]]
name = "roxy_markdown_parser"
version = "0.1.0"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c9ad43dee77efc231568de10362592e9d828a5fbeb1d1a6f800515b0424e5ca"
checksum = "340648d5566e42d77d96a3dc1d0682defff8248a5eff39b32d751890dbfa4503"
dependencies = [
"pulldown-cmark",
"roxy_core",

View file

@ -1,6 +1,6 @@
[package]
name = "roxy_cli"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Rowan <rowan@kitsu.cafe>"]
repository = "https://fem.mint.lgbt/kitsunecafe/roxy-cli"
@ -12,7 +12,7 @@ homepage = "https://roxy-docs.netlify.app"
[dependencies]
glob = "~0.3.1"
syntect = "~5.2.0"
roxy_markdown_parser = "~0.1.0"
roxy_markdown_parser = "~0.1.2"
roxy_tera_parser = "~0.1.0"
roxy_markdown_tera_rewriter = "~0.1.0"
roxy_syntect = "~0.1.0"

View file

@ -10,23 +10,22 @@ use context::Context;
use file_path::FilePath;
use functions::register_functions;
use roxy_markdown_parser::MarkdownParser;
use roxy_markdown_parser::{MarkdownParser, Options as MPOptions};
use roxy_markdown_tera_rewriter::{MarkdownTeraPreformatter, MarkdownTeraRewriter};
use roxy_syntect::SyntectParser;
use roxy_tera_parser::{TeraParser, TeraParserOptions};
use clap::Parser as Clap;
use std::{
ffi,
fs,
ffi, fs,
path::{Path, PathBuf},
};
use syntect::{highlighting::ThemeSet, parsing::SyntaxSet};
use glob::glob;
use roxy_core::roxy::{Parser, Roxy};
use roxy_core::result::Result;
use roxy_core::roxy::{Parser, Roxy};
use crate::iter_ext::{Head, MapFoldExt};
@ -91,10 +90,7 @@ fn load_config(path: &Path) -> Config {
.into()
}
fn copy_static<T: AsRef<Path>>(
files: &Vec<&PathBuf>,
file_path: &FilePath<T>,
) -> Result<()> {
fn copy_static<T: AsRef<Path>>(files: &Vec<&PathBuf>, file_path: &FilePath<T>) -> Result<()> {
for file in files {
let output = file_path.to_output(file).unwrap();
fs::create_dir_all(output.parent().unwrap())?;
@ -127,6 +123,11 @@ fn main() -> Result<()> {
let mut context = Context::from_files(meta, &file_path)?;
context.build_paths(&content, &file_path)?;
let md_options = MPOptions::all()
& !MPOptions::ENABLE_SMART_PUNCTUATION
& !MPOptions::ENABLE_YAML_STYLE_METADATA_BLOCKS
& !MPOptions::ENABLE_PLUSES_DELIMITED_METADATA_BLOCKS;
let theme = config.syntect.theme;
let syntax_set = SyntaxSet::load_defaults_newlines();
@ -151,7 +152,7 @@ fn main() -> Result<()> {
let mut syntect = SyntectParser::new(&syntax_set, &theme_set, theme.as_str());
parser.push(&mut syntect);
let mut md = MarkdownParser::new();
let mut md = MarkdownParser::with_options(md_options);
parser.push(&mut md);
let mut rewriter = MarkdownTeraRewriter::new();