natfarleydev / anki-auto-markdown

10 stars 2 forks source link

Nested list regression #12

Open peter-moran opened 3 years ago

peter-moran commented 3 years ago

I think there is a regression. Using https://ankiweb.net/shared/info/1030875226 the following correctly converts to a nested list:

* level 1
    * level 2

While the version at https://ankiweb.net/shared/info/15061497 does not.

natfarleydev commented 3 years ago

Thanks for the report @peter-moran, which version(s) of Anki does this effect? I think there have been significant changes to the way Anki internally converts cards into text so it might be a bug further upstream which needs to be worked around.

If you are on a version of Anki that supports the previous plugin I would recommend using that as I make no effort to preserve backwards compatibility with this fix version in order to keep it compatible with the latest version

sre2dev commented 3 years ago

I have this bug as well: Anki 2.1.44 (b2b3275f) Python 3.8.1 Qt 5.15.1 PyQt 5.15.1

smart-town commented 3 years ago

Maybe I find a way to fix it. @natfarleydev (I am not good at English, please don't laugh at me 😄 ) I also has this question, when I use nested list, for example:

1. item1
2. item2
    - a
    - b

It can not work correctly on my anki. My anki version:

2.1.44 (b2b3275f)⁩ Python 3.8.6 Qt 5.14.2 PyQt 5.14.2 add-on: 15061497

I found that field_text use \xa0 to indicate `(blank space), You can find it in *line37*:anki-auto-markdown/editor.py generateHtmlFromMarkdown() function, then I replace\xa0with `(blank space):

generated_html = markdown.markdown(
    field_plain.replace("\xa0", " ")
    extensions = [...]
)

After modified this place, I restarted anki, get it: image

natfarleydev commented 3 years ago

That's awesome! Would you be happy to make a pull request with those changes @smart-town?

smart-town commented 3 years ago

That's awesome! Would you be happy to make a pull request with those changes @smart-town?

Hi, I am not sure the condition that this bug recurrent. I am afraid of causing other question.(but the solution is so simple that may be has no effect).

natfarleydev commented 3 years ago

I can pick this up next time I have a spare afternoon, but if you'd feel comfortable giving it a go, it would be really helpful for me as my time is limited at the moment.

I'll review anything before it goes in so you don't need to worry about causing more problems 🙂

smart-town commented 3 years ago

@natfarleydev I have submitted a pull request, only one line of code 😅 .

natfarleydev commented 2 years ago

Thanks @smart-town , I hadn't realised it was just a single line (another great reason for PRs, code speaks louder than words). I haven't had a chance to test it yet but the code looks good and I can't see any problems it would cause (apart from possibly people using non breaking spaces on purpose, but then I'd argue markdown is the wrong tool for that).

I'll try and test this week and get a release out

natfarleydev commented 2 years ago

Change seems to work well, I'll try and release this holidays (my dev environment has been lost so I'll have to rebuild that before I can re-release)