You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(link-notes): add tooltip mode via link_snippet templates
Add a `link_snippet` option that switches a rule into "tooltip mode":
each matching link is replaced inline with the snippet rendered as a
template (${url}/${text}/${domain} substituted, HTML-escaped), producing
a pretty hover popup instead of a footnote. The rule's disclosure box is
emitted once per page rather than as per-link footnotes.
Because the replacement is inline HTML (not a footnote reference), tooltip
mode also works inside pipe-table cells, so links generated from CSVs by
the table-reader get the same popup. A referenced-but-missing link_snippet
fails the build, matching note_snippet behavior. Footnote mode is unchanged
and remains the default for rules without a link_snippet.
Adds 4 tests (345 total pass) and documents the new mode + placeholders.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Affiliate Link</span><spanclass="tooltip-content">This is an eBay affiliate link…</span></span></span>
134
+
```
135
+
136
+
Because the replacement is inline HTML (not a footnote), tooltip mode also works **inside pipe-table
137
+
cells** — where footnote references can't go — so links generated from CSVs by the
138
+
[table-reader](table-reader.md) get the same pretty popup. A referenced-but-missing `link_snippet`
139
+
**fails the build**, exactly like `note_snippet`.
140
+
141
+
!!! tip "Style it once"
142
+
Put the tooltip CSS (`.affiliate-wrapper` / `.affiliate-tooltip` etc.) in your `extra_css` and
143
+
reuse the same classes across every affiliate snippet so all popups look consistent.
144
+
92
145
## How it works
93
146
94
147
The plugin runs as a Markdown preprocessor (order `30`, after
@@ -173,14 +226,15 @@ Each **rule** object:
173
226
|`name`| string | yes | Rule id; used to build the footnote label (`linknote-<name>`). |
174
227
|`note`| string | yes*| Markdown shown as the tooltip and footer note. Legacy alias: `disclosure`. |
175
228
|`note_snippet`| string | yes*| Path to a Markdown snippet whose content is used as the note (resolved against the project root / `docs` dir and their `snippets` subdirs). A single-admonition snippet contributes its title (→ `label`) and kind, and its body becomes the note. A referenced-but-missing snippet **fails the build**. Legacy alias: `disclosure_snippet`. |
229
+
|`link_snippet`| string | no | Path to an HTML/Markdown snippet template. When set the rule switches to **tooltip mode**: each matching link is replaced inline with this snippet rendered with `${url}`/`${text}`/`${domain}` substituted, and the `note`/`note_snippet` box is emitted once per page (no footnotes). A referenced-but-missing snippet **fails the build**. |
176
230
|`domains`| array | no† | Hosts that identify the link. Each entry is a domain string or `{ "domain": "...", "query_contains": "..." }`. Subdomains match automatically. |
177
231
|`patterns`| array | no† | Regular expressions matched (case-insensitively) against the full URL. |
178
232
|`query_contains`| string | no | Default substring a matching URL must contain (per-domain values override this). |
179
233
|`label`| string | no | Title for the standalone fallback admonition (table-only links). Defaults to the snippet's admonition title, else `Links`. |
180
234
181
-
\* A rule must provide the note text via either `note` or `note_snippet`. If `note_snippet`
182
-
is set it takes precedence; a referenced snippet that cannot be found fails the build rather
183
-
than falling back, so a mistyped path is caught instead of silently dropping the note.
235
+
\* A rule must provide either a note (`note` or `note_snippet`) or a `link_snippet`. If `note_snippet`
236
+
is set it takes precedence over `note`; any referenced snippet that cannot be found fails the build
237
+
rather than falling back, so a mistyped path is caught instead of silently dropping the note.
184
238
185
239
† A rule must provide at least one of `domains` or `patterns`.
0 commit comments