basalt_core/
lib.rs

1//! This crate provides the core functionality for Basalt, a TUI application for Obsidian.
2//! It lets you read and manipulate Obsidian's configuration, vaults, and notes.
3//!
4//! # Example
5//!
6//! ```
7//! use basalt_core::obsidian::{ObsidianConfig, Error};
8//!
9//! let config = ObsidianConfig::load();
10//! ```
11//!
12//! This crate also provides a markdown parser that produces a custom AST using the
13//! [`pulldown_cmark::Parser`]. The "AST" acts as an intermediate layer. This enables segregation
14//! of the parsing logic into a module under basalt-core lib.
15//!
16//! # Example
17//!
18//! ```
19//! use basalt_core::markdown::{from_str, Range, Node, MarkdownNode, HeadingLevel, Text};
20//!
21//! let markdown = "# My Heading\n\nSome text.";
22//! let nodes = from_str(markdown);
23//!
24//! assert_eq!(nodes, vec![
25//!   Node {
26//!     markdown_node: MarkdownNode::Heading {
27//!       level: HeadingLevel::H1,
28//!       text: Text::from("My Heading"),
29//!     },
30//!     source_range: Range { start: 0, end: 13 },
31//!   },
32//!   Node {
33//!     markdown_node: MarkdownNode::Paragraph {
34//!       text: Text::from("Some text."),
35//!     },
36//!     source_range: Range { start: 14, end: 24 },
37//!   },
38//! ])
39//! ```
40
41#![deny(missing_docs)]
42#![doc(html_root_url = "https://docs.rs/basalt-core")]
43
44/// Provides Markdown parser that supports Obsidian flavor.
45/// Obsidian flavor is a combination of different flavors and a few differences.
46///
47/// Namely `CommonMark` and `GitHub Flavored Markdown`. More info
48/// [here](https://help.obsidian.md/Editing+and+formatting/Obsidian+Flavored+Markdown).
49///
50/// NOTE: Current iteration does not handle Obsidian flavor, unless it is covered by
51/// pulldown-cmark. Part of Obsidian flavor is for example use of any character inside tasks to
52/// mark them as completed `- [?] Completed`.
53///
54/// This crate uses [`pulldown_cmark`] to parse the markdown and enable the applicable features. This
55/// crate uses own intermediate types to provide the parsed markdown nodes.
56pub mod markdown;
57
58/// Provides Obsidian interoperability operations
59pub mod obsidian;