Skip to content

Commit

Permalink
Merge pull request #203 from sl-sh-dev/fix-mdbook-docs
Browse files Browse the repository at this point in the history
fix mdbook address issue #202
  • Loading branch information
gpwclark authored Sep 26, 2024
2 parents 2f40606 + 5c1ffbf commit 3cb4138
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 2,330 deletions.
27 changes: 15 additions & 12 deletions doc/mdbook-slosh-eval/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn handle_supports(pre: &dyn Preprocessor, sub_args: &ArgMatches) -> ! {
mod slosh_eval_lib {
use super::*;
use pulldown_cmark::CodeBlockKind;
use slosh_lib::{new_slosh_vm_with_builtins, run_reader, Reader};
use slosh_lib::Reader;

/// Preprocessor to evaluate slosh code
pub struct EvalSlosh;
Expand Down Expand Up @@ -115,9 +115,9 @@ mod slosh_eval_lib {
if name.starts_with("slosh") && !name.contains("no-execute") {
slosh_code_block_num += 1;
log::debug!(
"Evaluate slosh code block #{} in chapter: {}",
slosh_code_block_num,
"File: {}: block #{}",
chapter.name,
slosh_code_block_num,
);
tracking = true;
}
Expand All @@ -142,7 +142,8 @@ mod slosh_eval_lib {
buf += "\n";
}
tracking = false;
log::debug!("New Code Block: {}", buf);
log::debug!("```slosh\n{}", buf);
log::debug!("```");
events.push(Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced(
"slosh".into(),
))));
Expand Down Expand Up @@ -185,19 +186,21 @@ mod slosh_eval_lib {
}

fn exec_code(code: String) -> String {
let mut vm = new_slosh_vm_with_builtins();
let mut vm = slosh_lib::new_slosh_vm_with_builtins_and_core();

let mut reader =
Reader::from_string(r#"(load "core.slosh")"#.to_string(), &mut vm, "", 1, 0);
_ = run_reader(&mut reader);
let code = format!(
r#"(def *prn* "")
(dyn prn (fn (&rest) (set! *prn* (str *prn* &rest))) (do {}))"#,
r#"(import test)
(def *prn* "")
(dyn
prn
(fn (&rest) (set! *prn* (str *prn* &rest)))
(do {}))"#,
code
);

let mut reader = Reader::from_string(code, &mut vm, "", 1, 0);
let s = run_reader(&mut reader)
.map(|x| x.display_value(&mut vm))
let s = slosh_lib::run_reader(&mut reader)
.map(|x| x.display_value(&vm))
.map_err(|e| format!("Encountered error: {}", e));
match s {
Ok(s) | Err(s) => s,
Expand Down
1 change: 0 additions & 1 deletion doc/mdbook-slosh/.gitignore

This file was deleted.

Loading

0 comments on commit 3cb4138

Please sign in to comment.