feat(markup): prefer [key](collection) for map and list access

Add GFM link-shaped index as the primary get surface, keep footnote
index as transitional compatibility, and align the coffee example.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-14 10:44:18 +08:00
1 parent 5e74ff39f2
commit 4a1c9c48a2
12 files changed
+235 -23

No files matched your search

+6 -5
View File
@@ -145,10 +145,11 @@ pub enum Expr {
List(Vec<Expr>),
/// Object literal / horizontal table (`map` value).
Map(Vec<(String, Expr)>),
/// Footnote index: `` `xs`[^1] `` / `` `m`[^key] `` / `` `m`[^`var`] `` (dynamic key).
/// Collection index: `` [拿铁](菜单) `` / `` [`名`](菜单) `` (preferred), or
/// legacy footnote `` `菜单`[^拿铁] `` / `` `菜单`[^`名`] ``.
Index {
base: Box<Expr>,
/// Label inside `[^…]` (digits → 1-based list index, or map key; see [`IndexKey`]).
/// Key or 1-based list index; see [`IndexKey`].
label: IndexKey,
},
/// Parsed `$$…$$` formula tree (from assignment RHS).
@@ -166,12 +167,12 @@ pub enum InterpPart {
Index { base: String, labels: Vec<String> },
}
/// Footnote / map key after `[^…]`.
/// Map / list index key (`[key](coll)` or legacy `[^…]`).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum IndexKey {
/// Static text: `[^拿铁]` / `[^1]`.
/// Static text: `[拿铁](…)` / `[^拿铁]` / `[^1]`.
Lit(String),
/// Dynamic: `` [^`品名`] `` — evaluate variable, then stringify as key.
/// Dynamic: `` [`品名`](…) `` / `` [^`品名`] `` — evaluate variable, then stringify as key.
Var(String),
}