Exploring the Dynannotate plugin (to build a search-replace-tool)

In a recent thread I discovered the Dynannotate plugin which allows annotations on textual content to be created and displayed. It really fascinates me because it enhances the capabilities of TW.

  • Dynannotate can be used to enhance search by showing the highlighted appearance of the search string embedded into a context snippet. Could it be possible to use the snippets as a button to build a better search-replace tool? I would like to build a modal which allows me to choose which appearances shall be replaced. Therefore the snippets would have to be able to trigger a search-replace action.
  • The plugin allows to highlight text in different colors - is it possible to add a comment-text that appears on hover or click as a pop-up?
  • Could it be possible to have a version which does not contain all the examples and a link to a demo-wiki instead? This would cut the plugin-weight by half.

Best wishes Jan


After some research I have some answers.

Yes! There is an actions param in the widget.
My question is to find an elegant way to reduce prefix and suffix in case of a double appearance of the string to replace for a regex-term

Yes! The viewTemplate is just an example, after some modifications it will be possible, I will publish my version here.
I ask myself if I can make it display annotations based on tags given to the annotation-tiddlers.

The challenge is that the dynannotate highlighting works on the rendered text of a tiddler, while (presumably) such a search-replace tool would work on the raw text of a tiddler.

Applying a highlight to the raw text of a tiddler is actually much easier, and wouldn’t need all the complexity of dynannotate.

The examples provided show how to add a comment popup that triggers on clicking on a highlight.

Generally we value making plugins that are completely self-contained, is there a particular reason that size is important here?

1 Like

thanks for your answers Jeremy, our replies seem to have crossed in the same minute…

@JanJo interesting idea. I will follow your work.

I have some ideas that may help if you get stuck, basically its an intermediate way of interacting with the wiki or a tiddler. If you are familiar application or software deployment it is like a “Run Once” function. basically you generate a string of “commands” like add tag, set field to value, etc… to a custom field. Then use a trigger (later) to cause the change(s) to take place and clear the custom field.

I already have a proof of concept POC for wiki wide, it allows tiddlers dropped from bookmarklets to be actioned against the wiki.

  • This can be extended to specific tiddlers
  • This could be used to generate desired actions in one plugin or solution such as a search and replace request and “drop” it in on a tiddler to action separately.

In some ways this is “meta messaging”, content or actions into tiddlywiki or tiddlers.

Hi @jeremyruston if I am not wrong the viewtemplate example just allows to choose a color and shows text prefix and suffix. I am working on a mod where you get an edit field and a configurationpanel out of the box.

I discovered a minor issue: with the dynannotate viewtemplate the text of some tiddlers i.e. $:/Import remains invisible which is not very practical.

And I have a question on the performance. My first usecase would be to use dynannotate to give a reading help for Hamlet. Which means I would use it for approximately 500+ expressions.
Do you think the plugin can handle that?

Would it possible to display/exclude annotations based on a filter?

Hi @JanJo

Great stuff. Dynannotate is really a kit of parts for people to experiment with and build from.

Ouch. The implementation could be simplified now that we have the cascade mechanism.

I developed it for annotating epubs, and it works well for long texts as long as some optimisations can be made. The crucial one is to selectively only wrap the dynannotate widget around chunks of text that are known to have annotations.

But the first rule of performance optimisation is to always be making concrete measurements on which to base decisions, so I’d just go ahead and get an implementation up and running to act as a baseline for further optimisation.


One tiny question:
How can I make a button in the pop-up to close the pop-up?

As promised I post a link to my mod of the plugin here.

Dynannotate Mod

It is still rough, the styling of the drop-down and the buttons still has to be done.
Two questions to @jeremyruston :

Is it already possible to filter the annotations displayed for example by modifier or by tag?
(For example only those tagged vocabulary for reading and those tagged stage for rehearsals…)
Meanwhile I found the answer: yes - and it is implemented in the control-panel.

Is it possible to display the annotations of a Tiddler in ther order of their appearance in the text?
This would be usefull, e.g. to add a dictionary with the vocabulary below the text.