entrenar/research/notebook/mod.rs
1//! Notebook Exporter for Jupyter bridge (ENT-024)
2//!
3//! Provides export to Jupyter notebook format (.ipynb) with
4//! evcxr kernel support for Rust.
5
6mod cell;
7mod exporter;
8mod kernel;
9
10#[cfg(test)]
11mod tests;
12
13pub use cell::{Cell, CellMetadata, CellOutput, CellType};
14pub use exporter::{NotebookExporter, NotebookMetadata};
15pub use kernel::KernelSpec;
16
17/// Split source into lines for Jupyter format
18pub(crate) fn split_source(source: String) -> Vec<String> {
19 source
20 .lines()
21 .map(|line| format!("{line}\n"))
22 .collect::<Vec<_>>()
23 .into_iter()
24 .enumerate()
25 .map(|(i, mut line)| {
26 // Remove trailing newline from last line
27 if i == source.lines().count().saturating_sub(1) {
28 line.pop();
29 }
30 line
31 })
32 .collect()
33}