Add a built-in variable $month_from_text that detects month names in the document text and resolves to a 2-digit month number. Supports English and German month names.
| Detected Text |
Resolves To |
| January / Januar |
01 |
| February / Februar |
02 |
| March / März |
03 |
| April |
04 |
| May / Mai |
05 |
| June / Juni |
06 |
| July / Juli |
07 |
| August |
08 |
| September |
09 |
| October / Oktober |
10 |
| November |
11 |
| December / Dezember |
12 |
If no month name is found, resolves to empty string (or a configurable default).
Example Usage
output:
filename: "Test_AG_$y_$month_from_text"
Implementation
- File:
crates/paporg/src/config/variables.rs
- Add a new function
detect_month_from_text(text: &str) -> Option<String> that scans for month names (case-insensitive)
- Return the first match found (scanning left-to-right)
- Add to builtin variables in
get_builtin_variables() — requires access to the document text, so the function signature may need to accept text as parameter
- If no month detected, insert empty string or omit the variable (letting the default mechanism handle it)
Acceptance Criteria
Add a built-in variable
$month_from_textthat detects month names in the document text and resolves to a 2-digit month number. Supports English and German month names.If no month name is found, resolves to empty string (or a configurable default).
Example Usage
Implementation
crates/paporg/src/config/variables.rsdetect_month_from_text(text: &str) -> Option<String>that scans for month names (case-insensitive)get_builtin_variables()— requires access to the document text, so the function signature may need to accept text as parameterAcceptance Criteria