nips/84.md

99 lines
4.1 KiB
Markdown
Raw Normal View History

NIP-84
======
Highlights
----------
`draft` `optional` `author:pablof7z`
This NIP defines `kind:9802`, a "highlight" event, to signal content a user finds valuable.
## Format
The `.content` of these events is the highlighted portion of the text.
`.content` might be empty for highlights of non-text based media (e.g. NIP-94 audio/video).
### References
Events SHOULD tag the source of the highlight, whether nostr-native or not.
`a` or `e` tags should be used for nostr events and `r` tags for URLs.
When tagging a URL, clients generating these events SHOULD do a best effort of cleaning the URL from trackers
or obvious non-useful information from the query string.
### Attribution
Clients MAY include one or more `p` tags, tagging the original authors of the material being highlighted; this is particularly
useful when highlighting non-nostr content for which the client might be able to get a nostr pubkey somehow
(e.g. prompting the user or reading a `<meta name="nostr:nprofile1..." />` tag on the document). A role MAY be included as the
last value of the tag.
```json
2023-11-07 12:19:11 +00:00
[ "p", "<pubkey-hex>", "<relay-url>", "author" ],
[ "p", "<pubkey-hex>", "<relay-url>", "author" ],
[ "p", "<pubkey-hex>", "<relay-url>", "editor" ],
```
### Context
Clients MAY include a `context` tag, useful when the highlight is a subset of a paragraph and displaying the
surrounding content might be beneficial to give context to the higlight.
### Ranges
Clients MAY include `range` tags with the start/end indexes of where the highlight begins and finishes within
the referenced article/tagged-event.
```
[ "range", <start-index>, <end-index> ]
```
Additionally a range with `context` as the third value of the tag MAY be added to indicate the begin/finish indexes
of the highlight within the included `context` tag.
```
[ "range", <start-index>, <end-index>, "context" ]
```
#### Text-based nostr events' highlights
Highlights of Nostr events SHOULD use the range index of the content as-is
(e.g. NIP-23 articles include the markdown instead of computing the index from the rendered markdown).
```
[ "range", 3000, 3042 ] # highlight begins at index position 3000 of the tagged event's `.content`
[ "range", 42, 84, "context" ] # highlight begins at index position 42 of the `context` tag's value
```
#### Non-text-based nostr events' highlights
A `kind:9802` event that tags a NIP-94 event which includes a video or audio file can use ranges to
indicate the start/end time position in seconds.
#### Ranges in URL highlights
When creating a highlight from a URL the range should be expressed over
the extracted plain text of the formatted content (e.g. rendered HTML instead of including the HTML markup);
this helps make finding the correct indexes easier on websites with markup variations on each render.
e.g. `<html><body>hello, world</body></html>`
Tagging `hello, world` would result in using a range tag like `["range", 0, 12 ]`.
Text extraction (i.e. translation from non-plain text medium like HTML or PDF) is highly subjective and the value
of the range should be carefully interpreted by the different clients that support this.
```json
{
"created_at": 1682707885,
"content": "while allowing creators to simply keep doing what theyre doing. Creators dont need to be blatant shills for brands",
"tags": [
[ "r", "https://footstr.com/zapvertise/" ],
[ "p", "c48e29f04b482cc01ca1f9ef8c86ef8318c059e0e9353235162f080f26e14c11", "wss://relay.url", "author" ],
[ "context", "The Nostr zapvertising model creates a truly free market for advertisers, while allowing creators to simply keep doing what theyre doing. Creators dont need to be blatant shills for brands, they just have to create high quality content people find valuable, and companies will naturally want to zapvertise on their posts." ]
[ "range", 3916, 4032 ],
[ "range", 74, 190, "context" ],
],
"kind": 9802,
"pubkey": "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52",
"id": "59e5887a3cdf32d5f11edf9b8cd098c620d278514b2edde3e6d1ba8a541d262c",
"sig": "f2d15b8bc2csf6d198350f8df0a31dcf66d7c32ec9c54e6b3f102d579370b7de9d164d70350a5b32a2911db3b124e972bafa9a1bc8fd60c1e338903d2f6306b0"
}
```