Giter VIP home page Giter VIP logo

anki-markdown-notes's People

Contributors

alexcthompson avatar pradhyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

anki-markdown-notes's Issues

Export existing notes to markdown silently fails

Using Anki 2.0.52 and installing add-on using the ID through the Anki UI, I cannot get the existing notes exported using Tools > Export to Markdown Notes. The resulting file that is created is empty except for a level-1 heading with the name of the deck. (There is also a file called Default.md but I expected that to be empty because its the dummy deck that Anki provides before you create a deck of your own.)

Any chance you can point me in the right direction to fixing this? Not sure how to get to a debug console in Anki but if there is one available, I'm happy to provide the output that prints when I try to export to markdown...

Thanks!

Use file name as tag for all notes in a file

Having used this for a bit, I tend to leave out context in the questions in my markdown notes because of the file name and everything surrounding the questions but this gets confusing without tags in anki

Umlauts

Importing German words or Umlauts from Obsidian:

image

Results to this

image

ImportError: No module named glob

I installed the plugin through Anki's own specific menu. Since then, I receive the following error message each time I open Anki:

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
  File "aqt/addons.py", line 41, in loadAddons
  File "/home/andras/.local/share/Anki2/addons/Anki_Markdown_Notes.py", line 6, in <module>
    from glob import glob
ImportError: No module named glob

It has been already reported here: https://anki.tenderapp.com/discussions/add-ons/16903-error-with-markdown-addon

I checked, and I have glob2 installed:

>>> ~$ pip list | grep glob
glob2                              0.6

Neither the following console command yields any error:

from glob import glob

ASCII codec error when exporting notes to Markdown

Hi @Pradhyo - thanks for creating and maintaining this add on. I ran into a fail when trying to export my existing decks to Markdown. Here's the error:

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
  File "/Users/alexcthompson/Library/Application Support/Anki2/addons/anki-markdown.py", line 271, in exportNotesUI
    exportedDecks = exportAllNotes(NotesPath)
  File "/Users/alexcthompson/Library/Application Support/Anki2/addons/anki-markdown.py", line 238, in exportAllNotes
    writeNote(note)
  File "/Users/alexcthompson/Library/Application Support/Anki2/addons/anki-markdown.py", line 226, in writeNote
    deckFile.write("A: {}\n".format(note.fields[1].replace("<br>", "\n")))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 198-199: ordinal not in range(128)

I think we're dealing with a classic Python unicode problem here. My hunch, having done absolutely zero investigation is that L226 in anki-markdown.py, by creating a format string, is casting some unicode characters to utf-8 badly, creating this error. Using my Stackoverflow spidey sense, I wonder if this answer might resolve the issue.

Error when exporting hierarchical decks

Debug info:
Anki 2.1.33 (3f403040) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 10
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2022-01-31 11:46:14

Caught exception:
Traceback (most recent call last):
File "C:\Users\User\AppData\Roaming\Anki2\addons21\2141874715_init_.py", line 317, in exportNotesUI
exportedDecks = exportAllNotes(NotesPath)
File "C:\Users\User\AppData\Roaming\Anki2\addons21\2141874715_init_.py", line 279, in exportAllNotes
os.makedirs(deckFolder)
File "os.py", line 221, in makedirs
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:/Users/User/Documents/Obsidian/Vault/Notes\Notes\Default::Nested

I think what's going on is that nested decks are named "parent::deckname", but windows doesn't allow colons in filenames.
So when you set deckFolder to os.path.join(NotesPath, deck) where deck has double colons, everything is fine. But in the next line when you try to create a folder with that name, Windows forbids that and the error is thrown.

This is the exportAllNotes function that the bug is in:

def exportAllNotes(NotesPath):
    """
    Exports all notes to markdown files in a Notes folder in 'NotesPath'.
    Aborts if 'Notes' folder already exists.
    For deck 'DeckName', a folder 'DeckName' is created and all the notes
    in that deck are stored in 'DeckName.md' in that folder.
    """
    showInfo("Logs are located here - " + directory)
    NotesPath = os.path.join(NotesPath, "Notes")
    if os.path.exists(NotesPath):
        showInfo("Aborting - 'Notes' folder already exists")
        return

    os.makedirs(NotesPath)
    allDecks = mw.col.decks.allNames()
    for deck in allDecks:
        deckFolder = os.path.join(NotesPath, deck)
        os.makedirs(deckFolder)
        with open(os.path.join(deckFolder, deck + ".md"), "w") as deckFile:
            deckFile.write("# {} \n\n".format(deck))
            for cid in mw.col.findNotes("deck:" + deck):
                note = mw.col.getNote(cid)
                writeNote(note, deckFile)

    return allDecks`

Re-add notes with IDs in the markdown notes when importing

Consider the markdown notes as the source of truth.
Deleting a note from the Anki app was throwing an error when importing notes again because that note with the ID from the markdown comment was not found anymore. Fix this by adding these notes again with the same ID.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.