|
@@ -1,5 +1,9 @@
|
|
|
|
+mod html_formatter;
|
|
mod utils;
|
|
mod utils;
|
|
|
|
|
|
|
|
+use html_formatter::HtmlFormatter;
|
|
|
|
+use numbat::markup::Formatter;
|
|
|
|
+use numbat::pretty_print::PrettyPrint;
|
|
use numbat::resolver::{CodeSource, NullImporter};
|
|
use numbat::resolver::{CodeSource, NullImporter};
|
|
use numbat::{Context, InterpreterResult};
|
|
use numbat::{Context, InterpreterResult};
|
|
|
|
|
|
@@ -15,10 +19,12 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
|
pub fn interpret(code: &str) -> String {
|
|
pub fn interpret(code: &str) -> String {
|
|
utils::set_panic_hook();
|
|
utils::set_panic_hook();
|
|
|
|
|
|
|
|
+ let html_formatter = HtmlFormatter {};
|
|
|
|
+
|
|
let mut numbat = Context::new(NullImporter {});
|
|
let mut numbat = Context::new(NullImporter {});
|
|
match numbat.interpret(&code, CodeSource::Text) {
|
|
match numbat.interpret(&code, CodeSource::Text) {
|
|
Ok((_, result)) => match result {
|
|
Ok((_, result)) => match result {
|
|
- InterpreterResult::Value(q) => format!("{}", q),
|
|
|
|
|
|
+ InterpreterResult::Value(q) => html_formatter.format(&q.pretty_print(), true),
|
|
InterpreterResult::Continue => "Nothing to show".into(),
|
|
InterpreterResult::Continue => "Nothing to show".into(),
|
|
InterpreterResult::Exit(_) => "Error!".into(),
|
|
InterpreterResult::Exit(_) => "Error!".into(),
|
|
},
|
|
},
|