mdbook_plotly/
code_handler.rs1pub mod parse_context;
2pub mod plot_obj_parser;
3pub mod until;
4
5use crate::preprocessor::config::{MapEvalConfig, PlotlyInputType};
6use anyhow::Result;
7use plotly::Plot;
8use serde_json::Value;
9
10pub fn handle(
11 raw_code: String,
12 input_type: &PlotlyInputType,
13 map_eval: &MapEvalConfig,
14) -> Result<Plot> {
15 let result = match input_type {
16 PlotlyInputType::JSONInput => handle_json_input(raw_code, map_eval)?,
17 };
18 Ok(result)
19}
20
21pub fn handle_json_input(raw_code: String, map_eval: &MapEvalConfig) -> Result<Plot> {
29 let mut value: Value = json5::from_str(&raw_code)?;
31 plot_obj_parser::parse(&mut value, map_eval)
32}