present/
lib.rs

1//! `present` is a simple tool that lets you interpolate the standard output of
2//! arbitrary scripts that get interpreted by the shell into your markdown
3//! documents.
4//!
5//! With `present`, you can create a `File` struct by pointing it to a path.
6//! This will parse all codeblocks with the `present` prefix, and add them as
7//! commands to the struct. From there, you can present the file by using the
8//! `File::present` function, which will modify the internal content. From
9//! there, you can use the `File::print` or `File::save` functions to print the
10//! presented document to stdout or save it back to the original file.
11//!
12//! ```rust
13//! use std::path::PathBuf;
14//!
15//! let mut file = present::File::new(PathBuf::from("README.md")).unwrap();
16//! file.present().unwrap();
17//! file.save();
18//! ```
19
20mod codeblock;
21mod command;
22mod common;
23mod diff;
24mod error;
25mod file;
26mod grapheme;
27mod lexer;
28mod parser;
29mod position;
30mod prompt;
31mod rope_ext;
32
33// Publicly exposed
34pub use crate::{diff::Diff, error::Error, file::File};
35
36// Public only to crate
37pub(crate) use crate::{
38  codeblock::Codeblock,
39  command::Command,
40  grapheme::{byte_index_to_grapheme_index, grapheme_index_to_byte_index},
41  lexer::Lexer,
42  parser::Parser,
43  position::Position,
44  prompt::prompt,
45  rope_ext::RopeExt,
46};
47
48/// Present's internal result type
49pub type Result<T = (), E = Error> = std::result::Result<T, E>;
50
51// Test README
52#[doc = include_str!("../README.md")]
53#[cfg(doctest)]
54pub struct ReadmeDoctests;