1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Lua scripting support for mdvault.
//!
//! This module provides a sandboxed Lua environment with access to
//! mdvault's date math and template rendering engines.
//!
//! # Overview
//!
//! The scripting layer allows users to define custom validation logic,
//! type definitions, and automation rules in Lua while having access
//! to mdvault's core functionality.
//!
//! # Example
//!
//! ```rust
//! use mdvault_core::scripting::LuaEngine;
//!
//! let engine = LuaEngine::sandboxed().unwrap();
//!
//! // Use date math
//! let date = engine.eval_string(r#"mdv.date("today + 7d")"#).unwrap();
//! println!("One week from now: {}", date);
//!
//! // Render templates
//! let greeting = engine.eval_string(
//! r#"mdv.render("Hello {{name}}!", { name = "World" })"#
//! ).unwrap();
//! println!("{}", greeting);
//! ```
//!
//! # Available Lua Functions
//!
//! The `mdv` global table provides:
//!
//! - `mdv.date(expr, format?)` - Evaluate date math expressions
//! - `mdv.render(template, context)` - Render templates with variables
//! - `mdv.is_date_expr(str)` - Check if a string is a date expression
//!
//! With vault context (via `LuaEngine::with_vault_context`):
//! - `mdv.template(name, vars?)` - Render a template by name
//! - `mdv.capture(name, vars?)` - Execute a capture workflow
//! - `mdv.macro(name, vars?)` - Execute a macro workflow
//! - `mdv.read_note(path)` - Read a note's content and frontmatter
//! - `mdv.current_note()` - Get the current note being processed
//! - `mdv.backlinks(path)` - Get notes linking to a path
//! - `mdv.outlinks(path)` - Get notes a path links to
//! - `mdv.query(opts)` - Query the vault index
//! - `mdv.selector(opts)` - Show interactive fuzzy selector for notes of a type
//!
//! # Security
//!
//! By default, the Lua environment is sandboxed to prevent:
//! - File system access (`io` library removed)
//! - Shell command execution (`os` library removed)
//! - Loading external modules (`require` removed)
//! - Arbitrary code loading (`load`, `loadfile`, `dofile` removed)
//! - Debug library access (`debug` removed)
pub use LuaEngine;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;