Coder Social home page Coder Social logo

shogi_addon_for_anki's People

Contributors

tokoharu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

timezombi

shogi_addon_for_anki's Issues

KIF issues with Anki 2.1

I'll preface this bug report with two caveats:

  1. 日本語を学ぶけど、生憎ここで十分じゃありません。
  2. This is probably an Anki 2.0 - 2.1 input field formatting problem.

I have a card template that just puts [kif][/kif] or [sfen][/sfen] around the raw contents of an anki field {{KIF}} or {{SFEN}} respectively. SFEN seems to work just fine - I haven't found any problems yet.

KIF on the other hand seems very fragile. Please consider the two following kifu, one of which is provided by you as a sample, the other of which is the first of a pack of 詰将棋 kifu.

1) Your Sample:

後手の持駒:飛二 角二 金二 銀四 桂四 香四 歩十八  
  9 8 7 6 5 4 3 2 1  
+---------------------------+  
| ・ ・ ・ ・v玉 ・ ・ ・ ・|一  
| ・ ・ ・ ・ ・ ・ ・ ・ ・|二  
| ・ ・ ・ ・ 金 ・ ・ ・ ・|三  
| ・ ・ ・ ・ ・ ・ ・ ・ ・|四  
| ・ ・ ・ ・ ・ ・ ・ ・ ・|五  
| ・ ・ ・ ・ ・ ・ ・ ・ ・|六  
| ・ ・ ・ ・ ・ ・ ・ ・ ・|七  
| ・ ・ ・ ・ ・ ・ ・ ・ ・|八  
| ・ ・ ・ ・ ・ ・ ・ ・ ・|九  
+---------------------------+  
先手の持駒:金  
先手:  
後手:  
  • If I copy this into the Anki field editor, it doesn't work. No board appears, and the 持ち駒 sections are empty. The final raw HTML contents of the field have the newlines removed:
後手の持駒:飛二 角二 金二 銀四 桂四 香四 歩十八 9 8 7 6 5 4 3 2 1 +---------------------------+ | ・ ・ ・ ・v玉 ・ ・ ・ ・|一 | ・ ・ ・ ・ ・ ・ ・ ・ ・|二 | ・ ・ ・ ・ 金 ・ ・ ・ ・|三 | ・ ・ ・ ・ ・ ・ ・ ・ ・|四 | ・ ・ ・ ・ ・ ・ ・ ・ ・|五 | ・ ・ ・ ・ ・ ・ ・ ・ ・|六 | ・ ・ ・ ・ ・ ・ ・ ・ ・|七 | ・ ・ ・ ・ ・ ・ ・ ・ ・|八 | ・ ・ ・ ・ ・ ・ ・ ・ ・|九 +---------------------------+ 先手の持駒:金 先手: 後手:  
  • If I copy this into the Raw HTML editor for the field (bring it up with CTRL+SHIFT+X), it still doesn't work. Same problem as above. The Raw HTML obviously still contains exactly what the sample text kifu contains.
  • If, however, I first copy it into the Raw HTML editor, then copy that into the Anki field editor as normal (first close and re-open the Raw HTML editor before copying again), it works! The final Raw HTML contents of the field also have no newlines, but are full of <div> formatting, which unfortunately seems to be significant for the way the plugin works:
<div>後手の持駒:飛二 角二 金二 銀四 桂四 香四 歩十八 </div> <div> 9 8 7 6 5 4 3 2 1 </div> <div>+---------------------------+ </div> <div>| ・ ・ ・ ・v玉 ・ ・ ・ ・|一 </div> <div>| ・ ・ ・ ・ ・ ・ ・ ・ ・|二 </div> <div>| ・ ・ ・ ・ 金 ・ ・ ・ ・|三 </div> <div>| ・ ・ ・ ・ ・ ・ ・ ・ ・|四 </div> <div>| ・ ・ ・ ・ ・ ・ ・ ・ ・|五 </div> <div>| ・ ・ ・ ・ ・ ・ ・ ・ ・|六 </div> <div>| ・ ・ ・ ・ ・ ・ ・ ・ ・|七 </div> <div>| ・ ・ ・ ・ ・ ・ ・ ・ ・|八 </div> <div>| ・ ・ ・ ・ ・ ・ ・ ・ ・|九 </div> <div>+---------------------------+ </div> <div>先手の持駒:金 </div> <div>先手:</div> <div>後手:</div>

2) My 詰将棋 kifu

# ----  Kifu for Windows V4.01β 棋譜ファイル  ----
# ファイル名:D:\b\temp\M2TOK141\KIFU\1t120600-1.kif
棋戦:1手詰
戦型:なし
手合割:平手  
後手の持駒:飛 角 金四 銀三 桂四 香三 歩十七 
  9 8 7 6 5 4 3 2 1
+---------------------------+
| ・ ・ ・ ・ ・ ・ ・ ・v香|一
| ・ ・ ・ ・ 飛 馬 ・ ・v玉|二
| ・ ・ ・ ・ ・ ・ ・v歩 ・|三
| ・ ・ ・ ・ ・ ・v銀 ・ ・|四
| ・ ・ ・ ・ ・ ・ ・ ・ ・|五
| ・ ・ ・ ・ ・ ・ ・ ・ ・|六
| ・ ・ ・ ・ ・ ・ ・ ・ ・|七
| ・ ・ ・ ・ ・ ・ ・ ・ ・|八
| ・ ・ ・ ・ ・ ・ ・ ・ ・|九
+---------------------------+
先手の持駒:なし
先手:大内延介
後手:最新詰将棋200選
手数----指手---------消費時間--
*作者:大内延介
*発表誌:最新詰将棋200選
   1 3一馬(42)   ( 0:00/00:00:00)
   2 中断         ( 0:00/00:00:00)
まで1手で中断

(the # comment lines don't seem significant)

  • copying into the normal field editor doesn't work, same as before
  • copying into the Raw HTML editor doesn't work, same as before
  • doing the double-copy trick (as above) doesn't work either, but also the plugin crashes with the following message:
Debug info:
Anki 2.1.15 (442df9d6) Python 3.8.1 Qt 5.14.1 PyQt 5.14.1
Platform: Linux
Flags: frz=False ao=True sv=2
Add-ons possibly involved: tokoharu_shogi

Caught exception:
  File "/usr/share/anki/aqt/browser.py", line 98, in data
    return self.columnData(index)
  File "/usr/share/anki/aqt/browser.py", line 238, in columnData
    return self.question(c)
  File "/usr/share/anki/aqt/browser.py", line 292, in question
    return htmlToTextLine(c.q(browser=True))
  File "/usr/share/anki/anki/cards.py", line 120, in q
    return self.css() + self._getQA(reload, browser)['q']
  File "/usr/share/anki/anki/cards.py", line 137, in _getQA
    self._qa = self.col._renderQA(data, *args)
  File "/usr/share/anki/anki/collection.py", line 591, in _renderQA
    d[type] = runFilter(
  File "/usr/share/anki/anki/hooks.py", line 39, in runFilter
    arg = func(arg, *args)
  File "/home/adam/.local/share/Anki2/addons21/tokoharu_shogi/__init__.py", line 328, in make_kif_table
    return kif_re.sub(insert_kif_table, txt)
  File "/home/adam/.local/share/Anki2/addons21/tokoharu_shogi/__init__.py", line 276, in insert_kif_table
    gote_str += get_mochi_kif(line)
  File "/home/adam/.local/share/Anki2/addons21/tokoharu_shogi/__init__.py", line 265, in get_mochi_kif
    ret += format_mochi(pdata[0], val)
<class 'IndexError'>: string index out of range

I have a large collection of 詰将棋 kifu files, and I was hoping to be able to create a deck by parsing out the initial board state as one Field (the question side), and the subsequent moves as another Field (the answer side), but it seems that this plugin doesn't use the kifu plaintext, and it also seems that there are some problems with Anki 2.1.

If you are still interested in maintaining this plugin, I would be very keen to hear back from you, and am willing to provide more details or test any changes as needed.

Anki 2.1.20+ problem

In Anki2.1.20+, following command cannot to be used (actually, this was deprecated command).

addHook("mungeQA", make_fen_table)

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.