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

Convert a text file exported by vym to a standard indented text format. #101

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

GReagle
Copy link

@GReagle GReagle commented Apr 10, 2024

It is not as pleasant to read, but much better for data interchange, for example to copy and paste into Freeplane or another mind map program.

It is not as pleasant to read, but much better for data interchange, for example to copy and paste into Freeplane or another mind map program.
@insilmaril
Copy link
Owner

Thanks for the script! Though for data interchange - why use non-standard text format? XML, JSON, YAML are way better formats than just indented text. I could also think of improved Markdown (just received another patch there), where there is already number of tools to generate and also process Markdown? What is the advantage of the text your script produces?

@GReagle
Copy link
Author

GReagle commented Apr 12, 2024

Thank you for viewing my pull request. To answer your question: because it actually works--currently not just potentially--and it is the only way that actually works--currently, not just potentially--that I know of to move a mind map from VYM to Freeplane.

XML, JSON, YAML, might well be better choices for moving a mind map from VYM to another mind map program theoretically. As far as I know, they are not currently available as export options from VYM. Please correct me if I'm wrong.

Edit: To be clear, I know of course that VYM can export to XML. But as far as I understand, that XML cannot be imported into Freeplane. And I realize that there is a potential to transform that XML into a format the Free plane can load or import. I might even think about writing such a program. But for now, plain text export from VYM plus my awk script is the only way I know that currently works. I would be glad to learn that there is a way that I do not know about.

@GReagle
Copy link
Author

GReagle commented Apr 12, 2024

By the way, I don't understand why you've called tab-indented text a "non-standard text format". Tab-indented text to represent an outline or tree structure seems about as universal and standard as possible to represent an outline or tree structure. Of course it has the drawback of being plain and simple, but that also makes it very easy to manipulate with standard tools like text editors and utilities like sed and awk. A format like XML or JSON or YAML can do a much better job of representing the richness of a mind map, but I didn't write such a utility, I wrote a text utility because I am currently capable of doing so, and it works and solves my problem.

I do not know of a standard format for mind maps, other than tab-indented text, which admittedly loses a lot of the richness of a mind map. I know that a bunch of different mind map programs use a bunch of different and incompatible formats. XML itself is not a standard format for mind maps as much as it is a family of standards for mind maps. Same thing goes for JSON and YAML.

The awk script is an optional tool. It does not hinder other ways of moving data around.

I am thinking of (but no promises) writing a program that transforms the XML that VYM exports to a different schema of XML. Maybe to a Freemind XML format. What do you think of that? Do you want to give me any input before I start?

@insilmaril
Copy link
Owner

Thanks for sharing your thoughts. I see several options:

  1. Adding your script, but then I think it would be good to have some documentation. Like: How to execeute (which platform) which of the existing 5 text exports to use as input, ...
  • Rather simple to do
  • Would create a dependency on the used text export format.
  • Does not work on all platforms (easily)
  1. Write an XSL which translates vym XML to freeplane XML
  • "Cleanest approach"
  • Complicated
  • Would create platform dependency
  1. Write a native C++ export for freeplane
    o Not really hard, but requires knowledge of freeplane
    o Why should I do that and not the freeplane guys writing an import filter like I started the other way round? ;-)

  2. Write a vym script which exports the map

  • Platform independent
  • Easy to do and maintain

All above is possibe, personally I'd vote for the vym script, which basically is Javascript:

An example for iteration in release branch could be this :

vym.clearConsole();
m1 = vym.currentMap();

m1.initIterator("foobar");
print ("Starting with branch: " + m1.getHeadingPlainText() );

while (m1.nextIterator("foobar") )
{
    print ("Selected branch: " + m1.getHeadingPlainText() );
}

In the current develop branch this already would look a bit different, as I am currently moving many of the commands from VymModelWrapper to BranchWrapper. So it probably would be approx. something like this:

map = vym.currentMap();

map.newBranchIterator("it");
b = map.nextBranch("it");
while (b)
{
  // Print heading, add tabs as required by b.depth()
  vym.print(b.headingText());
  b = map.nextBranch("it");
}

What do you think? Analog to text export one could also build a string with Freeplane XML of course. I could also maybe build a file dialog, which could be opened by the script to select a destination

@GReagle
Copy link
Author

GReagle commented Apr 16, 2024

Thank you for your very thoughtful response, insilmaril.

Regarding an indented text export... I did it in awk because it got the job done and easily. I wrote it to work with the export format that VYM (I use version 2.6.11 from Debian Stable) calls "Text (ASCII)". I think that having the indented text export format available is generally very useful.

I could fairly easily edit the C++ code of VYM to to export to indented text format, then no extra script would be needed. The code would be very similar to the code already written for "Text (ASCII)" and OrgMode. I might be willing to do this work and submit a pull request, but only if you want it. The awk script works fine for me currently, and I don't want to do the work unless it will get accepted.

@GReagle
Copy link
Author

GReagle commented Apr 16, 2024

Regarding VYM exporting to Freemind/Freeplane mind map format (.mm) . . .
I have been working on an XSLT file. It is coming along nicely. I am pleased with the progress I have made. As preparation, I found XSD files for a few different versions of .mm (0.8, 0.9, and 1.0), and I have made EBNF as well as mind map tree diagrams of the formats.

Do you have an XSD for VYM XML format? Any other concise documentation? I have been (to some extent) reverse engineering the formats.

What is complicated about XSLT method? And why would it create a platform-dependency? I see that VYM already uses an XSLT for Task Juggler export. Does that have limited platform availability?

I have been using the xalan command to do my transformations, FYI.

@insilmaril
Copy link
Owner

Thanks for all the thoughts you put into this. For XSLT: The question is how to execute to parser to transform the XML. I'd have to find out how to do this on Mac and Windows, on Linux it also would a dependency to a 3rd party software, which would need to be taken care of by packagers for the various distributions. So personally I'd prefer a vym script (easy to modify and no need to recompile vym) or C++, both easily portable.

I'd help with both approaches.

Unfortunatly I didn't bother to come up with a XSD so far, also the XML is changing (slightly) while I am working on 3.0. The versions in develop branch are able to read the pre-2.9.500 versions, but not vice versa.

Another idea could be to create an export specifically for Freeplane, again maybe a vym script might be interesting for same reasons as above.

What do you think? I just don't have the time to learn about Freeplane myself...

-Uwe

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

Successfully merging this pull request may close these issues.

2 participants