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
//! tramlines-md: the markdown format of tramlines. It checks a markdown
//! document against a schema, repairs it, and derives the scaffold a
//! schema implies.
//!
//! A schema is YAML in the vocabulary of the grammar: the core grammar of
//! tramlines-core, with the markdown format grammar laid on it, which adds
//! the sections, blocks and units a document of one kind must carry. The
//! engine parses the document, holds it to the schema and reports each
//! failure as a [`Finding`]. The items of tramlines-core are re-exported,
//! so a host needs this crate alone.
//!
//! Compile a schema and check a document against it:
//!
//! ```
//! use tramlines_md::{
//! Locator, RepoPath,
//! check::{CheckOptions, NullHost, check_against},
//! document::Document,
//! grammar::{FormatRegistry, RegexCache, compile, load_grammar},
//! markdown::Dialect,
//! yaml,
//! };
//!
//! let schema = "line-limit: 0\nsections:\n - heading: Groceries\n level: 1\n blocks:\n - kind: bullet-list\n each: { template: '${item:word} x${n:int}', example: Milk x2 }\n";
//! let schema = compile(
//! &yaml::parse(schema, 1)?,
//! &load_grammar()?,
//! &FormatRegistry::default(),
//! &RegexCache::new(),
//! &RepoPath::parse("/list.yaml").expect("a path"),
//! "list",
//! &Dialect::default(),
//! )
//! .expect("the schema compiles");
//!
//! let text = "# Groceries\n\n- Milk x2\n- Bread\n";
//! let path = RepoPath::parse("/groceries.md").expect("a path");
//! let document = Document::parse(path, text, &Dialect::default());
//! let states = schema.states(document.frontmatter.as_ref());
//! let out = check_against(
//! document.view(),
//! &schema,
//! &states,
//! &NullHost,
//! CheckOptions::default(),
//! Locator::schema("list"),
//! );
//! assert_eq!(out.findings.len(), 1);
//! assert_eq!(out.findings[0].criterion, "TL_74");
//! assert_eq!(out.findings[0].line, Some(4));
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
// sokf-implements: MD-9_AC-1
// sokf-implements: MD-9_AC-3
// sokf:begin reexports
pub use ;
// sokf:end reexports