rust_texas/lib.rs
1//!
2//! Well, hello there.
3//!
4//! So this crate aims to provide convenient ways of programmatically generating a latex file.
5//!
6//! If you want to just convert from some other file format WITHOUT any processing, I recommend `pandoc`.
7//!
8//! I'll slowly and steadily begin adding more features, and my goal is to be able to cover most standard use-cases of Latex.
9//! If you want any feature, raise an issue! I will see it, and while I may not reply (scatterbrained, much?) I will fix it.
10//!
11//! A shout-out to another crate, `tex-rs`. A few of the design choices I made are based on this crate.
12
13/// Bunch of From<>s, they feel like they might be useful
14pub mod casting;
15
16/// Latex commands/macros. Haven't found this in any other crate.
17pub mod commands;
18
19/// Standard Latex things.
20pub mod component;
21
22/// Packages and the overall latex layout.
23pub mod document;
24
25/// Custom error type.
26pub mod errors;
27
28/// Really helpful stuff.
29pub mod macros;
30
31/// Ubiquitous.
32pub mod traits;
33
34pub mod label;
35
36// #[cfg(feature = "markdown")]
37// pub mod markdown;
38
39///
40#[cfg(test)]
41mod tests;
42
43pub mod prelude {
44 pub use crate::commands::*;
45 pub use crate::component::*;
46 pub use crate::document::*;
47 pub use crate::errors::*;
48 pub use crate::label::*;
49 pub use crate::traits::*;
50
51 pub fn escape(s: &str, esc: Option<&[char]>) -> String {
52 if esc.is_none() {
53 s.replace("_", "\\_")
54 .replace("^", "\\^")
55 .replace("#", "\\#")
56 .replace("&", "\\&")
57 .replace("%", "\\%")
58 .replace("$", "\\$")
59 .replace("{", "\\{")
60 .replace("}", "\\}")
61 } else {
62 let esc = esc.unwrap();
63 let mut s = s.to_string();
64 for c in esc {
65 s = s.replace(&c.to_string(), &format!("\\{}", c));
66 }
67 s
68 }
69 }
70
71 // All the macros, again.
72 pub use crate::{
73 builtin, chapter, command, document, environment, figure, frame, image, label, package,
74 part, reference, row, section, tabular, textchunk, unwrap,
75 };
76}