giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.41k stars 463 forks source link

OPML export #1859

Open PhilHair opened 2 years ago

PhilHair commented 2 years ago

I have TreePad Business Edition (now an orphaned product) and am happy that CherryTree can import from TreePad .HJT files. However, I need it to 1) either export to .HJT or 2) export to OPML (I can work with either option, however OPML is probably the better one). Alternatively, a utility to create either file would be acceptable.

Please let me explain why. I use a program called Outliner for Android devices, and it can accept several formats, including OPML and TreePad HJT files. I would like to be able to use the CherryTree desktop app, then export to Outliner for my phone. That is my personal intended use, but OPML might be as easy to implement, and of more general use.

I have decided that CherryTree is the best replacement for TreePad, and as soon as you implement either solution, I’m going to switch.

Thanks, Phil Hair

giuspen commented 2 years ago

export to OPML is more likely but I cannot personally work on it for now

PhilHair commented 2 years ago

Dear Giuseppe Penone

Thank you for your reply concerning my request. I understand that you have other concerns, and that this cannot be a priority at this time. That is why I suggested that it might be set up as a utility. This would greatly reduce implementation time, and fulfill my needs as well. Later, if/ when you wish to add it to the menus as part of the Cherrytree program, it might be a welcome addition. I might add that making this an OPML export is probably the best (most useful) approach. Again thank you for your consideration, --Phil

Philip R. Hair -- Software Developer / Unix Administrator 711 SW 67th Terrace, Apt C, Gainesville, FL 32607-1923 813/494-0439(C) / @.*** CallSend SMSAdd to SkypeYou'll need Skype CreditFree via Skype

On Wednesday, November 10, 2021, 03:43:21 PM EST, Giuseppe Penone ***@***.***> wrote:  

export to OPML is more likely but I cannot personally work on it for now

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

jgrisham commented 1 year ago

If anyone would like to volunteer to help with this, the import and export code can be found at tree/master/src/ct/.

Possible tasks:

Keep in mind that the three formats mentioned (.hjt, .ctd, and .opml) will not be completely compatible; some data will likely need to be intentionally omitted when importing and/or exporting between them.

PhilHair commented 1 year ago

Dear Jim,

I'm not sure that this will help, but I tried to do some of the work for .CTD to .HJT conversion. I ran into issues and had to abandon the project, but the documentation (particularly for HJT straight ASCII [no RTF] file export may be useful.) All I'm really doing is pattern matching. Please note some extra material included which only applies to my work (CherryTree drops the highest level node, so I acted to recreate it.)

Please find attached the files I created to do this.

On the odd chance that you did not have the original, I am including the file documentation from the original TreePad (free version). I would be glad to share any other documentation I have.

--Phil

Philip R. Hair -- Software Developer / Unix Administrator 1120 TN-91 #1, Elizabethton, TN 37643 813/494-0439(C) / @.***

On Monday, September 11, 2023 at 04:29:36 PM EDT, Jim Grisham @.***> wrote:

If anyone would like to volunteer to help with this, the import and export code can be found at tree/master/src/ct/.

Possible tasks:

           Document the CherryTree file format(s) / user data structure itself, e.g. for:           .ctb Sqlite database           .ctd XML document           subnotes.lst and node.xml files                 Gather documentation for the TreePad file format (either from the CherryTree import code, i.e. ct_imports.h / ct_imports.cc, or from external sources).           Here is some general background information about TreePad by Freebyte.com, for those who are unfamiliar:          *  

   TreePad was available in different editions ranging from free (TreePad Lite and TreePad Viewer), for personal use (TreePad Plus and TreePad Safe) and for business use (TreePad Business and TreePad X Enterprise).

               Official file format specifications for .hjt files for TreePad 3.x-7.x (including sample code), .tpt template files, and .hjt files for TreePad 2.x are mentioned on an archived version of their site (unfortunately the direct links to the files themselves do not work, but I've manually linked to them for convenience)           There was also a .tpx 'enterprise database' format, but I didn't explicitly search for any documentation on that.          

          The TreePad utilities page contains a link to a python script that can read/write TreePad Lite files           The TreePad File-conversion utilities page contains tools to convert between TreePad and other formats, such as:           .csv           Binary TreePad .tpd files, which it states were introduced back in 2004           .xml           Unix Yank format           .opml           NoteTab .otl outline files           ... and others                      Create a draft export function (even if only a pseudocode procedure) for the desired TreeLine format(s)            Create a draft export function (even if only a pseudocode procedure) for .opml files            Create a draft import function (even if only a pseudocode procedure) for .opml files     

--

Keep in mind that the three formats mentioned (.hjt, .ctd, and .opml) will not be completely compatible; some data will likely need to be intentionally omitted when importing and/or exporting between them.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

@REM -- awk-#1-all-txt.bat [ctd file w/o extension: default PRH-GtD] -- PRH -- 2023-04-14 @REM -- convert all articles in a CTD file to text only @set xfile=%1% @if [%xfile%] == [] set xfile=PRH-GtD @echo %xfile%.ctd @if not exist %xfile%.ctd ( @echo file does not exist @pause @exit /b ) @"C:\Program Files (x86)\GnuWin32\bin\awk.exe" -f ctdtext.awk %xfile%.ctd >%xfile%.out @if exist %xfile%.tmp del %xfile%.tmp @rename %xfile%.ctd %xfile%.tmp @rename %xfile%.out %xfile%.ctd @dir %xfile%.ctd /n | "C:\Program Files (x86)\GnuWin32\bin\grep.exe" %xfile% @dir %xfile%.tmp /n | "C:\Program Files (x86)\GnuWin32\bin\grep.exe" %xfile% @pause

@REM -- awk-#2-ctb2hjt.bat [ctd file w/o extension: default PRH-GtD] -- PRH -- 2023-04-14 @REM -- convert all articles in a CTD file to text only @set xfile=%1% @if [%xfile%] == [] set xfile=PRH-GtD @echo %xfile%.ctd @if not exist %xfile%.ctd ( @echo file does not exist @pause @exit /b ) @"C:\Program Files (x86)\GnuWin32\bin\awk.exe" -f ctdhjt.awk %xfile%.ctd >%xfile%.hjt @dir %xfile%.ctd /n | "C:\Program Files (x86)\GnuWin32\bin\grep.exe" %xfile% @dir %xfile%.hjt /n | "C:\Program Files (x86)\GnuWin32\bin\grep.exe" %xfile% @pause

Technical documentation on the structure of the TreePad file format.

TreePad file format for TreePad .hjt files:

The basic file format is text/ascii. Inside the ascii file, the start of a TreePad file should be the line: <hj-Treepad version 2.7> where the version number can vary depending on the TreePad version which had been used to create/write the file.

each node looks like:

(Data type indicator)

(Node title) (level indicator, 0 meaning at tree level 0, 1 meaning one level up, etc.) the following lines are part of the article text, until the closing line ('end node'), which is: 5P9i0s8y19Z example for one node: dt=text mail from the President 4 Dear sir, I would like to invite all TreePad users into the Oval Office to help me learn how to use TreePad. Sincerely, G. Bush, the White House Washington 5P9i0s8y19Z The data type indicator 'dt=text' has been introduced by version 2.7 and will be ignored by earlier TreePad versions, so that the file format is backwards compatible. 'dt=text' indicates that the type of data inside the article connected to the next node is 'plain text'. A future RTF-enabled TreePad will be able to have RTF articles, so that dt=RTF or possibly also dt=HTML will be included. The string 5P9i0s8y19Z is included to make sure that when someone types in the article, the program will not get confused into thinking the node has ended there (in the middle of the article). The chance that someone types 5P9i0s8y19Z by accident into the article area is very much smaller. Not a very beautiful implementation, but it's simple and it works. The order in which the nodes are listed in the TreePad file is determined by the order in which they would appear in a fully expanded tree, beginning at the top, and ending at the bottom. E.g. a sequence of levels (the numbers are indicating the node levels): 1 - 2 - 3 - 3 - 3 - 2 will be corresponding to the tree structure (the numbers are indicating the node levels): 1 ___2 | |___3 | |___3 | |___3 | |____2 Warning: if you store this text in TreePad, do not include any " 5P9i0s8y19Z" as appearing in this text !!!!! More information on TreePad file formats can be found in the TreePad documentation and manuals section: http://www.treepad.com/docs/ TreePad home page: http://www.treepad.com Freebyte.com home page: http://www.freebyte.com Contact: http://www.treepad.com/support/