giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.38k stars 461 forks source link

Replacing all occurrences of a matching text by a pre-formatted one #2436

Open A-ri-eL opened 8 months ago

A-ri-eL commented 8 months ago

Hi, all!

It would be useful if we could replace all occurrences of a matching text by a pre-formatted (color, font style, in the codebox, [hyperlink](), etc) one.

Any chance? ^--^

gitvectors commented 6 months ago

My approach in absence of such a built in feature is to open CherryTree *.ctd as XML and view in XML editor. Then you can can parse the extire XML document and save. Shut down running instances of CherryTree first before editing. In fact in Ubuntu desktop I use Recoll to index every CherryTree document on desktop then list by Recoll Query - ext:ctd Each CherryTree document shows as XML. But also the selected ctd / XML file can be clicked in recoll panel and opened in GEdit which has find and replace in hamburger button. But caveat: all this is in Ubuntu, not Windows. Recoll does work in Windows so that is worth trying. Requires a small donation to developer due to complexity in Windows whereas Ubuntu usage is free. But I feel that Recoll is worth investigating.

A-ri-eL commented 6 months ago

My approach in absence of such a built in feature is to open CherryTree *.ctd as XML and view in XML editor. Then you can can parse the extire XML document and save. Shut down running instances of CherryTree first before editing. In fact in Ubuntu desktop I use Recoll to index every CherryTree document on desktop then list by Recoll Query - ext:ctd Each CherryTree document shows as XML. But also the selected ctd / XML file can be clicked in recoll panel and opened in GEdit which has find and replace in hamburger button. But caveat: all this is in Ubuntu, not Windows. Recoll does work in Windows so that is worth trying. Requires a small donation to developer due to complexity in Windows whereas Ubuntu usage is free. But I feel that Recoll is worth investigating.

It's a possible approach, but not practical on the day-to-day usage as the needed text styles come up at the reading.

gitvectors commented 5 months ago

I did not notice your answer until now. I don't quite understand where you see .. “as the needed text styles come up at the reading”

Now if you remember that CherryTree document (I refer here to *.ctd) is in fact an XML MIME type it is quite feasible to either (a) parse the content with an XML editor such as XMLCopyEditor or other (using xquery to find and replace) or (b) dynamically change XML content through a method I learned from other apps. It is to insert PHP vars where you want to dynamically change the content like a YAML front end script.

Much depends on how frequently you are changing content. I suspect that you prefer to have a built in CherryTree feature so only if you are seriously interested can I expand further with other tried methods. I reiterate, leverage the XML structure.

A-ri-eL commented 3 months ago

I did not notice your answer until now. I don't quite understand where you see .. “as the needed text styles come up at the reading”

Sorry, I don't log in to Github often.

I also thought of using that XML approach since CT updates the document whenever it receives any changes; but it would be nice if the CT could perform that sort of replacement, yielding pre-styled text as a result, not just plain text. This would help maintain any visual references already in place, as currently we can only replace strings with plain text.