1.1.0: fix Live Preview crash, add Reading View inline support, birthday labels
- Fix RangeSetBuilder ordering crash: inline and fenced-block decorations
are now merged and sorted before being added, instead of two unsorted
passes (crashed whenever a fenced block preceded inline code in a note).
- Add explicit @codemirror/state and @codemirror/view devDependencies
(previously only transitive via @codemirror/language).
- Add Reading View support for inline `date-calc:` spans via
registerMarkdownPostProcessor (previously Live Preview only), mirroring
the approach used by Dataview's inline queries.
- Fix verbose=false being silently truthy (non-empty string) in inline
key=value config, which meant it never actually disabled verbose output.
- Fix diff type auto-inference: from/to was dead code (countdown's check
always matched first); reordered so from+to or start+end infer diff.
- Implement documented but missing birthday label support: cfg.label,
falling back to frontmatter name ("Jane's age:"), then "Age:".
- Split main.ts (777 lines) into src/ modules per AGENTS.md conventions.
- Fix duplicated command-palette prefixes, move inline JS styles to
styles.css, fix package.json author, drop orphaned showArrow setting.
Verified: unit tests against the real bundled logic (mocked obsidian
module), a reproduction of the RangeSetBuilder crash against the real
@codemirror/state package, and live end-to-end testing in Obsidian via
CDP/Playwright (Tchernobyl vault).
This commit is contained in:
@@ -4,7 +4,6 @@ An Obsidian plugin that adds dynamic date calculations to your notes using `date
|
||||
|
||||
|
||||
## Todo
|
||||
- [ ] Make everything work not only in Live Preview, but Reading also.
|
||||
- [ ] Add custom language (default to Obsidian language, overridable)
|
||||
|
||||
|
||||
@@ -24,20 +23,20 @@ birthday: 1992-08-16
|
||||
|
||||
Use inline code for quick calculations: `date-calc: birthday=1992-08-16`
|
||||
|
||||
**Note about Live Preview**: Inline code works in both Reading view and Live Preview mode. In Live Preview, the result appears after the inline code (e.g., `date-calc: birthday=1992-08-16` → Age: 32 years old...). However, inline code does **not** work for live-preview in Source mode - you'll see the literal code until you switch to Reading view or Live Preview mode.
|
||||
**Rendering modes**: Inline code and fenced blocks both render in Reading view and Live Preview mode. In Source mode, you'll see the literal `date-calc:` code until you switch to Reading view or Live Preview.
|
||||
|
||||
## Supported Calculation Types
|
||||
|
||||
### Birthday (`birthday`)
|
||||
|
||||
Calculates age and time until next birthday with enhanced personalization features.
|
||||
Calculates age and time until next birthday, with an optional custom label and automatic personalization from your note's frontmatter.
|
||||
|
||||
**Fields:**
|
||||
|
||||
- `birthday` (or `birthdate`, `date`): Birth date in YYYY-MM-DD format
|
||||
- `label` (optional): Custom label (defaults to "Age:")
|
||||
|
||||
**Frontmatter Support:** If not provided in the code block, the plugin will look for `birthday`/`birthdate`, and `name` properties in the note's frontmatter.
|
||||
**Frontmatter Support:** If not provided in the code block, the plugin reads `birthday`/`birthdate` from the note's frontmatter. If no `label` is set, a frontmatter `name` property becomes the default label automatically (e.g. `name: John` → "John's age:").
|
||||
|
||||
**Examples:**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user