1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! # omgbase-graph
//!
//! The omgbase graph layer, Rust implementation — the **pure** half: the
//! semantic nodes a Markdown document's blocks project (links, wikilinks,
//! tasks, anchors, inline fields) and the authored edge descriptors they and
//! the frontmatter yield (links, frontmatter relations, inline relations),
//! plus URI normalization and relative-path resolution. The contract is
//! `spec/graph/README.md` in the omgbase repository, with the executable
//! fixtures under `spec/graph/cases`; [`SPEC_VERSION`] is the spec version
//! this crate conforms to. Resolution to node ids, minting, the edge
//! intervals and the `doc_edges` rollup read and write the database and live
//! in `omgbase-store`, which calls this crate inside its commit transaction.
//!
//! ```
//! use omgbase_format::parse_markdown;
//! use omgbase_graph::{DstKind, NodeKind, Provenance, extract_doc_edges, node_rows, project_nodes};
//! use omgbase_properties::DocBlock;
//!
//! let tree = parse_markdown("# T\n\nSee [x](./x.md#H) and [[note^r1]]\n\nrel:: [[y]]\n");
//! let ids: Vec<String> = (0..DocBlock::count(&tree.children)).map(|i| format!("b_{i}")).collect();
//! let blocks = DocBlock::from_blocks(&tree.children, &ids);
//!
//! let nodes = project_nodes(&blocks);
//! let kinds: Vec<NodeKind> = nodes.iter().map(|n| n.kind).collect();
//! assert_eq!(
//! kinds,
//! [NodeKind::Link, NodeKind::Wikilink, NodeKind::Anchor, NodeKind::Wikilink, NodeKind::InlineField]
//! );
//! assert_eq!(nodes[0].span, Some((4, 17)));
//! let rows = node_rows("d_0", &nodes);
//! assert!(rows[0].node_id.starts_with("n_") && rows[0].node_id.len() == 14);
//!
//! let edges = extract_doc_edges(&blocks, None);
//! assert_eq!(edges.len(), 3);
//! assert_eq!(edges[0].target, "./x.md");
//! assert_eq!(edges[0].anchor.as_deref(), Some("H"));
//! assert_eq!(edges[0].dst_kind, DstKind::Document);
//! assert_eq!(edges[1].dst_kind, DstKind::Block); // `[[note^r1]]`: a block ref
//! assert_eq!(edges[2].predicate, "rel"); // and `[[y]]` is not also a plain link
//! assert_eq!(edges[2].provenance, Provenance::InlineField);
//! ```
pub use ;
pub use mask_code_bytes;
pub use ;
pub use ;
pub use normalize_uri;
/// The `spec/graph/VERSION` this crate implements (`major.minor`).
pub const SPEC_VERSION: &str = "1.0";