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