klieret / anki-merge-notes

Anki plugin to merge notes.
GNU Affero General Public License v3.0
6 stars 0 forks source link

Line breaks separating merged content [solved] #6

Closed 4SoG closed 5 years ago

4SoG commented 5 years ago

Line breaks that should separate merged content:

    # * ```merge_tf``` (the field value of the to note will be
    #   field value of to note + line break + field value of from note

don't work for me for some reason (Anki Version 2.0.52 Qt 4.7.4 PyQt 4.8.6 on Windows 10 Version 1809 (OS Build 17763.615) 32 bit.). Field values are only separated with a space.

To get line breaks I have replaced

            return field_from + "\n" + field_to

with

             return field_from + "<br>" + field_to

in line 257

and

            return field_to + "\n" + field_from

with

            return field_to + "<br>" + field_from

in line 262.

Note: this has been tested with

    self.strip_html_permanently = False

and I'm not sure if setting self.strip_html_permanently = True might conflict with those <br> tags. If yes, there could be another separator used instead of a line break, e.g. |. (The separator could also be user-configurable, but this would require code alterations too complex for a person with zero knowledge of Python, like myself...)

Hope this helps in case someone else has a similar issue or would like to use a different separator.

klieret commented 5 years ago

Right! Sorry again for how sloppy this addon was written (intended for one time use, haha).

I'll fix this/make this configurable.

Yeah, about strip_html_permanently, I'm wondering if I should just remove it completely. Feels like a dangerous feature and it's not really related to note merging anyway.

Thanks again for reporting this so thoroughly! :heart_eyes: Testing and feedback is really valuable.

4SoG commented 5 years ago

Happy to help any way I can!

That's great to hear, configurable separators would be a neat option. As for strip_html_permanently, you're right that it seems unnecessary and may even be harmful sometimes, but maybe setting the default value to False and a warning would be enough, some users might like/need this functionality.

And thank you one more time for the addon, it's already saved me a lot of time! I'm awfully grateful that you're willing to share and support it. Thanks! :1st_place_medal: :clap:

klieret commented 5 years ago

The latest commit should fix the linebreaks (and you can set another string with self.merge_join_string) :)

As for strip_html_permanently you might be right, but I don't see the use case in this addon (one could write a much much simpler addon doing the same thing). I think here it is only dangerous. I will remove it and write a strip html addon if anyone ever requests it ;)

klieret commented 5 years ago

I hope I can add some more functionality to this addon (and perhaps port it to anki 2.1). Would be great if you could also test that it works as intended some time then :)