fix pretty_print

This commit is contained in:
Mark 2024-06-26 13:02:50 +02:00
parent 7a945e80ba
commit 12d90a8022
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "mers_lib"
version = "0.8.16"
version = "0.8.17"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "library to use the mers language in other projects"
@ -19,7 +19,6 @@ run = []
ecolor-term = ["dep:colored"]
ecolor-html = ["dep:html-escape"]
# pretty-print requires ecolor-term, but this is not listed here because I want people to explicitly opt-in to the extra `colored` dependency via the ecolor-term feature.
pretty-print = []
[dependencies]

View File

@ -5,13 +5,12 @@ use crate::{
theme::ThemeGen,
};
#[cfg(not(feature = "ecolor-term"))]
compile_error!("feature ecolor-term is required if pretty-print feature is enabled");
#[cfg(feature = "ecolor-term")]
pub fn pretty_print(src: Source) {
pretty_print_to(src, &mut std::io::stdout(), DefaultTheme)
}
/// to print to stdout, use `pretty_print` (available only with the `ecolor-term` feature)
pub fn pretty_print_to<O: Write>(mut src: Source, out: &mut O, theme: impl FTheme<O>) {
let srca = Arc::new(src.clone());
match parse(&mut src, &srca) {
@ -65,7 +64,9 @@ pub enum FColor {
Unknown,
}
#[cfg(feature = "ecolor-term")]
pub struct DefaultTheme;
#[cfg(feature = "ecolor-term")]
impl ThemeGen for DefaultTheme {
type C = FColor;
type T = std::io::Stdout;