Menotexport icon indicating copy to clipboard operation
Menotexport copied to clipboard

Add a way to configure output template

Open ludzeller opened this issue 6 years ago • 7 comments

Could there be an easy way to configure the way the txt files are configured, look and which fields they output? A templating system would do of course, but maybe a little manual on how to change the code would also do the trick for now. Thing is, I know nothing about python...

ludzeller avatar Oct 06 '17 11:10 ludzeller

Hi ludzeller,

That's a good idea. In fact I'm planning a major update and a template system is one of the ideas I want to implement, but I'm still learning some GUI things. So the quickest solution might be you paste me a couple of templates you would like to have, and let me see whether I could come up with a quick patch for you. Since you are running the python script directly on Mac, I think with a couple of templates as reference it would be much easier for you to craft your own templates.

Xunius avatar Oct 06 '17 14:10 Xunius

Ah, could you also do me a favor? In the docs you export, do you have any notes in the "Notes" tag in the right-side-panel in Mendeley? Because I noticed that I can't find them in the Mendeley datafile anymore, and the tool can't fetch them either, and I wonder could it be that Mendeley has changed the way it saves such notes. I'm on Mendeley 1.17.10, and I can't find them on Linux or Win.

Xunius avatar Oct 06 '17 14:10 Xunius

Of course, here would be my dream template (at the moment...)

--------------------------------------------------------------------------------
# entry title

Comment #: {enumerator}
Page #: {page number in PDF}
Created: 2017-10-06 13:18:07
Text: That's a good idea. In fact I'm planning a major update and a template system is one of the ideas I want to implement, but I'm still learning some GUI things. So the quickest solution might be you paste me a couple of templates you would like to have, and let me see whether I could come up with a quick patch for you. Since you are running the python script directly on Mac, I think with a couple of templates as reference it would be much easier for you to craft your own templates

---

Comment #: {enumerator}
Page #: {page number in PDF}
Created: 2017-10-06 13:18:07
Text: That's a good idea. In fact I'm planning a major update and a template system is one of the ideas I want to implement, but I'm still learning some GUI things. So the quickest solution might be you paste me a couple of templates you would like to have, and let me see whether I could come up with a quick patch for you. Since you are running the python script directly on Mac, I think with a couple of templates as reference it would be much easier for you to craft your own templates

---

Having the page number would be extremely useful for citing! Even if the PDF does not start at page 1 of the actual publication, it would still be much easier to use that as an offset and to calculated the actual page numbers by hand.

In the docs you export, do you have any notes in the "Notes" tag in the right-side-panel in Mendeley?

Yes, I use the Notes field excessively. And yes, it is exported in the according txt file as the first entry of all of them. (In the case of two PDFs it was exported twice at the beginning, even though the Notes field does not differ for each PDF. There is just one per Mendeley entry.)

It would of course be nicer if the Notes was styled a little bit differently at the beginning of the txt.

Notes: That's a good idea. In fact I'm planning a major update and a template system is one of the ideas I want to implement, but I'm still learning some GUI things. So the quickest solution might be you paste me a couple of templates you would like to have, and let me see whether I could come up with a quick patch for you. Since you are running the python script directly on Mac, I think with a couple of templates as reference it would be much easier for you to craft your own templates

ludzeller avatar Oct 17 '17 15:10 ludzeller

Hi ludzeller, Very sorry for the delay, I was literally "engaged" during the previous 2 weeks ;) Now I'm working on a solution to get your template. Just want to confirm one point: in your template, the "Comment" field is the notes you put in Mendeley on top of a highlight section, and "Text" field is the text that gets highlighted, am I right? So you want to export each piece of original highlighted texts grouped with your own comment? If so, I think it's doable but I need to mess around a bit. But for those notes that are not attached to any highlights but just attached onto a page in the PDF, that will probably give you some "Text" field that doesn't make much sense on its own.

Xunius avatar Nov 06 '17 11:11 Xunius

Congratulations for your engagement, if that's what you mean!

And thanks for getting back, really appreciating your help. I will be in the process of writing down my PhD thesis over the coming months and your code could really save my day!

Actually, I both didn't know that the highlights can be read out and linked with comments as well. If that's the case (and I often right-clicked on a highlight to add a note, now assuming I have actually created a linked data structure with that) then it would be fantastic to render them accordingly for output.

That brings me to this new dream template. I think there would be three scenarios:

  • Highlights linked with comment
  • Just highlights without linked comment
  • Just comments without linked highlight

See the templates below. Is that actually feasible?

--------------------------------------------------------------------------------
# entry title
# Highlights linked with comment

Highlight #: {enumerator}
Page #: {page number in PDF}
Created: 2017-10-06 13:18:07
Text: The highlighted text.
Comment: The comment linked to it.

---
#Just comments 

Comment #: {enumerator}
Page #: {page number in PDF}
Created: 2017-10-06 13:18:07
Comment: The comment linked to it.

---
#Just highlights 

Highlight #: {enumerator}
Page #: {page number in PDF}
Created: 2017-10-06 13:18:07
Text: The comment linked to it.

ludzeller avatar Nov 08 '17 10:11 ludzeller

Hi ludzeller,

I've come up with a new update to add the functionality to design template for the annotations. Please get the new code and check it out. Specifically, under the "lib" folder you can modify the file "annotation_template.py" to change the template. I've put some instructions in it, and the template itself should be self-explanatory enough to understand.

Regarding the notes associated with highlights, there is no hard link saved into the mendeley data file, so I'm using geometrical closeness to infer a linkage. I found that if you click on a highlighted text and then add note, the location of the note is almost certainly inside the bounding box of the highlight, therefore suggesting a linkage. For a note inserted at page margin, if it is close enough to a block of highlighted texts, I think it could also infer a linkage. How close this needs to be is defined by a parameter "MAX_ASSOCIATE_DIST" in "annotation_template.py". If you want to disable the 2nd scenario, just set "MAX_ASSOCIATE_DIST" to 0, then only those notes added by clicking a highlight get associated.

Give it a try and let me know if there is any trouble. Good luck with the thesis!

Xunius avatar Nov 09 '17 07:11 Xunius

Hi Xunius,

I finally found the time to check your latest commits, thanks so much for your time!

Unfortunately the -t flag doesn't seem to work properly. Basically all the outputs are just empty then.

Should I maybe send you my sqlite file so that you have something to test against? If so, please drop me a line at [email protected].

Thank you

ludzeller avatar Nov 30 '17 13:11 ludzeller