Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
'',
'Hover over numeric citations such as [1-10] or [3,1-10,12] to view the corresponding references together in Obsidian Page preview. Citation groups are assembled in memory from the numbered bibliography in the same note.',
'',
'A consistent citation and bibliography format is required. References must be explicitly numbered, unique, and listed under a supported bibliography heading in the same note. See README.md for the exact format and linked-citation examples.',
'Reference blocks are identified by unique ^ref-N and ^sref-N block IDs in the same note. No particular bibliography heading is required. Use explicit links to distinguish main and supplementary references with the same number. See README.md for the exact format and linked-citation examples.',
'',
'## Changes',
'',
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.2.0

- Identify references directly from their `^ref-N` and `^sref-N` block IDs, without requiring a bibliography heading. References work under arbitrary headings or with no heading, including notes whose headings contain section numbers or entry counts.
- Also support compact IDs such as `^ref1` and named sets such as `^ref-appendix-1`. Unanchored numbered lists no longer create reference entries; existing plain citations need identifiable reference blocks.
- Keep independent indexes for main and supplementary anchor prefixes, even when entries appear in different parts of a note. Resolve linked citations by their actual targets and expand ranges only within the selected reference set.
- Separate previews and refreshes for groups with identical visible numbers but different reference targets. Check the exact rendered link targets so figure or equation links cannot consume a citation's preview.
- Use the same local-link validation in Reading view and the editor, including relative and encoded note paths.
- Preserve compact and spaced reference lists and multiline reference blocks. Retain ambiguity reporting when a plain numeric citation does not identify a unique reference set.
- Add regression coverage and a copyable main/supplementary demonstration. Keep the plugin ID `citation-range-preview` and minimum Obsidian version `1.15.1`.

## 1.1.1

- Make the native Page preview implementation available as an update for the existing Obsidian Community listing. The plugin keeps its existing ID, settings, and same-note bibliography format.
Expand Down
51 changes: 42 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Citation Preview

Preview numeric citations in Obsidian using the bibliography already in the same Markdown note. Hover over a citation such as `[1, 3, 5]` or `[1–10]` to see the corresponding references together in a Page preview popover.
Preview numeric citations in Obsidian using the reference blocks already in the same Markdown note. Hover over a citation such as `[1, 3, 5]` or `[1–10]` to see the corresponding references together in a Page preview popover. Reference block IDs identify the entries; no particular bibliography heading is required.

## Why Citation Preview?

Expand All @@ -22,8 +22,6 @@ Citation Preview was built for that workflow. It assembles the cited entries in

Linked range endpoints can preview the entries in between \[[1](#^ref-1)–[3](#^ref-3)\].

## References

[1] Example reference one. ^ref-1

[2] Example reference two. ^ref-2
Expand All @@ -35,15 +33,50 @@ Citation Preview was built for that workflow. It assembles the cited entries in

See the [demonstration note](examples/Citation-demo.md) for more examples.

## Citation and bibliography format
## Citation and reference block format

- Put each citation on one line of normal prose. Use positive integers in square brackets, commas for separate numbers, and a hyphen or en dash for an ascending range.
- Put the bibliography under a supported heading such as `## References` or `## Bibliography` in the same note. Start each entry with its explicit number, such as `[1]`, `[2]`, `[3]`, and separate entries with a blank line. Explicitly numbered Markdown list entries such as `1.`, `2.`, `3.` also work. A list using `1.` for every item contains duplicate reference numbers in the source, even if it renders as a sequential list.
- For linked citations, give each target entry a unique block ID and link the matching number to it. Markdown links such as `\[[1](#^ref-1), [3](#^ref-3)\]` and Wikilinks such as `\[[[#^ref-1|1]], [[#^ref-3|3]]\]` keep the visible outer brackets and link the numbers to their own entries. Plain citations do not require block IDs.
- Identify main reference blocks with `^ref-1`, `^ref-2`, and so on; use `^sref-1`, `^sref-2`, and so on for supplementary references. The numeric suffix identifies the reference number, and the prefix distinguishes the two sets. Each block ID must be unique throughout the note.
- Reference blocks can appear under any heading or with no heading at all. Both compact lists and lists separated by blank lines work, including multiline entries. Entries with the same prefix belong to the same reference set even when they appear in different parts of the note.
- Link each stated number to its own block. Markdown links such as `\[[1](#^ref-1), [3](#^ref-3)\]` and Wikilinks such as `\[[[#^ref-1|1]], [[#^ref-3|3]]\]` keep the visible outer brackets. Angle-bracket destinations such as `[1](<#^ref-1>)` also work.
- Plain citations such as `[1–3]` can preview entries when the existing reference block IDs identify a unique set. When main and supplementary references reuse those numbers, use explicit links to select the intended set.

The compact forms `^ref1` and `^sref1` are also supported. For additional independent sets, use a named prefix such as `^ref-appendix-1` or `^sref-a-1`, with the reference number after the final hyphen. Link to the exact ID used in the note. A visible list number is optional; the block ID supplies the reference number.

**Upgrading from 1.1.x:** each reference now needs a supported block ID. A heading and an unanchored numbered list alone no longer establish a reference index. Plain in-text citations remain supported when their reference blocks are identifiable as described above.

Version 1.2.0 uses the actual anchors as its source of reference identity:

| Reference block | Citation target | Meaning |
| --- | --- | --- |
| `^ref-1` | `#^ref-1` | Main reference 1 |
| `^sref-1` | `#^sref-1` | Supplementary reference 1 |

### Main and supplementary references in one note

Main reference 1 and supplementary reference 1 coexist because `#^ref-1` and `#^sref-1` identify different blocks. A linked range expands only within the reference set selected by its endpoints: `ref-1` to `ref-3` selects `ref-1`, `ref-2`, and `ref-3`; the corresponding `sref` range selects the three supplementary entries. Previews with identical visible numbers keep their contents separate.

```markdown
Main result: \[[1](<#^ref-1>)–[3](<#^ref-3>)\].

1. Main reference one. ^ref-1
2. Main reference two. ^ref-2
3. Main reference three. ^ref-3

## Supplementary notes
Supplementary result: \[[1](<#^sref-1>)–[3](<#^sref-3>)\].

### Sources
1. Supplementary reference one. ^sref-1
2. Supplementary reference two. ^sref-2
3. Supplementary reference three. ^sref-3
```

The main references in this example have no heading, and the supplementary references use the arbitrary heading `Sources`. Changing either heading, including its language or entry count, does not change how the anchors resolve. A group whose explicit links mix `ref` and `sref` targets is left to normal link behavior; split it into one group for each set.

## Preview behavior

A group opens one native Page preview popover with an ordered list of references. Ranges expand in place, and repeated numbers appear only at their first occurrence. For example, `[3,1-10,12]` shows `3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 12` in that order. Recognized groups flag missing entries and duplicate numbers in the bibliography.
A group opens one native Page preview popover with an ordered list of references. Ranges expand in place, and repeated numbers appear only at their first occurrence. For example, `[3,1-10,12]` shows `3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 12` in that order. Recognized groups flag missing entries and ambiguous reference numbers. The same number in the main and supplementary sets is valid when the citation identifies its target set.

A single linked citation uses Obsidian's normal direct Page preview. A single unlinked citation can also preview its matching entry when plain numeric recognition is on. Body links keep their normal Obsidian click behavior, and the preview adds no jump buttons.

Expand All @@ -57,8 +90,8 @@ A single linked citation uses Obsidian's normal direct Page preview. A single un
## Dependencies and limits

- **Obsidian's built-in Page preview must be enabled.** Citation Preview uses Obsidian's private embed registry and renderer to display groups. Changes to those internals can affect compatibility across app versions. The minimum supported version is **Obsidian 1.15.1**, tested on desktop.
- The plugin uses numeric Markdown citations and explicitly numbered references in the current note. Author–date citations, general CSL processing, and resolving references from external sources are outside its scope. Citation lookup needs only Obsidian and the current note.
- Plain numeric recognition is heuristic. A bracketed interval can look like a citation when the note has matching numbered references. Check the heading, explicit numbering, and block targets if a preview is missing.
- The plugin uses numeric Markdown citations and reference block IDs in the current note. Author–date citations, general CSL processing, and resolving references from external sources are outside its scope. Citation lookup needs only Obsidian and the current note.
- Plain numeric recognition is heuristic. A bracketed interval can look like a citation when the note has matching reference blocks. Check the actual `^ref-N` or `^sref-N` block IDs and citation targets if a preview is missing. Headings do not determine whether a block is a reference.
- The preview is designed for desktop mouse hover. There is no dedicated touch gesture.

## Install or update
Expand Down
6 changes: 6 additions & 0 deletions docs/RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Install the locked dependencies with Node.js 24 and run `npm run check`.
- Run `npm run package` and confirm the installation ZIP contains `main.js`, `manifest.json`, and `styles.css` under `citation-range-preview/`.
- Check that the manifest, package metadata, compatibility map, and release tag agree.
- Verify the regression cases for reference blocks with arbitrary or absent headings, compact reference lists, and independent `ref`/`sref` numbering.

## Verify in Obsidian

Expand All @@ -16,6 +17,11 @@ Enable the core Page preview plugin and open the [demonstration note](../example
- Check that missing and duplicate reference numbers receive distinct messages.
- Verify close behavior, typography, and list spacing in Reading view and confirm group previews work in the editor using its Page preview modifier.
- Check that editing bibliography text refreshes the next preview without creating helper files.
- Copy the main/supplementary example into a separate note. Hover both linked `[1–3]` groups in either order and confirm that each displays only its own reference set.
- Rename or remove the reference headings and move one entry elsewhere in the note. The same reference IDs and ranges must continue to resolve.
- Edit a title in each bibliography, save the note, and confirm that both existing citation groups refresh without exchanging contents.
- Check that an ambiguous plain `[1–3]` does not silently select either reference set, and that duplicate block IDs never silently resolve to an arbitrary entry.
- Check same-note relative and encoded link destinations in Reading view and the editor. Numeric figure/equation links must retain their ordinary behavior.

## Publish

Expand Down
33 changes: 29 additions & 4 deletions examples/Citation-demo.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Citation Preview demonstration

> All ten references in this note are fictional test fixtures. Their authors, titles, journal, years, and pagination are invented for demonstration. Do not cite them as research or add them to a real bibliography.
> All reference examples in this note are fictional test fixtures. Their authors, titles, journal, years, and pagination are invented for demonstration. Do not cite them as research or add them to a real bibliography.

Copy this note into an Obsidian vault with Citation Preview and the Page preview core plugin enabled. Start in Reading view and hover over a citation to see its references. In an editor, follow Obsidian's modifier-key setting for Page preview.

All examples use the same References section at the end of this note. Each entry starts with its unique number and ends with its matching block ID.
The live examples use the `^ref-1` through `^ref-10` blocks near the end of this note. Their heading is arbitrary; the block IDs identify the entries. The separate main/supplementary example below is a code block to copy into another note.

## Plain citations

Expand Down Expand Up @@ -46,17 +46,42 @@ A Wikilink range: \[[[#^ref-1|1]]-[[#^ref-10|10]]\].

A mixed Wikilink group: \[[[#^ref-1|1]]-[[#^ref-3|3]], [[#^ref-5|5]], [[#^ref-8|8]]-[[#^ref-10|10]]\].

## Main and supplementary bibliographies

Copy the following block into a **separate note** as ordinary Markdown. Its six references are fictional placeholders. It uses compact lists and independent `ref`/`sref` numbering, as supported in 1.2.0. The main entries have no bibliography heading; the supplementary entries use an arbitrary heading.

```markdown
## Main text

Main evidence: \[[1](<#^ref-1>)–[3](<#^ref-3>)\].

1. Fictional main reference one. ^ref-1
2. Fictional main reference two. ^ref-2
3. Fictional main reference three. ^ref-3

## Supplementary notes

Supplementary evidence: \[[1](<#^sref-1>)–[3](<#^sref-3>)\].

### Sources
1. Fictional supplementary reference one. ^sref-1
2. Fictional supplementary reference two. ^sref-2
3. Fictional supplementary reference three. ^sref-3
```

Hover the two linked groups in either order. Although both display `[1–3]`, the first should show only the main references and the second only the supplementary references. Edit and save a title in each set, then hover again to confirm that the updated contents remain separate. Rename or remove `Sources`; the same links must continue to work. A plain `[1–3]` in this copied note is ambiguous: use the explicit links to select the intended reference set.

## Additional checks

- Hover over the beginning, separator, and end of a range; each should open the same complete group.
- Confirm a single linked citation uses the standard block preview.
- Copy this note before testing duplicate numbering. Add a second entry numbered 4 to the copied bibliography and confirm that its preview reports the ambiguity.
- Copy this note before testing duplicate IDs. Add a second block with `^ref-4` and confirm that the plugin does not silently choose either duplicate.
- Change a fictional title in the bibliography, then hover over its citation again to check that the preview updates.
- Open another note with a different reference 1 and confirm that each note resolves its own bibliography.
- Try reading view, Live Preview, and source mode separately. Editor previews are enabled by default.
- Turn off **Recognize plain numeric citations** and confirm that the explicit linked forms still work. Turn it back on for the plain examples.

## References
## Sources for these examples

[1] Example Author One. (2091). Fictional demonstration of a coastal signal. Journal of Fictional Preview Fixtures, 1, 1–2. **Fictional test reference.** ^ref-1

Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "citation-range-preview",
"name": "Citation Preview",
"version": "1.1.1",
"version": "1.2.0",
"minAppVersion": "1.15.1",
"description": "Preview numeric citation groups in Page preview using the numbered bibliography in the same note.",
"description": "Preview numeric citation groups in Page preview using reference block anchors in the same note.",
"author": "Chuangwu Deng",
"authorUrl": "https://github.com/lyingTree",
"isDesktopOnly": false
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "citation-preview",
"version": "1.1.1",
"description": "Preview numeric citation groups in Page preview using the numbered bibliography in the same note.",
"version": "1.2.0",
"description": "Preview numeric citation groups in Page preview using reference block anchors in the same note.",
"main": "main.js",
"private": true,
"scripts": {
Expand Down
Loading
Loading