markdown_org_extract/lib.rs
1#![warn(missing_docs)]
2//! Extract Emacs Org-mode tasks from markdown files.
3//!
4//! This is the library behind the `markdown-org-extract` command-line tool.
5//! Both entry points run the same code: the binary parses arguments and writes
6//! bytes, everything below that line lives here. See [`README.md`] at the
7//! repository root for the user-facing description of the format itself.
8//!
9//! # Pipeline
10//!
11//! A run is two steps, and they are separate so a caller can hold on to the
12//! tasks and build several agendas from one scan:
13//!
14//! 1. [`scan_directory`] walks a directory and returns every [`Task`] it finds.
15//! 2. [`filter_agenda`] turns those tasks into an [`AgendaOutput`] for a given
16//! [`AgendaScope`] and date window.
17//!
18//! ```no_run
19//! use markdown_org_extract::{filter_agenda, scan_directory, AgendaDates, AgendaScope, ScanOptions};
20//!
21//! # fn main() -> Result<(), markdown_org_extract::AppError> {
22//! let outcome = scan_directory("notes".as_ref(), &ScanOptions::default(), None)?;
23//! let agenda = filter_agenda(
24//! outcome.tasks,
25//! AgendaScope::Day,
26//! AgendaDates::default(),
27//! "Europe/Moscow",
28//! false,
29//! false,
30//! true,
31//! )?;
32//! # let _ = agenda;
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! # Determinism
38//!
39//! Nothing here reads the wall clock unless it has to: `AgendaDates::current_date`
40//! overrides "today" so a caller can render the agenda as it would look on any
41//! date. Consumers are expected to pass it rather than rely on the host clock.
42//!
43//! [`README.md`]: https://github.com/VitalyOstanin/markdown-org-extract
44
45pub mod agenda;
46pub mod clock;
47pub mod error;
48pub mod exceptions;
49pub mod holidays;
50pub mod locale;
51pub mod parser;
52mod regex_limits;
53pub mod render;
54pub mod scan;
55pub mod timestamp;
56pub mod types;
57
58// The flat facade is the surface embedders are expected to use; the modules
59// stay public so anything not re-exported here is still reachable without
60// waiting for a release.
61pub use crate::agenda::{filter_agenda, AgendaDates, AgendaOutput, AgendaScope};
62pub use crate::error::AppError;
63pub use crate::holidays::HolidayCalendar;
64pub use crate::locale::get_weekday_mappings;
65pub use crate::parser::{
66 display_text, extract_tasks, extract_tasks_with_counter, parse_heading_line, HeadingLine,
67 HeadingToken,
68};
69pub use crate::render::{render_days_html, render_days_markdown, render_html, render_markdown};
70pub use crate::scan::{scan_directories, scan_directory, ScanOptions, ScanOutcome};
71pub use crate::timestamp::{
72 add_months, closest_date, parse_timestamp_parts, DatePreference, Repeater, RepeaterType,
73 RepeaterUnit, TimestampParts,
74};
75pub use crate::types::{
76 ClockEntry, DayAgenda, Priority, ProcessingStats, Task, TaskType, TaskWithOffset,
77 DEFAULT_MAX_TASKS, MAX_FILE_SIZE,
78};