Giter VIP home page Giter VIP logo

anki-auto-markdown's Introduction

Auto Markdown

Source for the Auto Markdown Anki add-on.

To-do

Better implementation of fields.py

Current code is incompatible with other add-ons.

Possible Features

Convert-all to Markdown button

Have convert-all-to and convert-all-from buttons to allow easier adoptation and prevent lock-in.

Field should be auto markdown by convention

Allow setting of custom field name suffix, e.g. "mkd", to indicate that the field should be auto markdown.

anki-auto-markdown's People

Contributors

corrit-gshiel avatar gregorrr avatar jansurft 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  avatar

Watchers

 avatar  avatar  avatar

anki-auto-markdown's Issues

Throwing Error

When I tap the icon to enabled it I get the following error. I'm on Apple Silicone M1.

Caught exception:
Traceback (most recent call last):
File "aqt.webview", line 568, in handler
File "/Users/asceticcode/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 129, in
lambda field_text : onInnerTextAvailable(field_html, field_text))
File "/Users/asceticcode/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 139, in onInnerTextAvailable
updated_field_html = generateHtmlFromMarkdown(field_text, field_html)
File "/Users/asceticcode/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 53, in generateHtmlFromMarkdown
encoded_field_html = base64.b64encode(field_html.encode('utf-8')).decode() # needs to be string
AttributeError: 'NoneType' object has no attribute 'encode'

Can't insert picture

I wonder if picture is supported? Neither ![name](some.png) nor attach picture (F3) works. Thanks.

Issue after adding a card

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.
Debug info:
Anki 2.1.12 (eef86bf3) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.14.5
Flags: frz=True ao=True sv=2
Add-ons possibly involved: Auto Markdown, Search in Add Card Dialog, Frozen Fields

Caught exception:
File "aqt/webview.py", line 27, in cmd
File "aqt/webview.py", line 85, in _onCmd
File "aqt/webview.py", line 363, in _onBridgeCmd
File "", line 2, in myOnBridgeCmd
File "anki/hooks.py", line 74, in decorator_wrapper
File "anki/hooks.py", line 71, in repl
File "/Users/yilunzhang/Library/Application Support/Anki2/addons21/516643804/main.py", line 212, in onBridge
return _old(self, str)
File "/Users/yilunzhang/Library/Application Support/Anki2/addons21/1781298089/init.py", line 317, in myOnBridgeCmd
oldOnBridge(self, cmd)
File "aqt/editor.py", line 286, in onBridgeCmd
File "anki/hooks.py", line 29, in runHook
File "/Users/yilunzhang/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 158, in editFocusGainedHook
editor_instance.web.eval("""document.getElementById('f%s').innerHTML = %s;""" % (field_id, json.dumps(md)))
<class 'AttributeError'>: 'NoneType' object has no attribute 'eval'

Provide an easy option to change the pygments style

Hi there,

there are a lot of styles in ~\AppData\Roaming\Anki2\addons21\1030875226\pygments\styles and I don't know how to change from the default style to one of those.

I was only able to find out that you can remove the line numbers by commenting out the linese after CSSFILE_TEMPLATE = '''\ in the file ~\AppData\Roaming\Anki2\addons21\1030875226\pygments\formatters\html.py

/* td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } */

I'm closing this because I forgot to look into the Config in the Add-ons menu in Anki, where it was explained perfectly 😃

Code block font is wired on Catalina

On my clean install Catalina and Anki, the code block font is wired.
But on the web and mobile app, the code block font is normal.
Screen Shot 2019-10-12 at 01 27 19

Please help me to fix this bug.
Thanks a lot!

Preserve Line-breaks

It would been great if line breaks are preserved from original without having to add double-space or a <br> tag explicitly.

Example :

Hello
World

Gives

Hello
World

without having to add <br> or double-space or anything like :

Hello<br>
World

I believe this is how it was done in Power Format Addon and I was used to that. Is there a way to tweak the addon to allow for this ?
Thanks!

Anki Error: Caught exception

Anki Error

An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.29 (bbff62bf) Python 3.8.1 Qt 5.15.0 PyQt 5.15.0
Platform: Linux
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2020-08-14 12:40:27
Add-ons possibly involved: ⁨Auto Markdown⁩

Caught exception:
Traceback (most recent call last):
  File "aqt/webview.py", line 490, in handler
  File "aqt/editor.py", line 479, in <lambda>
  File "aqt/editor.py", line 345, in _onFields
  File "/home/nikhil/.local/share/Anki2/addons21/1030875226/fields.py", line 18, in fieldDialog__init__
    self.model = note.model()
AttributeError: 'dict' object has no attribute 'model'

Error in Anki 2.1.44 when converting from Markdown

In the latest version of Anki (2.1.44) the following error occurs when I create a card using markdown syntax and press the "Convert to/from Markdown" button.
Looking at the error message I assume it has to do with the version update causing an incompatibility with the base64 package.

Anki 2.1.44 (b2b3275f) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.16
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-06-11 12:30:15
Add-ons possibly involved: ⁨Auto Markdown⁩

Caught exception:
Traceback (most recent call last):
  File "aqt/webview.py", line 526, in handler
  File "/Users/xxx/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 129, in <lambda>
    lambda field_text : onInnerTextAvailable(field_html, field_text))
  File "/Users/xxx/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 139, in onInnerTextAvailable
    updated_field_html = generateHtmlFromMarkdown(field_text, field_html)
  File "/Users/xxx/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 53, in generateHtmlFromMarkdown
    encoded_field_html = base64.b64encode(field_html.encode('utf-8')).decode() # needs to be string
AttributeError: 'NoneType' object has no attribute 'encode'

The add-ons doesn't supprt newline when the code very long?

e.g.
mysql:yeyztest 22:35:39>>insert into fk_test_2 values (3,3);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (yeyztest.fk_test_2, CONSTRAINT fk_test_2_ibfk_1 FOREIGN KEY (uid) REFERENCES fk_test_1 (id))
20200315010552

Exception with Cyrillic characters in URL

Throws an exception when attempting to add URL's containing Russian letters. For example

https://en.wiktionary.org/wiki/выпускаться#Russian

throws this exception:

Error 
An error occurred. Please start Anki...blah blah blah
Debug info:
Anki 2.1.15 (442df9d6) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.14.6
Flags: frz=True ao=True sv=2
Add-ons possibly involved: Auto Markdown, Frozen Fields
Caught exception:
  File "aqt/webview.py", line 27, in cmd
  File "aqt/webview.py", line 87, in _onCmd
  File "aqt/webview.py", line 368, in _onBridgeCmd
  File "<decorator-gen-58>", line 2, in onBridgeCmd
  File "anki/hooks.py", line 74, in decorator_wrapper
  File "anki/hooks.py", line 71, in repl
  File "/Users/alan/Library/Application Support/Anki2/addons21/516643804/main.py", line 212, in onBridge
    return _old(self, str)
  File "aqt/editor.py", line 273, in onBridgeCmd
  File "anki/hooks.py", line 39, in runFilter
  File "/Users/alan/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 228, in editFocusLostFilter
    isGenerated = fieldIsGeneratedHtml(field_html)
  File "/Users/alan/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 78, in fieldIsGeneratedHtml
    tree = BeautifulSoup(field_html, 'html.parser')
  File "bs4/__init__.py", line 274, in __init__
  File "bs4/__init__.py", line 336, in _check_markup_is_url
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/warnings.py", line 101, in _showwarnmsg
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/warnings.py", line 30, in _showwarnmsg_impl
  File "aqt/errors.py", line 41, in write
<class 'UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 104-113: ordinal not in range(128)

Issue with converting to markdown

When both fields are on using automatic markdown it looks like it's not saved appropriately. One of the fields are shown non-markdown when you try to preview the result.

Code highlighting seems to be broken after latest update 20190613

Hi there,

Problem

I've updated the Add-on and I'm not getting line numbers and syntax highlighting anymore.

Behavior to reproduce

  • Add a new note and enter (it's highlighted in GitHub, of course you need C++ and around)
#include <iostream>
int main()
{
  return 0
}
  • Toggle Markdown (ctrl + m)

Expected

Syntax highlighting like above

Observed

No syntax highlighting and curiously even no line numbering

Comments

I was just trying to put in a different style schema and disable the line numbering when it stopped working as expected. Other markdown features are still working.

Steps I've taken to find out what's the issue

  • I've downloaded the before latest version 20190430-auto_markdown.zip and found out, that syntax highlighting worked as expected

Auto markdown crashes sometimes

Anki 2.1.13 (3ba55990) Python 3.6.1 Qt 5.9.7 PyQt 5.9
Platform: Mac 10.11.6
Flags: frz=True ao=True sv=1
Add-ons possibly involved: Auto Markdown

Caught exception:
  File "aqt/webview.py", line 27, in cmd
  File "aqt/webview.py", line 87, in _onCmd
  File "aqt/webview.py", line 368, in _onBridgeCmd
  File "aqt/editor.py", line 288, in onBridgeCmd
  File "/Users/jonathan/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 221, in onMarkdownToggle
    editor_instance.web.evalWithCallback("document.getElementById('f%s').innerHTML" % (field_id), onHtmlAvailable)
<class 'AttributeError'>: 'NoneType' object has no attribute 'evalWithCallback'

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.