Skip to main content

oxios_markdown/
lib.rs

1//! # oxios-markdown
2//!
3//! Markdown knowledge management library — ported from [files.md](https://github.com/zakirullin/files.md)
4//! by Artem Zakirullin. Licensed under MIT — see LICENSE-THIRD-PARTY.
5//!
6//! This crate provides core functionality for managing a knowledge base
7//! stored as plain `.md` files:
8//!
9//! - **VirtualFs** — sandboxed filesystem with path traversal protection
10//! - **BacklinkIndex** — bidirectional link tracking between notes
11//! - **Merge** — LCS-based conflict resolution
12//! - **Parser** — text processing utilities (similarity, links, headings)
13//!
14//! # Example
15//!
16//! ```no_run
17//! use oxios_markdown::VirtualFs;
18//! use std::path::PathBuf;
19//!
20//! let fs = VirtualFs::new(PathBuf::from("/path/to/knowledge")).unwrap();
21//! fs.write("brain", "Rust.md", "# Rust\n\nSee [Ownership](brain/Ownership.md)").unwrap();
22//! let content = fs.read("brain", "Rust.md").unwrap();
23//! ```
24
25// `.unwrap()` in tests is idiomatic (workspace convention); suppressed only
26// under `cfg(test)` so production code remains linted by the `--lib` clippy pass.
27#![cfg_attr(test, allow(clippy::unwrap_used))]
28
29pub mod backlinks;
30pub mod chat;
31pub mod checklist;
32pub mod frontformat;
33pub mod fs;
34#[allow(dead_code)]
35pub mod fslog;
36pub mod habits;
37pub mod html;
38pub mod i18n;
39pub mod journal;
40pub mod knowledge;
41pub mod merge;
42pub mod parser;
43pub mod plugins;
44pub mod schedule;
45pub mod stats;
46#[allow(dead_code)]
47pub mod sync;
48pub mod tgtxt;
49pub mod tokens;
50pub mod types;
51pub mod watch;
52pub mod worker;
53
54// Re-export core types for convenience
55pub use types::{
56    CHAT_FILENAME, DIR_ARCHIVE, DIR_JOURNAL, DIR_MEDIA, DIR_USER_ROOT, DONE_FILENAME, FileEntry,
57    FsError, HABIT_COMPLETED, HABIT_COMPLETED_AT_WEEKEND, HABIT_SKIPPED, Habits, KnowledgeConfig,
58    LATER_FILENAME, MD_EXT, MODE_CHAT, MODE_FULL, MODE_JOURNAL, MODE_NOTES, MODE_TASKS,
59    MOOD_EMOJIS, MOOD_HABIT, READ_FILENAME, SHOP_FILENAME, STATUS_MERGED, STATUS_NOT_MODIFIED,
60    STATUS_OK, STATUS_UPDATED_ON_SERVER, SyncError, SyncFile, SyncRequest, SyncResponse,
61    WATCH_FILENAME,
62};
63
64pub use backlinks::{Backlink, BacklinkIndex, LinkEdge, LinkGraph, LinkNode};
65pub use chat::{
66    append_to_chat_msg, delete_chat_msg, find_chat_msg_by_hash, move_from_chat, read_chat_msgs,
67    rename_chat_msg, today_header as chat_today_header,
68};
69pub use checklist::{
70    add_checklist_item, add_header_and_text, checklist_item, checklist_items,
71    complete_checklist_item, incomplete_checklist_items, remove_checklist_item,
72    remove_completed_checklist_items,
73};
74pub use fs::VirtualFs;
75pub use fs::split_posix_path;
76pub use fslog::FsLog;
77pub use habits::{
78    emoji_for_status, habit_emoji, habits, last_week_habits, weekday_emoji, write_habits,
79};
80pub use html::{
81    escape_html, markdown_to_html, replace_with_placeholders, restore_from_placeholders,
82    strip_html_tags,
83};
84pub use i18n::{add_emoji, emoji_for};
85pub use journal::{
86    add_emoji as journal_add_emoji, add_record as journal_add_record,
87    today_header as journal_today_header, today_journal_filename,
88};
89pub use knowledge::{FileChange, KnowledgeBase, NoteHit};
90pub use merge::merge;
91pub use parser::{
92    emoji_prefix, extract_headings, extract_markdown_links, is_multiline, lcfirst, levenshtein,
93    norm_new_lines, similar, split_text_into_chunks, substr, today_chat_header, today_journal_path,
94    ucfirst,
95};
96pub use plugins::{
97    TimezoneEntry, can_handle as world_clock_can_handle,
98    format_report as format_world_clock_report, handle as world_clock_handle,
99    world_clock_for_names, world_clock_now,
100};
101pub use schedule::ScheduleManager;
102pub use stats::{CompletedItem, TodayReport, done_today, format_today_report, today_report};
103pub use sync::{MediaEntry, MediaSyncResponse, SyncEngine};
104pub use tgtxt::{ExtractResult, extract_text_imgs_links};
105pub use tokens::TokenManager;
106pub use worker::{
107    NightlyReport, move_due_tasks, next_exclude_today, remove_completed_checklist,
108    remove_completed_inbox_entries, remove_completed_items, schedule_report,
109};