devup_editor_input_rules/lib.rs
1// Input rule matching logic ported from
2// `packages/plugin/src/defaults/inputRules.ts`. Keeping pattern/tactic
3// equivalence with the TS side matters more than pedantic Rust style,
4// so a handful of lints that fire on the idiomatic mirror are allowed.
5//
6// Justifications:
7// - `module_name_repetitions`: public API uses names like `MarkdownMatch`
8// in module `markdown.rs` — the repetition aids discoverability.
9// - `too_many_lines`: the `shortcuts()` table has ~90 lines of rule
10// declarations. Splitting across helpers would obscure the 1:1
11// mapping with the TS `MARKDOWN_SHORTCUTS` array.
12// - `doc_markdown`: prose references to "Process" key events, Notion
13// etc. trigger false positives for missing code fences.
14#![allow(
15 clippy::module_name_repetitions,
16 clippy::too_many_lines,
17 clippy::doc_markdown
18)]
19
20//! Markdown shortcut, special-character, and inline-mark matchers for
21//! the devup editor input-rule pipeline.
22//!
23//! Every matcher is a pure function of `(block_text, cursor_offset)`:
24//! no DOM, no editor handle, no commands. The React layer calls into
25//! these matchers, inspects the returned [`Match`] payload, and
26//! synthesises the appropriate `dispatchBatch` sequence on the JS
27//! side. This keeps command dispatch (which needs an `EditorHandle`)
28//! in React and confines the hot-path string work to Rust.
29//!
30//! The regex patterns, delimiter rules, and skip-`~~` reservation are
31//! mirrored byte-for-byte from the TypeScript source so behaviour is
32//! identical under typical clipboard / keyboard interactions.
33
34mod mark;
35mod markdown;
36mod special_char;
37
38pub use mark::{InlineMatch, LinkMatch, MarkKind, match_inline_mark};
39pub use markdown::{MarkdownMatch, match_markdown_shortcut};
40pub use special_char::{SpecialCharMatch, match_special_char};