mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 05:43:53 +01:00
fix pretty_print_to
This commit is contained in:
parent
1b79cfc08f
commit
af1715ef91
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mers_lib"
|
||||
version = "0.8.20"
|
||||
version = "0.8.21"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "library to use the mers language in other projects"
|
||||
|
@ -1,28 +1,29 @@
|
||||
use std::{io::Write, process::exit, sync::Arc};
|
||||
|
||||
use crate::{
|
||||
errors::CheckError,
|
||||
prelude_compile::{parse, Source},
|
||||
theme::ThemeGen,
|
||||
};
|
||||
|
||||
#[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) {
|
||||
Err(e) => {
|
||||
if let Err(e) = pretty_print_to(src, &mut std::io::stdout(), DefaultTheme) {
|
||||
eprintln!("{e:?}");
|
||||
exit(28);
|
||||
}
|
||||
Ok(parsed) => {
|
||||
}
|
||||
|
||||
/// 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>,
|
||||
) -> Result<(), CheckError> {
|
||||
let srca = Arc::new(src.clone());
|
||||
let parsed = parse(&mut src, &srca)?;
|
||||
print_parsed(&srca, parsed.as_ref(), out, theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum AbstractColor {
|
||||
Gray,
|
||||
|
Loading…
Reference in New Issue
Block a user