@@ -11,11 +11,9 @@ use std::collections::BTreeMap;
11
11
use std:: io;
12
12
use std:: path:: PathBuf ;
13
13
14
+ mod rules;
14
15
mod std_links;
15
16
16
- /// The Regex for rules like `r[foo]`.
17
- static RULE_RE : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r"(?m)^r\[([^]]+)]$" ) . unwrap ( ) ) ;
18
-
19
17
/// The Regex for the syntax for blockquotes that have a specific CSS class,
20
18
/// like `> [!WARNING]`.
21
19
static ADMONITION_RE : Lazy < Regex > = Lazy :: new ( || {
@@ -57,41 +55,6 @@ impl Spec {
57
55
}
58
56
}
59
57
60
- /// Converts lines that start with `r[…]` into a "rule" which has special
61
- /// styling and can be linked to.
62
- fn rule_definitions (
63
- & self ,
64
- chapter : & Chapter ,
65
- found_rules : & mut BTreeMap < String , ( PathBuf , PathBuf ) > ,
66
- ) -> String {
67
- let source_path = chapter. source_path . clone ( ) . unwrap_or_default ( ) ;
68
- let path = chapter. path . clone ( ) . unwrap_or_default ( ) ;
69
- RULE_RE
70
- . replace_all ( & chapter. content , |caps : & Captures < ' _ > | {
71
- let rule_id = & caps[ 1 ] ;
72
- if let Some ( ( old, _) ) =
73
- found_rules. insert ( rule_id. to_string ( ) , ( source_path. clone ( ) , path. clone ( ) ) )
74
- {
75
- let message = format ! (
76
- "rule `{rule_id}` defined multiple times\n \
77
- First location: {old:?}\n \
78
- Second location: {source_path:?}"
79
- ) ;
80
- if self . deny_warnings {
81
- panic ! ( "error: {message}" ) ;
82
- } else {
83
- eprintln ! ( "warning: {message}" ) ;
84
- }
85
- }
86
- format ! (
87
- "<div class=\" rule\" id=\" r-{rule_id}\" >\
88
- <a class=\" rule-link\" href=\" #r-{rule_id}\" >[{rule_id}]</a>\
89
- </div>\n "
90
- )
91
- } )
92
- . to_string ( )
93
- }
94
-
95
58
/// Generates link references to all rules on all pages, so you can easily
96
59
/// refer to rules anywhere in the book.
97
60
fn auto_link_references (
0 commit comments