From 6e7ab3e5e44a39a451a42438092c595250baa21c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 30 Mar 2025 06:32:53 -0700 Subject: [PATCH 1/2] Add the ability for rules to be specified in link definitions This adds the ability to link to rules from a link definition. For example: ```markdown See [this rule]. [this rule]: expr.array ``` This will convert `[this rule]` to point to the link of the file for that rule. This is somewhat hacky, as parsing markdown with regex is unwise (and this is intentionally incomplete), and could maybe be done more efficiently. --- mdbook-spec/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/mdbook-spec/src/lib.rs b/mdbook-spec/src/lib.rs index 9eac0e4ed..7b06704f4 100644 --- a/mdbook-spec/src/lib.rs +++ b/mdbook-spec/src/lib.rs @@ -24,6 +24,10 @@ static ADMONITION_RE: Lazy = Lazy::new(|| { Regex::new(r"(?m)^ *> \[!(?[^]]+)\]\n(?
(?: *>.*\n)+)").unwrap() }); +/// A primitive regex to find link reference definitions. +static MD_LINK_REFERENCE_DEFINITION: Lazy = + Lazy::new(|| Regex::new(r"(?m)^\[(?