Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Cherrytree markdown-based for greater compatibility #2448

Open
Breizhux opened this issue Feb 27, 2024 · 13 comments
Open

Make Cherrytree markdown-based for greater compatibility #2448

Breizhux opened this issue Feb 27, 2024 · 13 comments

Comments

@Breizhux
Copy link

When I discovered Cherrytree over 6-7 years ago, I was quick to think that your software should be based on markdown.

The idea was simple, the file would be characterized by :

  • each node would be a markdown file (or simply text, for plain text).
  • a file (json, for example) that would define the entire data tree (records the left-hand side of cherrytree: name of nodes to be displayed, corresponding md file, associated icon, its position in the tree, keywords for searching, etc.).
  • images/attachments would be saved in a folder (named resources, for example). This would contain all images and other data not directly integrated into Markdown.
  • the whole thing would form a folder full of files, and would be compressed to form an archive specific to markdown (archives can be encrypted...).

It seems to me that there would be enormous advantages to such a structure:

  • compatibility: it would be very easy for all developers to automatically generate a Cherrytree file. Because generating markdown files would be very easy. It also means that, for highly constrained or non-compatible systems, cherrytree could still open the file legibly, manually (even if it's not as pretty as in a markdown viewer).
  • configuration: it would then be much easier to style the CSS for users who are demanding in terms of design... And God knows, everyone has different requirements in this respect!

On the other hand, the complexity would lie in maintaining a WYSIWYG editor... In other words, the user wouldn't see any change in the interface, except (perhaps, if we choose to do it that way) to be able to format text directly with markdown syntax (to be seen if it's feasible).
I haven't looked at how your interface works, but I imagine you're basing it on GtkTextView with formatted text. So there are perhaps 2 possibilities: have a WYSIWYG markdown engine → visualizer directly (such as joplin wysiwyg editor), or a markdown converter → GtkTextView (which would modify the GUI (almost) nothing).

I'm well aware that this would be a real project, and that it would take a lot of time to develop, and maybe even a new version number ^^.
But your interface (although perfectible) is well thought-out, very simple and really useful! It really feels like you're developing a tool to be of service, and that's what we expect from a tool!
So I thought I'd suggest making it even more useful by integrating this Markdown standard into the file saving structure itself, without changing the interface (unless you really want to improve it).

Thank you for your work and I wish you all the best!

@giuspen
Copy link
Owner

giuspen commented Feb 27, 2024

Hi @Breizhux , it's more likely that the markdown will be supported as an export type in future.
Supporting yet another data storage type (there are 3 at the moment, not considering the password protection) would require a serious amount of time

@Breizhux
Copy link
Author

I'm well aware that this would be a major change, and that it would take time. And it's with a long-term perspective that I'd like to put this idea forward.
I think that switching to markdown would mark a real turning point and make CherryTree more essential than it already is in the world of note-taking!
I think the concept and design of CherryTree is really good, and makes it almost better than any other tool out there (simple, minimalist but with the important features, allowing you to take structured notes without unnecessary distractions, it's perfect in form!). I just think you could beat them all by a mile if you added support for markdown storage while keeping the same wysiwyg interface.

Now, I'm aware that I won't be seeing this released for a long time. I'm developing a bit, and I know it's going to be a lot of work. I'm just putting the idea out there for consideration, and hope to integrate it into future versions (I'm patient, I can wait ;)!

@gitvectors
Copy link

gitvectors commented Feb 28, 2024

I have used CherryTree for years and I see no need to change its already formidable structure. However I also use Markdown in multiple cases such as Hugo.

Where we see multiple frameworks there is often the ability to think of orchestrating tools. That is using a cohort of tools in a toolchain.

Thus I have just bounced questions off an AI assistant (who can search faster than I can) and the convergence of prompted ideas was as follows:

Think of a cooperating toolchain rather than aiming for every feature from one tool.

Use a Markdown editor such as Zettlr, Sublime Text, VS Code to create Markdown “nodes”.

Use Pandoc wth a custom Lua filter to transform Markdown to XML.

Inject custom XML as nodes into CherryTree.

The internal structure of any CherryTree document can be viewed in XML editors such as XMLCopyEditor.

Another route is to use Python to inject Markdown created documents into CherryTree. That is leverage the XML structure.

https://lxml.de/tutorial.html

https://stackoverflow.com/questions/73652391/create-custom-xml-output-from-pandoc

I am using CherryTree as eLearning containers.

@Breizhux
Copy link
Author

You think users will do that? Especially simple users who just want to take notes and be able to share them?!

I'm not asking for a tool that does everything and the opposite of everything. Only a tool that can do wysiwyg markdown, which nobody does correctly and simply today (except closed-source solutions). Without losing the spirit of Cherrytree, which I mentioned above.

I really think that with Markdown support, Cherrytree would become THE open-source note-taking software. We all know the advantages of Markdown. Cherrytree also has qualities that no other note-taking software has. I think it would be a great idea to bring together the best of both worlds!

@gitvectors
Copy link

Converging on "simpler" workflow, but not dropping above.
"Pair" Sublime Text (for Markdown notes and Markdown Preview) with CherryTree (import HTML exported from Markdown).
Via Sublime Text custom plugin to automate Markdown <-> CherryTree flow.

@hazeyez
Copy link

hazeyez commented Mar 4, 2024

+1 more vote for markdown export. the reality is that the people using cherrytree interact with markdown in other apps frequently, and cherrytree is a vector to that.

this request has been made for the past 5+ years and i was just about to make it again, and saw this one. understandable it'd take a lot of effort to support this feature as @giuspen noted. he also has been saying that he plans to add markdown support for 7-8+ years, so don't hold your breath.

@Breizhux you fail to realize how much work and effort goes into a small open source project like this. On top of this, multiple other factors come into play such as time, cost, security, etc.

@Breizhux you know you can export from cherrytree to HTML which is so very easily convertible to markdown? IN FACT, they're practically one-in-the-same in the sense of how easy and seamlessly they convert.

https://codebeautify.org/html-to-markdown

  • Upload the html file or paste the html code / download the markdown file or copy the md code
  • Should work for most fields, if not then get creative.
  • You can also ask GPT to convert the html 2 md

https://github.com/search?q=%22html+to+markdown%22+%22converter%22&type=repositories&s=stars&o=desc

  • if you want to run a converter locally, from command line - there are plenty out there.

On a final note - it'd be nice if all programs did everything we wanted. That's not the reality we live in, unfortunately. Your request is not outrageous, I want to make the same request and have for years. But I realize this is a small open source project, and the creators do the best they can for us. It's on us to liaison the tool for its best uses, and get what we can out of it - while supporting it.

Before we know it, the white house will take CherryTree away from us - so enjoy it while it's still here!!!

https://www.tomshardware.com/software/security-software/white-house-urges-developers-to-avoid-c-and-c-use-memory-safe-programming-languages

@Breizhux
Copy link
Author

Breizhux commented Mar 4, 2024

Yes, I'm well aware of the amount of work involved. That's why I'm proposing a very long-term vision for Cherrytree.

And today I'm perfectly capable of doing a CherryTree --> HTML conversion.
But you have to admit that Ctrl+S is more convenient than going to the menus, clicking on export to HTML, then doing an html --> md conversion.

On the other hand, I didn't know that Giuspen included markdown support.

In any case, my intention is only to propose a concept/how to integrate markdown into CherryTree. I have no time requirements, as you can see. My idea is to simplify usage to such an extent that markdown can be used with the touch of a fingertip: Ctrl+S! Wouldn't that be great ;)

@gitvectors
Copy link

Another shorter term vision. Today.
CherryTree -> HTML -> Pandoc -> Markdown (or other types of many)
This pipeline script can be written in a CherryTree CodeBox to run.

@tititototutu
Copy link

tititototutu commented Jun 12, 2024

Hello,

My christmas present would be a keyboard shortcut to easily switch between two view modes for a node: the markdown edit mode and the view mode :)

EDIT: Verry Sorry, it's already implemented....
for those wishing to have a keyboard shortcut that displays the visual output of markdown text via a keyboard shortcut (under GNU/Linux)
0) install the "glow" visualizer via your package manager

  1. On your active node -> F2 -> Syntax highlighting -> Select "markdown".
  2. In Cherrytree preferences
    2.1 ) "Plain text and syntax highlighting" on the left menu -> then Click "+".
    2.2 ) Select markdown
    2.3) Double click on the mark down line and change "REPLACE_ME <tmp_src_path>" to "clear && \glow -w 230 -- <tmp_src_path>"

And Voila, now press F5 on your markdown node, and you will a have a nice terminal markdown rendering :) and press CTRL + F9 to hide/view the terminal windows, hmm how nice :)

Many thanks to the Cherrytree creator and contributors :)

/!\ Please keep the facility to crypt the cherrytree file with a password/passphrase :)

PS: after reading some source code files, giuspen seems more to be a LaTeX fan :)

@Zireael07
Copy link

Does the html to markdown site work locally or via sending to server?

Anyway Markdown is such a widely used format that I'm sorely disappointed to see it's not an option for CherryTree exports :(

@gitvectors
Copy link

gitvectors commented Nov 10, 2024

You can export as HTML then in a helper script run Pandoc > HTML > Markdown (or other format). indeed I am exploring export CT to HTML then tweak to create a Reveal.js Presentation where each CT node is a slide. A new feature?

@galk-research
Copy link

galk-research commented Feb 22, 2025

I have been using cherrytree for years, and I love it. However, recently I started thinking about the advantage of using markdown in addition to XML as a valid file format. While this may be a rather significant undertaking, I'm thinking that perhaps this can be done in several stages, each perhaps not as daunting as one might expect.

The format I have in mind would use folders to maintain the hierarchy, in much the same the existing hierarchical XML format does (when using "file per node" xml format): Each folder would have its main text in "index.md", a folder for embedded files (images, PDFs, etc) and leaf subnodes (i.e., subnodes that do not have subsubnodes) as markdown files, named after the subnode name.

The main benefit I see in this are the fact that the file hierarchy is self-explanatory, notes can be edited from outside cherry-tree, and files can be added and changed without running cherry tree. This for instances eases the syncing (via services such as syncthing, git, or just a dropbox folder). It also makes easier to create scripts, in lieu of plugins, that can be run externally to cherrytree

Some of the components for making this happen are actually already there, as best as I can tell:

  • Choosing to save cherrytree DB in its hierarchical form (each node in an xml file) is already supported. Currently, node file names are numbers -- likely used internally in cherry tree. Would need to convert these to and from note names to use them in file names. As the XML holds this information, should be doable.
  • Exporting XML to html is supported, i.e., there is somewhere in the code a component that translates internally from the internal representation to html. Currently, the export writes a flat folder of all subnodes, where the hierarchy is embedded into the file names. It looks pretty feasible to use folder names for the hierarchical parts. And even, as a first step, calling on pandoc to translate every html file to markdown from within the code, while very crude, may actually provide a first working solution.
  • Importing from markdown is supported, both of a single file as well as a folder of files. Using this to read from the proposed file+folder format seems fairly straightforward

Likely, there are bugs in my reasoning. There's always a difference between what seems doable and what is actually doable in reasonable time. I am also no arguing that the simple format I proposed (folder and files) is well thought out, though it seems on the face of it to be similar to what obsidian is using (but I'm not an obsidian user -- cherrytree for years, as I stated).

I would love some feedback on this idea, as well as any pointers that could be useful -- either to the code itself (i.e., where do I find the necessary components) or to other attempts, examples of good ideas, and components that be used or reused. If there's any documentation on the cherrytree code structure that I could use, it would be quite beneficial.

Thanks!
p.s. a really terrific starting point would be a definition of the cherrytree XML. pandoc can accept XML syntax definitions as a parameter. That would allow working directly on the XML file of each node.

@gitvectors
Copy link

I spotted by chance this reply buried very deep.

I found it by chance.

This is my latest thinking.

#2661

Perhaps community needs a discourse server or similar so that we do not lose late replies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants