Skip to main content

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 holidays;
49pub mod locale;
50pub mod parser;
51mod regex_limits;
52pub mod render;
53pub mod scan;
54pub mod timestamp;
55pub mod types;
56
57// The flat facade is the surface embedders are expected to use; the modules
58// stay public so anything not re-exported here is still reachable without
59// waiting for a release.
60pub use crate::agenda::{filter_agenda, AgendaDates, AgendaOutput, AgendaScope};
61pub use crate::error::AppError;
62pub use crate::holidays::HolidayCalendar;
63pub use crate::locale::get_weekday_mappings;
64pub use crate::parser::{
65    display_text, extract_tasks, extract_tasks_with_counter, parse_heading_line, HeadingLine,
66    HeadingToken,
67};
68pub use crate::render::{render_days_html, render_days_markdown, render_html, render_markdown};
69pub use crate::scan::{scan_directory, ScanOptions, ScanOutcome};
70pub use crate::timestamp::{
71    add_months, closest_date, parse_timestamp_parts, DatePreference, Repeater, RepeaterType,
72    RepeaterUnit, TimestampParts,
73};
74pub use crate::types::{
75    ClockEntry, DayAgenda, Priority, ProcessingStats, Task, TaskType, TaskWithOffset,
76    DEFAULT_MAX_TASKS, MAX_FILE_SIZE,
77};