tomboy-notes / tomboy

This is the legacy development for Tomboy.
http://projects.gnome.org/tomboy
GNU Lesser General Public License v2.1
126 stars 25 forks source link

Import from HTML? Options? #104

Closed SupraLance closed 5 years ago

SupraLance commented 5 years ago

My OS HDD crashed, and the Tomboy hidden folder where notes were stored is lost. I kept backups on another drive via the 'Export to HTML' function, but now realize there is no 'Import from HTML' function, so I can only view my notes in the browser.

How can I quickly/easily convert my notes from HTML back into Tomboy while preserving the formatting?

davidbannon commented 5 years ago

SupraLance, if you don't get a better answer ... I think Ben has put some effort into an HTML import/export filter for tomboy-ng. Not sure how far he has got with it. But I reckon, one way or another we could do that. Once the notes are recreated as .note you could revert back to Tomboy. Lets see if anyone has a more direct solution .... Davo

SupraLance commented 5 years ago

David, even if that's not quite ready I would be happy to test it if you could point me in the right direction. There doesn't seem to be any other solution that doesn't involve reformatting each and every note (many of my notes used tabs to make quick tables etc and are a jumbled mess without the formatting). I have a lot of information in there that I can only view in the browser now and no longer edit, so appreciate any help.

davidbannon commented 5 years ago

Hmm, not so much "not quite ready" as "not quite started" I'm afraid. I think Ben was working on an export filter rather than import. So, I'll see what I can do. It won't be a generic html importer, I'll focus on just the html that Tomboy produces. So, what plug-ins do you use ? And I guess you use bullet points ?

I still have an install of Tomboy on an older Laptop so will generate some test files there.

Davo

SupraLance commented 5 years ago

I haven't added any plug-ins, it's just as it comes with the Linux Mint distro (which includes Export to HTML). I tried to attach one of the HTML exported files, but that file type is not supported for upload here. Perhaps I can email it to you as an example? I didn't use bullets, just tabs (bad practice I know) to quickly type the text into tables to organize data as I went. The tabs still line up right when I open the HTML in the browser, but not if I copy/paste it back into a Tomboy note so even one-at-a-time option isn't working for me.

davidbannon commented 5 years ago

Hmm, I have had a look at the html that Tomboy makes when exporting. Its very heavy on CSS I'm afraid. Thats going to make direct translating to xml very difficult. And just as difficult to try and pull it into a tomboy-ng env, especially as Tomboy seems to honour the use of a Tab far better than -ng.

So, we need an alternative approach. -ng will import a RTF file. Either opening a RTF file directly or by pasting RTF content into an existing (and ideally empty) tomboy-ng note window. So, a browser that chooses to copy in RTF would a great way to go.

However, RTF is not big in the Linux world (not surprisingly) and I have not found a reliable way of translating HTML to RTF on my Linux box. Libre Office does not open Tomboy's HTML correctly. Both Firefox and Chrome do but neither will save or copy in RTF. Sigh.....

I'm wondering if a Windows browser can, firstly parse Tomboy's HTML and then copy in RTF (so you can paste into -ng) ?

davidbannon commented 5 years ago

OK, further scratching around. Two points.

  1. Current release of tomboy-ng does not handle tabs as you expect. Fixed in source, if you want me to cut you a custom version, please ask.
  2. I used a website, https://www.aconvert.com/document/html-to-rtf to convert my Tomboy created HTML files to RTF and them imported them into (my updated) tomboy-ng and all seemed to work OK.

Not knowing the content of your notes, I cannot comment on how good an idea it is to let that particular website have a read of them. They sure would not get to see all of mine ! But it does at least prove that it may be practicable to do this two step conversion.

If you have a lot of notes to do (and I guess you do!) it probably makes sense to script as much as possible. So, for example, you'd probably want me to add a command line switch to tomboy-ng that saves and exits after it imports each RTF file. Else you have to make some arbitrary change to force a new save each time.

Davo

SupraLance commented 5 years ago

That website conversion actually works quite well, although, like you, I would prefer not to expose all my notes to the internet. It claims to support batch conversion, but so far I have only managed to convert files to rtf one at a time. I've converted a few of my notes, but hope for a better process to eventually get all 343 of them back into tomboy. I know nothing of scripting. Appreciating the help...

davidbannon commented 5 years ago

SupraLance, please note that if you are following my recipe, you should not be using the public version of tomboy-ng to convert RTF to Tomboy format. It will not preserve tabs ! And you apparently use a lot of tabs ....

Davo

SupraLance commented 5 years ago

I'm actually using Tomboy 1.15.9 that came with the 64bit Linux Mint install atm, and just opened the rtf in Libreoffice and copy/pasted into a new tomboy note. It works, although a tedious process. I'd be happy to try the new tomboy-ng though if you don't mind cutting a fixed version for Mint, as I don't know how to build from source

davidbannon commented 5 years ago

OK, first a question or two ? Mint ? The deb based one ? 64bit ? Do you use filesync ? (I ask 'cos the one I am working on, right now, has had a number of major changes to sync and if there was the slightest risk of you using that aspect of it, I'd not send it until I've tested a lot more.) I also think it would be heaps easier for you if you lets me add a command line switch that will auto save the imported note and, perhaps put it in an appropriate dir. That way you can build your dir full of rtf files and then just run a one line bash script, something like -

for i in ls -b *.note; do tomboy-ng --autosave "$i"; done

and all will be converted and tucked away safely. It you want to then use them with Tomboy, GNote etc, its just a case of moving them to appropriate dir.

Make sense ?

Davo

davidbannon commented 5 years ago

watch that sample script there, markup has pinched my backticks, but you get the idea ....

SupraLance commented 5 years ago

I can wait until it's ready, especially when waiting saves me some work. And yeah 64bit Mint, which is basically Cinnamon dt on top of Ubuntu, which is Deb based (so yes, Deb packaging works). Tomboy is the stock note taking app for Mint, so you have LOTS of users on that distro.

SupraLance commented 5 years ago

Oh, I've not used filesync, or I wouldn't have this problem, lol. It's something I should look into in the future though. But I won't mess with that feature if you tell me it's not working right.

davidbannon commented 5 years ago

OK SupraLance, I have made that deb package. I'd rather not put it on the tomboy-ng release page due to it having quite a lot of other, relatively untested code in it. Do you appear in the Tomboy mailing list ? If not I'll put it on my googledrive and post a link to it here.

Here is a line to use it to convert every rtf file in the current directory to a note.

for i in `ls -b *.rtf`; do echo "------ $i ------"; tomboy-ng --save-exit "$i"; done

For the record, this new deb has

SupraLance commented 5 years ago

Well, I'll help with that testing. I think I signed onto the mailing list just before posting here, if so it will be under the same name or mr2blu4u@yahoo.com.

SupraLance commented 5 years ago

David, Is there a way to make that batch import script work with filenames that include spaces (multiple words)? I could rename all my notes, but that will destroy all the links between the notes that I'm hoping Tomboy will restore if the names still match the in-note references.

davidbannon commented 5 years ago

Ah ! Spaces in File names ? Thats to be expected of course. Yes, can be done. Just a case of escaping the spaces. I'll get back to you ...

davidbannon commented 5 years ago

OK Lance, new command line below. Should have used find in the first place. However, and there is always a "however" - 'cos I tried it out this time, I realized there is a further problem, my model was creating note files with the same name as the html files, not the Tomboy standard 36char GUID names. And it was leaving them in the same dir as the html files. Sigh ...

So, I'll sen you a newer deb file to nstall over the last one, it will create proper looking note files and will create them in the standard tomboy-ng location, /home/$USER/.local/share/tomboy-ng

Here is the command line (note there is a space, a dot and another space after the word 'find') - find . -name "*.rtf" -exec /home/dbannon/Doc/Prj/Pascal/tomboy-ng/tomboy-ng/tomboy-ng --save-exit {} \;

SupraLance commented 5 years ago

Editing that command to match my Debian install did the trick: find . -name "*.rtf" -exec /./usr/bin/tomboy-ng --save-exit {} \;

Thanks so much for all your help, my notes are restored into Tomboy from the HTML export and I think we can mark this issue resolved. The most time-consuming part of the process was running the html files through Aconvert to convert them to rtf, which took about 6 hours. For anybody looking to create a streamlined process for "import from HTML" without using Aconvert, I ran across a post that might be useful and figure I should post that here for the benefit of others who may have this issue now or in the future: https://stackoverflow.com/questions/150208/how-do-i-convert-html-to-rtf-rich-text-in-net-without-paying-for-a-component