Giter VIP home page Giter VIP logo

Comments (2)

cayennes avatar cayennes commented on August 10, 2024

Thanks! I hadn't realized this would be useful, but since you do it's likely others will as well. I'll add this later this week when I catch up on some addon maintenance.

  • Cayenne

On Dec 19, 2012, at 6:16 AM, shufps [email protected] wrote:

Hi,

I'm not learning kanji alone but only in vocabulary context. For my learning strategy it's a problem to ristrict the kanji colorizer on a single kanji character.

Here is a small patch which removes the restriction:

kanji_colorizer.py:

102c107

< def kanjiToAdd(note, currentFieldIndex=None):

def addKanji(note, flag=False, currentFieldIndex=None):
104,105c109
< Determines whether and what kanji to add a diagram for, given a note

< and possibly the index of a field that was edited

Checks to see if a kanji should be added, and adds it if so.

108c112,113

< return None

    return flag

112,113c117,118
< return None

< # check that srcField contains a single character

        return None    

115,119d119
< if not srcTxt:
< return None
< if not len(srcTxt) == 1:
< return None
< return srcTxt
121,133c121,133
< def addKanji(note, flag=False, currentFieldIndex=None):
< '''
< Checks to see if a kanji should be added, and adds it if so.
< '''
< character = kanjiToAdd(note, currentFieldIndex)
< if character == None:
< return flag
< # write to file; anki works in the media directory by default
< filename = kc.get_character_filename(character)
< with open(filename,'w') as file:
< file.write(kc.get_colored_svg(character))
< mw.col.media.addFile(os.path.abspath(filename))

< note[dstField] = '' % filename

dst=''
for character in unicode(srcTxt):
    # if ord(ch) < 19968: # only add kanjis
        # continue

    # write to file; anki works in the media directory by default
    filename = kc.get_character_filename(character)
    with open(filename,'w') as file:
        file.write(kc.get_colored_svg(character))
        mw.col.media.addFile(os.path.abspath(filename))
        dst+='<img src="%s">' % filename

note[dstField] = dst


Reply to this email directly or view it on GitHub.

from kanji-colorize.

cayennes avatar cayennes commented on August 10, 2024

Pull request merged a while ago

from kanji-colorize.

Related Issues (20)

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.