giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.29k stars 457 forks source link

Node path to be accessed by means other than manual copying #2527

Open gitvectors opened 2 weeks ago

gitvectors commented 2 weeks ago

This request is rather different from a similar issue. Similar issue: Add show / hide option to show in status bar full path of selected node #2525

This is a different matter, you would like to support code executed in a node with for example environmental variables that expose node name or else... it is a fair request but this should go to another ticket along with description of a practical case / test example

Practical case:

Consider a scenario where each CherryTree document (*.ctd) is in fact an eLearning module or container (one of many) containing instructions to pass to a remote learner.

We wish to leverage embedded CodeBoxes in each eLearning module.

Consider that a node might contain instructions and embedded CodeBoxes and other assets containing scripts for each stage in an eLearning workflow.

We are aiming to provide an alternative to YouTube presentations where static screenshots and commentary followed by remote learners, skip ads, jump between screenshots and desktop terminal. Instead the eLearning container will be the alternative to YouTube presentations and execute code held in CodeBoxes.

We are aiming to use CherryTree as a skeleton for populating documents and web sites and presentations.

We might include code in one or more CodeBoxes supported by descriptive text in rich text mode. Like Jupyter notebooks in fact.

We can adopt a convention to ignore comments between tags.

We wish to parse the content of the node as an XML format node containing mixed rich text, images, tables, links to files, LaTeX and CodeBoxes.

If we wish to inspect the node structure we can view *.ctd content in XMLCopyEditor.

We create a Python CodeBox to parse that particular node.

We research how to use XML parsers.

https://realpython.com/python-xml-parser/

https://realpython.com/working-with-files-in-python/

HOWEVER .. the missing link in such adventures in morphing CherryTree into an IDE is the absolute path to the file or node which is required to be parsed .. wheresoever CerryTree document has been placed in desktop file system.

Noting the CherryTree existing feature that the node path is visible when hovering over node toolbar it would be useful to have a hotkey which grabs that data to copy into either clipboard or env variable to be accessed by CodeBox XML parsing script.

Of course an easy workaround is to just copy the popup node filepath and add to CodeBox script. But this is more than a one time operation. This also breaks if the CherryTree document is moved.

CherryTree is being used by this writer rather like scripts as a devops container for multiple processes. Granted, an outlier usage, but there is much scope in thinking of CherryTree as an eLearning container vs. YouTube.

Further note: Related to this companion issue. https://github.com/giuspen/cherrytree/issues/2528

I have decided that it is easier to export node as HTML and work on the exported HTML rather than parsing XML (although parsing XML has its advantages).

Issue resolved.

jonathonmckay commented 1 week ago

I raised a similar (I think) issue #2452