Attaching Evidence and Comments to Text

Attaching Evidence and Comments to Text

user avatar

by me1afon

18 minutes ago


AI tools helped gather research and write the first draft of this article. I edited it and checked every quote and figure against the source page listed at the end, read on 27 November 2026. The cover illustration is AI-generated. Details at the end.

An editor leaves a note on a sentence: "Where does this number come from?" Then the writer rewrites the paragraph above it. The note should still sit on the right sentence. If it sits on the wrong one, or vanishes, the review has quietly lost information. Anchor a comment or a source to the text it is about, not to a position in the file, and decide in advance what happens when that text changes. Three things do the work: a way to describe the target, a way to find it again after edits, and a rule for the cases where it cannot be found.

It draws on the W3C annotation standard, one annotation project's published design and the position-tracking tools of two editor libraries, and shows a record in a fictional newsroom. It does not test or recommend any product.

Two kinds of attachment

Editors attach two different things to a fragment of text, and they behave differently.

A comment is a conversation: a question, a request, a reply, a resolution. Its life is "open until someone closes it".

A piece of evidence is a claim about support: this sentence rests on that page, read on that date, and this is the passage that supports it. Its life is "valid until the sentence or the source changes".

The W3C Web Annotation Data Model, a W3C Recommendation of 23 February 2017, covers both with one structure. An annotation connects a body (what you say) to a target (what you say it about) [1]. It also records why, through a "motivation". The specification's list includes "commenting", "questioning", "replying", "editing" and "linking", and describes linking as the case where "the user intends to link to a resource related to the Target" [1]. A small publication need not adopt the whole standard to borrow the idea: keep one record shape and put the purpose in a field.

Describing the target: the selector

The interesting part of the model is how it points at text. Pointing is done with a "selector". Two selectors matter for an article editor.

Position. The Text Position Selector records a start and an end in the stream of characters: "Position 0 would be immediately before the first character" [1]. It needs no copy of the text. The specification also warns that it "is very brittle with regards to changes to the resource. Any edits or dynamically transcluded content may change the selection" [1]. One inserted paragraph above the target makes every stored number wrong.

Quote. The Text Quote Selector stores the selected text itself, plus a little text on either side. The specification describes it as copying a range of text "and including some of the text immediately before (a prefix) and after (a suffix) it to distinguish between multiple copies of the same sequence of characters" [1]. Its own example selects the misspelling "anotation" with the prefix "this is an " and the suffix " that has some" [1]. If the quote matches more than one place, the specification says that "the selection SHOULD be treated as matching all of the matches" [1]. A short common phrase such as "the token" can match many places; an ambiguous record should stay ambiguous, not silently resolve to the first hit.

The model says the text must be normalised before it is recorded: "HTML/XML tags SHOULD be removed, and character entities SHOULD be replaced with the character that they encode" [1]. For an editor this means the anchor should describe the words, not the markup around them, so that making a phrase bold does not break its comment.

Finding it again after edits

The text will change. Two published approaches show the range.

Re-attach by searching

The Hypothesis annotation project described its approach in a post dated 22 April 2013. That is old and concerns web pages, not a draft in an editor, so treat it as a design to learn from. The post says the aim was an approach to anchoring "that is robust to changes in the underlying document" [2]. Hypothesis saved the target in three selectors, among them a position selector and a quote selector whose prefix and suffix were 32 characters long [2]. To re-attach, it tried four strategies in order [2]:

  1. Apply the stored structural range directly, and check that the text it yields equals the saved quote.
  2. Use the stored character offsets, which survives a change of structure but not of content, again checking the text.
  3. "Context-first Fuzzy Matching": search near the expected position for the prefix, then for the suffix, then compare the text between them to the saved text, accepting it if "the difference is within a given acceptance threshold" [2].
  4. A last-resort fuzzy search for the saved text alone [2].

The lesson is the order. The cheap exact methods run first, and each one is verified against the saved quote before it is trusted. The fuzzy methods run last and carry a threshold.

Track the position through the edit

An editor, unlike a web page, sees every change as it happens. That allows a second approach: move the anchor along with each edit instead of searching afterwards. ProseMirror, an editor toolkit, documents this. Its guide says that when you change a document, "positions pointing into that document may become invalid or change meaning", and that steps can give you a map that converts positions before and after the change [3]. Positions can be mapped through a series of steps in one go, and the guide describes a choice of bias: when content is inserted exactly at your position, you decide whether the position stays in front of it or moves after it [3]. For comments this is the edge case of typing at the start or end of the commented phrase.

The ProseMirror reference describes a decoration set (the objects used to draw highlights) that can be mapped through a change, with an option to be told about "each decoration that gets dropped as a result of the mapping" [4]. That last detail matters here. Mapping is allowed to lose an anchor: if the whole target is deleted, there is nothing to map to, and the library will tell you. Whether the comment then disappears or becomes an orphan on a list is your decision.

Collaborative editors have the same problem across several authors at once. The documentation of Yjs, a library for shared documents, says that plain integer positions "are not convenient to use because the index-range is invalidated as soon as a remote change manipulates the document", and names "assign a comment to a range of text" as one use of its relative positions [5]. A relative position is attached to an element of the document rather than to a number, and the conversion back returns null when the position cannot be referenced [5]. The shape is the same: anchor to something that moves with the text, and have an answer for "gone".

The two approaches combine: track the anchor live through each edit, and also store the quote with prefix and suffix, so that after an import, a restore or a database round trip it can still be found by searching.

A fictional example

The following is invented. Example Ledger is a made-up publication; the draft, the audit and the record are fictional and show the format.

Ana, a writer at Example Ledger, is drafting a piece about an AI trading assistant. The sentence reads: "The independent audit found three critical issues in the vault contract." Her editor Ben wants the audit report attached as evidence. The record might look like this. Its layout is the author's proposal in the spirit of the W3C model, not a format the standard defines:

motivation: linking

target:

quote.exact: "found three critical issues in the vault contract"

quote.prefix: "The independent audit "

quote.suffix: "."

position: start 1204, end 1254 (a hint only)

body:

source: https://example.test/audit-report-v2 (fictional)

read_on: 2026-11-24

supports: "Findings: 3 critical, 5 medium" (fictional passage)

status: verified by Ben, 2026-11-24

Now three edits happen.

  1. Ana adds a paragraph above. The stored position is now wrong, and a position-only anchor would point at the wrong words. The quote matches exactly, so it is found, and the position is refreshed.
  2. Ana rewords to "found three critical issues in the vault code". The exact quote no longer matches. The prefix and the start of the quote still match, so a fuzzy search finds a very close candidate. A fuzzy match proves only that the text is similar, not that the new sentence is still supported by "Findings: 3 critical, 5 medium". The sensible rule is to re-attach the record but change its status to "needs recheck", and show the editor the old and new wording.
  3. Ana deletes the sentence. There is nothing to find. The record becomes an orphan: kept, listed in a "detached" panel with its old quote, never deleted silently.

A fictional anchored record for Example Ledger: a sentence with a highlighted phrase, the record beside it (motivation, quote with prefix and suffix, position as a hint, source, read date, status), and three outcomes after edits: found exactly with status kept, found only approximately and marked needs recheck, deleted and detached with its old quote kept. Diagram built in code.

Four mistakes and fixes

1. Anchoring to a character offset only. One inserted paragraph shifts everything, and the specification itself calls position selection "very brittle" under edits [1]. Fix: store the quote with prefix and suffix, and treat the offset as a hint for where to search first.

2. Anchoring to the markup. A selector tied to a particular tag breaks when the phrase is bolded or a link is added. Fix: describe the normalised text, as the model's quote selector does [1].

3. Trusting a fuzzy match without a status. A reworded sentence can be matched with a high score and still be a different claim. Fix: a fuzzy re-attachment sets the record to "needs recheck", and only a person sets it back to "verified". The threshold is a decision about risk, not a technical default; the Hypothesis post names a threshold without telling you what value suits your text [2].

4. Losing an anchor silently. Mapping and relative positions can both fail to resolve, and the documentation of both libraries says so [4][5]. Fix: show the detached record in a list, with the old quote and the source, until a person resolves or removes it.

Four numbered cards in a row, each showing a mistake and its fix: store the quote with context, anchor the words not the markup, a fuzzy match sets needs recheck, a lost anchor goes to a detached list. Diagram built in code.

Where the anchor and the evidence live

If a comment is stored inside the document, for example as a mark on the text, it moves with every edit but also ends up in whatever the export produces, so you must decide whether it should. If it is stored beside the document as a separate record, it survives an import and can be exported on its own, but it needs the search-based re-attachment described above. The W3C model is the second kind: the annotation is a separate resource that points at the target [1]. The choice follows from your editor and storage format (PART 02 of this series is Choosing a Storage Format for an Article); it decides how much re-attachment work you need.

One vendor example shows that the feature can be a separate product tier. The Tiptap documentation presents its Comments extension as letting "users create threads and comments in the editor", and lists the steps "Activate trial or subscribe", "Start Document server" and "Install from private registry" [6]. I did not test it, and licensing belongs to a later part of this series. The point here is narrower: in this vendor's case, anchored comments come with a document server and a subscription step, so they are a decision, not a toggle.

A template to copy

For each attachment, store:

  • Purpose: comment, question, edit request or source link (one field).
  • Quote: the exact words, about 30 characters of text before and after, and the position as a hint.
  • Body: the comment text, or the source address, the date it was read and the supporting passage.
  • Status: open, resolved, verified, needs recheck, or detached, with who set it and when.
  • Rule: if the quote is found exactly, keep the status; if found only approximately, set "needs recheck"; if not found, mark "detached" and keep the old quote.

The 30-character figure is an illustration, not a standard; Hypothesis used 32 [2], and your text may need more or less.

What this article cannot tell you

It does not test any editor's comment, suggestion or annotation feature, so it says nothing about how well any product keeps an anchor. It gives no fuzzy-match threshold. The Hypothesis post is from 2013 and describes that project's design at the time, not its current code. The record in the example is my proposal, labelled as such, and the W3C Recommendation is a data format, not a guarantee of how any editor behaves. The sources describe designs and documentation, not measured results: none shows that anchored evidence reduces errors by any amount. The Dapp.Expert editors are not covered.

How this article was made

Task What the AI did What a person did How it was checked
Research Gathered candidate sources and drafted notes Chose the question and which pages to rely on Every quote checked against the page named in the sources, read on 27 November 2026
Draft Wrote the first draft from the notes Edited the text, the example and the record design An independent review compares claims with the sources before publication
Images Generated the cover and inline illustrations Chose and checked them Labelled as AI-generated in the disclosure line and alt text
Not done by AI none The decision to publish and responsibility for the text none

Conflicts of interest: none. The author has no commercial relationship with the organisations named here.

Responsible for this article: Dmitriy Lastovka, author. Corrections: contact form.

Sources

Labels: standard (a published specification), design post (a project's own description of its design), documentation (a library's own docs). Quotes are as on the pages read on 27 November 2026.

  1. W3C, Web Annotation Data Model, W3C Recommendation 23 February 2017. https://www.w3.org/TR/annotation-model/ Standard.
  2. Hypothesis, "Fuzzy Anchoring", by csillag, 22 April 2013. https://web.hypothes.is/blog/fuzzy-anchoring/ Design post; 2013, not current code.
  3. ProseMirror Guide, section "Mapping". https://prosemirror.net/docs/guide/ Documentation.
  4. ProseMirror reference manual, DecorationSet. https://prosemirror.net/docs/ref/ Documentation.
  5. Yjs Docs, Y.RelativePosition. https://docs.yjs.dev/api/relative-positions Documentation.
  6. Tiptap Docs, Comments overview. https://tiptap.dev/docs/comments/getting-started/overview Documentation; paid feature, not tested.

Tier I

Sector: #18291

Sealed Hiding Place Room

Resource Cache

Resource Cache

Tier I

Requires 25% Tier Progress to Claim
Meme Cache

Meme Cache

Tier I

Requires 50% Tier Progress to Claim
Equipment Cache

Equipment Cache

Tier I

Requires 75% Tier Progress to Claim

After collecting, hiding places will be stored in your inventory and can be opened with Keys.

Other articles

Editing Tables, Embeds, and Custom Blocks

How to edit price tables, embeds and custom blocks: model each block, separate the editing view from stored output, sandbox embeds, test tables.

user avatarme1afon

Testing an Editor’s Import and Export Round Trip

How to test whether an editor keeps your content through import and export, with a real two-tool test, its results, and a reusable procedure.

user avatarme1afon

Choosing a Storage Format for an Article

HTML, Markdown or a block tree: what each format keeps, what it loses, what the editors' docs say, a fictional test article and a decision checklist.

user avatarme1afon

Choosing an Editor Engine for Editorial Work

How to pick a rich-text editor engine from editorial requirements: five questions, a fictional scorecard, a test document, four mistakes and a template.

user avatarme1afon

Making NLP Assistance Inspectable for Editors

How to give editors useful NLP metadata they can check: evidence, scope, calibrated confidence, overrides and no silent topic filtering.

user avatarme1afon

Sentiment Is Not the Same as Stance

Why a positive or negative score does not tell you where an author stands, with benchmark numbers, a fictional example and a checklist.

user avatarme1afon

Important disclaimer: The information presented on the Dapp.Expert portal is intended solely for informational purposes and does not constitute an investment recommendation or a guide to action in the field of cryptocurrencies. The Dapp.Expert team is not responsible for any potential losses or missed profits associated with the use of materials published on the site. Before making investment decisions in cryptocurrencies, we recommend consulting a qualified financial advisor.