-
Notifications
You must be signed in to change notification settings - Fork 82
Use joplin-turndown for HTML->MD conversion #38
Conversation
Hi @nathanlesage! First of all, let me say thanks for taking the time to contribute to this plugin, I really appreciate your help with this!
I agree with this! I actually have been meaning to improve this but haven't had much time to refactor it. I really appreciate this and love the idea of making this more maintainable. As a "fix", in v0.1.0 I added a hidden option to let users choose/modify how to translate those elements, the main reason (also based on the As for your open questions: TL;DR: I'd be happy to accept all the help I can get here. This is the first anything I do with Javascript, and it's been quite the learning curve. I've been trying to find ways to split the code into multiple files in a way Zotero could handle it, but haven't had much success with what I had tried so far (I was hoping to include this in v0.1.0 originally). The next thing to try on my todo list was migrating to typescript and using the generator written by retorquere which also uses webpack from what I could gather. Given that I'm still learning all these new tools, I was still doing research and testing out before I could book some time to work on it, so your PR couldn't have come at a better moment.
Once again, thank you! And greetings back to wherever you are in Germany! |
Hey @argenos, thanks for the elaborate reply!
Yes, there are three kinds of customizations we could easily add:
I know exactly what you are talking about; I've had that feeling for the past three years, and it has only abated a few weeks ago, which is why I'm much more confident proposing that large of changes at all! As to the answers to my questions: Splendid! And with regard to Typescript: I was pondering the thought myself, but didn't want to add too many things right now! But now that I know that in principle you'd be willing to migrate to typescript yourself, this is even better. So here's what I would suggest:
I'm in Sweden right now, but I'll be home for Christmas! Thanks again for your work, and I'm looking forward to making this plugin awesome :) |
Sounds like a plan! I'll set things up to test your branch locally too! Thank you! |
Perfect 👍 Quick update: I just fiddled around with it and TypeScript works like a charm. But I'll do it properly in time :) |
Hi @nathanlesage! I had to push a few small bug fixes today, but I'm doing a code freeze now. Let me know if I can help with anything! |
Easy, I'll just pull the current state as I'm not touching the mdnotes.js file either way, so you can continue amending this file, and I'll deal with any merge conflicts :) I'll be updating this PR in a few days I think when I have a first draft of the changes – this way you can follow the developments if you want! |
Hey @nathanlesage! Just a small update: I already had this working locally some weeks ago, but hadn't had time to play around with this further. I've just pushed your changes to feature/joplin-turndown (and solved the merge conflicts with the past few releases) and added a few rules for the missing Zotero note exports. What do you think about merging what we have so far? Let me know in case you want to take a look! |
Hey, sounds good! I would also like to apologise for not being able to further this even though I promised that, but in the End of January a course at my university started and it's taking almost all of my time :( Do I need to do something for this …? I'm sorry I don't have an overview right now … |
Hey, no worries at all! I also hadn't had much time to further work on this, and you already did a lot with the setup and your branch set me off on the right track! No need to do anything for now I think, I can just merge the branch and that would be it! We can tackle typescript on a separate PR on a semester break later on. Good luck with your course! |
Perfect! :) Thanks a lot! I hope I can get in here again and help out soon! |
Hey there!
First and foremost: thank you for the initiative of this plugin. I've been pondering the idea to do so myself for quite some time, but never actually realised it. However, now I'm pretty happy for your work already with this plugin, which I'll be using quite often!
This PR addresses two things, but there are also some open questions (see below), which is why I have created a draft PR first. I wanted to discuss these beforehand, and only convert it to a final PR once you agree!
Changes
This PR addresses two main issues:
The reason I switched to Turndown is because I also use Zotfile to extract my attachments, but have amended the preferences of Zotfile so that it actually spits out well-formed HTML code instead of the paragraphs with quotes. So when I first used the plugin, this gave me weird results. By using Turndown, we have both a solid engine for converting HTML to Markdown as well as something complete, so that users can actually create standalone notes and the plugin will correctly export anything that can be expressed in Markdown.
This initiative brings some important changes to how the plugin is built:
Zotero.MarkdownUtils
, because I did not want to mess with the Mdnotes-object. But I would like to add the utility functions to the Mdnotes object itself, however this would require to have themdnotes.js
-file in the webpack toolchain (see Open Questions)../src
-directory in which the entry point of the Markdown utilities resides./content
-directoryyarn build
-command)Caveats
I saw that your original implementation converted paragraphs that begin with a quote into blockquotes. This pretty much looks like a conversion of Zotfile output. However, this has some assumptions, and I'm personally wary of making them with regard to notes. I would rather not add this. But I can totally see the reason for adding this in the first place, as it takes away the responsibility of the users to mess with the hidden config options, which I can totally understand.
If you would like to retain this functionality, it is easier to apply this to the rendered Markdown (because we could simply run a search for lines beginning with
"
and prepend>
in front of them). Nevertheless, I would then make this an option (default set to yes) whether or not the user wants this additional conversion applied.Open Questions
I have some open questions, and as I would like to contribute to this plugin, I would like to discuss them with you, as this is first and foremost your plugin, so I'll go into your direction if you don't like certain approaches!
mdnotes.js
into the webpack toolchain. However, this shouldn't prove too difficult and I would volunteer to do the migratory work!And who will maintain all of this?
The big question I'm facing with my projects as well: Who is going to maintain it? I would volunteer to do all the initial work in such a way that the code documentation is decent and everyone has an easy chance of getting into it, especially given the fact that the Zotero plugin documentation is pretty awful (which is one of the reasons I did not so far attempt a plugin, and am now bandwagoning on this one). I would also vow to be responsible to maintain those parts I wrote where you don't understand or don't have the time to read the source.
EDIT:
P.S.: Tested on macOS 10.15.7 and works like a charm :) (including the changes from #35 which you mentioned in the other issue)
P.P.S.: Greetings to the Hochschule Bonn/Rhein-Sieg and my hometown! ;)