mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 05:43:53 +01:00
fix pretty_print
This commit is contained in:
parent
7a945e80ba
commit
12d90a8022
@ -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]
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user