javalent / dice-roller

Inline dice rolling for Obsidian.md
274 stars 28 forks source link

🧩 Refactor lexical parser to accept front matter fields in dice contexts #325

Open Shyclops opened 3 months ago

Shyclops commented 3 months ago

Scope

currently dice role context expects to only see numbers, change the parser so that it can take front matter fields as well

Discovery

Referencing number fields of a different note currently returns Error: Mismatched parenthesis. After the change

Validate

Steps

  1. Make a two notes, one called "Note with metadata" and one called "Note with dice context"
  2. In "Note with metadata" add fields Stat_1 and "Stat 2"
  3. In "Note with dice context" add `dice: 1d20 + ({[[Note with metadata]].Stat_1} + {[[Note with Metadata]]["Stat 2"]})
  4. Verify that dice is rolled and adds the two stats to the roll