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#![warn(missing_docs)]
26
27pub mod backlinks;
28pub mod chat;
29pub mod checklist;
30pub mod fs;
31#[allow(dead_code)]
32pub mod fslog;
33pub mod habits;
34pub mod html;
35pub mod i18n;
36pub mod journal;
37pub mod knowledge;
38pub mod merge;
39pub mod parser;
40pub mod plugins;
41pub mod schedule;
42pub mod stats;
43#[allow(dead_code)]
44pub mod sync;
45pub mod tgtxt;
46pub mod tokens;
47pub mod types;
48pub mod worker;
49
50// Re-export core types for convenience
51pub use types::{
52    FileEntry, FsError, Habits, KnowledgeConfig, SyncError, SyncFile, SyncRequest, SyncResponse,
53    CHAT_FILENAME, DIR_ARCHIVE, DIR_JOURNAL, DIR_MEDIA, DIR_USER_ROOT, DONE_FILENAME,
54    HABIT_COMPLETED, HABIT_COMPLETED_AT_WEEKEND, HABIT_SKIPPED, LATER_FILENAME, MD_EXT, MODE_CHAT,
55    MODE_FULL, MODE_JOURNAL, MODE_NOTES, MODE_TASKS, MOOD_EMOJIS, MOOD_HABIT, READ_FILENAME,
56    SHOP_FILENAME, STATUS_MERGED, STATUS_NOT_MODIFIED, STATUS_OK, STATUS_UPDATED_ON_SERVER,
57    WATCH_FILENAME,
58};
59
60pub use backlinks::{Backlink, BacklinkIndex, LinkEdge, LinkGraph, LinkNode};
61pub use chat::{
62    append_to_chat_msg, delete_chat_msg, find_chat_msg_by_hash, move_from_chat, read_chat_msgs,
63    rename_chat_msg, today_header as chat_today_header,
64};
65pub use checklist::{
66    add_checklist_item, add_header_and_text, checklist_item, checklist_items,
67    complete_checklist_item, incomplete_checklist_items, remove_checklist_item,
68    remove_completed_checklist_items,
69};
70pub use fs::split_posix_path;
71pub use fs::VirtualFs;
72pub use fslog::FsLog;
73pub use habits::{
74    emoji_for_status, habit_emoji, habits, last_week_habits, weekday_emoji, write_habits,
75};
76pub use html::{
77    escape_html, markdown_to_html, replace_with_placeholders, restore_from_placeholders,
78    strip_html_tags,
79};
80pub use i18n::{add_emoji, emoji_for};
81pub use journal::{
82    add_emoji as journal_add_emoji, add_record as journal_add_record,
83    today_header as journal_today_header, today_journal_filename,
84};
85pub use knowledge::{FileChange, KnowledgeBase, NoteHit};
86pub use merge::merge;
87pub use parser::{
88    emoji_prefix, extract_headings, extract_markdown_links, is_multiline, lcfirst, levenshtein,
89    norm_new_lines, similar, split_text_into_chunks, substr, today_chat_header, today_journal_path,
90    ucfirst,
91};
92pub use plugins::{
93    can_handle as world_clock_can_handle, format_report as format_world_clock_report,
94    handle as world_clock_handle, world_clock_for_names, world_clock_now, TimezoneEntry,
95};
96pub use schedule::ScheduleManager;
97pub use stats::{done_today, format_today_report, today_report, CompletedItem, TodayReport};
98pub use sync::{MediaEntry, MediaSyncResponse, SyncEngine};
99pub use tgtxt::{extract_text_imgs_links, ExtractResult};
100pub use tokens::TokenManager;
101pub use worker::{
102    move_due_tasks, next_exclude_today, remove_completed_checklist, remove_completed_inbox_entries,
103    remove_completed_items, schedule_report, NightlyReport,
104};