diff --git a/mers_lib/Cargo.toml b/mers_lib/Cargo.toml index e0c710f..4684f76 100755 --- a/mers_lib/Cargo.toml +++ b/mers_lib/Cargo.toml @@ -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] diff --git a/mers_lib/src/pretty_print.rs b/mers_lib/src/pretty_print.rs index 1f678f8..8fc13d0 100644 --- a/mers_lib/src/pretty_print.rs +++ b/mers_lib/src/pretty_print.rs @@ -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(mut src: Source, out: &mut O, theme: impl FTheme) { 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;