├── .gitignore ├── README.md ├── anki-markdown ├── README.md ├── RELEASE_NOTES.md ├── doc │ ├── manual-conversion.gif │ ├── markdown-mode.gif │ ├── markdown-preview.gif │ └── md-tags-cards.png ├── src │ ├── __init__.py │ ├── a-md.css │ ├── a-md.js │ ├── batch.py │ ├── config.json │ ├── config.md │ ├── config.py │ ├── controller.py │ ├── converter.py │ ├── core.py │ ├── field_ctrl.py │ ├── html2text │ │ ├── __init__.py │ │ ├── cli.py │ │ ├── compat.py │ │ ├── config.py │ │ └── utils.py │ └── icons │ │ ├── markdown-2-ico.png │ │ ├── markdown-2.svg │ │ └── markdown-3.png └── tests │ ├── amd-test.html │ ├── anki-editor.html │ ├── anki_mocks_test.py │ ├── config.json │ ├── config_test.py │ └── converter_test.py ├── anki-web-browser └── README.md ├── build.py ├── buy-coffee.png ├── fill-the-blanks ├── README.md ├── RELEASE_NOTES.md ├── doc │ ├── FIll-the-blanks-starter.apkg │ ├── card-template.png │ ├── cloze-card.png │ ├── from-cloze-to-input.gif │ ├── intant-feedback.gif │ └── review-inputs.png ├── src │ ├── __init__.py │ ├── binding.py │ ├── config.json │ ├── config.md │ ├── config.py │ ├── fill-blanks.js │ └── handler.py └── tests │ ├── __init__.py │ ├── anki_mocks_test.py │ ├── config.json │ ├── fill-blanks-test.html │ └── handler_test.py ├── schedule-priority ├── README.md ├── RELEASE_NOTES.md ├── doc │ ├── modify-priority-editor.gif │ ├── modify-priority-review.gif │ └── schedule-priority-config.png ├── schedule-priority.py ├── src │ ├── __init__.py │ ├── config.json │ ├── config.md │ ├── controller.py │ ├── core.py │ ├── prioritizer.py │ ├── schedv3_interface.py │ └── uicontrib.py └── tests │ ├── __init__.py │ ├── anki_test.py │ └── prioritizer_test.py └── words-shuffler ├── README.md ├── RELEASE_NOTES.md ├── doc ├── ws-addon-editor.gif └── ws-addon-review.gif ├── src ├── __init__.py ├── config.json ├── config.md ├── config.py ├── controller.py ├── resources │ ├── atokenizer.css │ ├── atokenizer.js │ ├── dragula.min.css │ ├── dragula.min.js │ └── reload.png └── shuffler_handler.py └── tests ├── anki_mocks_test.py ├── config.json ├── handler_test.py └── tokenizer-test.html /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | .vscode/settings.json 106 | anki-web-browser/tests/meta.json 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # anki-plugins 2 | 3 | > This repository is aimed to share my addons for the Anki Desktop Application. 4 | > In general, they are simple/small python modules -------------------------------------------------------------------------------- /anki-markdown/README.md: -------------------------------------------------------------------------------- 1 | # Markdown Support 2 | 3 | > TLDR; Surround your content with `` to let it be processed as Markdown. No conversion needs to be done in the editor (you can if you want though). 4 | > Or use the context menu to convert it in-place 5 | 6 | > If you don't know Markdown, checkout below (in the end) 7 | 8 | **This add-on** makes it possible to process cards' content (or parts of it) as Markdown. 9 | While editing or adding cards, write it in plain text. No formatting is required in this view. 10 | Then, when reviewing the card, it is interpreted as markdown and converted to HTML. 11 | 12 | Other option is to convert the content in-place during the edition, either getting a clean text or producing HTML. 13 | These operations may also be executed in batch. 14 | 15 | ## Usage 16 | 17 | You need to identify the area(s) on the cards that the add-on should work on. 18 | This is done using a markup tag: ``. 19 | 20 | On the HTML code, put the tags `` and `` around the area to be processed. 21 | 22 | **Example:** 23 | 24 | {{Example}} 25 | 26 | This might be done either in the Card Type level (recommended) or in parts of a given card (in cards' edition). 27 | 28 | > Markdown-formatter won't process the entire card, only the delimited areas. 29 | 30 | The area being processed by this add-on will be shown with a purple left border. 31 | 32 | ### Format the entire card type 33 | 34 | This is done through Card Type Configuration. Thus, it's applied to all cards of that type. 35 | 36 | ![Card type config](doc/md-tags-cards.png) 37 | 38 | ### Card Edition 39 | 40 | In the editor there is a button *Markdown* to activate/deactivate the **Markdown mode**. 41 | When enabled this will *tell* Anki that the text being edited is a plain text and should not be *escaped*. Otherwise, Anki converts the text to HTML (For instance, line breaks become `
` tags). 42 | The default **shortcut** is *Ctrl+Shift+K* (may be changed in Configurations). 43 | 44 | This won't convert the Markdown to HTML yet! 45 | 46 | ![Modifying from editor](doc/markdown-mode.gif) 47 | 48 | While editing, it's also possible to check the Markdown being produced using the *Preview*: 49 | 50 | > From version 2.3 51 | 52 | ![Preview on the editor](doc/markdown-preview.gif) 53 | 54 | ### The conversion 55 | 56 | There are 2 modes to make the add-on convert the content: 57 | 58 | #### In runtime 59 | 60 | Just write the notes using plain text (with Markdown formatting, of course). 61 | Then, during the review, the areas surrounded by `` will be converted and shown as HTML (it won't be stored as HTML). 62 | 63 | #### In place 64 | 65 | In the editor, use the context menu (right click) to invoke the processing immediately. There are 2 options: 66 | 67 | * Convert to MD 68 | * Used to clean up existing formatting in the card, preparing it to be used as Markdown 69 | * Convert to HTML 70 | * Interprets the content as Markdown and produces HTML (replacing the content) 71 | * May be used if you'd like to edit as Markdown, but you prefer to store as HTML 72 | 73 | The other option on this menu is to wrap the selected content with ``. 74 | 75 | ![Convertion in place](doc/manual-conversion.gif) 76 | 77 | The default **shorcut** to show the menu is *Ctrl+Shift+M*. 78 | 79 | #### Pasting data 80 | 81 | > From version 2.2 82 | 83 | In the editor, if the Markdown mode is *On*, when pasting some data, it will be set as plain text. This prevents Anki default behavior (which converts the data to HTML). 84 | 85 | ### Batch 86 | 87 | It is possible to invoke the conversion for several notes at once. 88 | This is useful in cases like: 89 | 90 | * When you start using this add-on and need to clean up the HTML existing in your collection (Convert to MD) 91 | * When you use your cards on Anki Mobile and need them in HTML (Convert to HTML) 92 | 93 | The batch operation are available on: 94 | 95 | > *Browse* -> *Notes* Menu -> *Markdown Addon* 96 | 97 | > You need to select the cards you want to apply the conversion 98 | 99 | ## Configuration 100 | 101 | The following customization are available: 102 | 103 | * Shortcut Edit 104 | * In the editor, it used to activate/deactivate the Markdown mode 105 | * Shortcut Menu 106 | * In the editor, invokes the Markdown context menu 107 | * Show markdown button 108 | * Indicates whether the Markdown button should be shown or not 109 | * Enable preview 110 | * In the editor, should the preview be shown or not? 111 | * Disable Add-on Decoration 112 | * Won't add decoration like purple border, indication where the add-on is working 113 | 114 | > further old configurations were dropped 115 | 116 | > The shortcuts work only when the focus is into an input field 117 | 118 | ## Bugs / Suggestions / more... 119 | 120 | Please, feel free to make suggestions and open issues about possible bugs found. 121 | 122 | That and the source code are available on: [Github](https://github.com/ssricardo/anki-plugins/tree/master/anki-markdown) 123 | 124 | ## Updates 125 | 126 | > Check [RELEASE_NOTES]() 127 | 128 | ## About 129 | 130 | Add-on developed by *ssricardo*. 131 | Check out more of my add-ons on [https://github.com/ssricardo/anki-plugins]() 132 | 133 | ## Still learning about Markdown... 134 | 135 | Markdown is an easy way of formatting texts, based on a predefined syntax. 136 | It makes it simple and fast to write texts because the user doesn't need to worry about annoying details, like when you use tools like Word. 137 | It's like on WhatsApp, you write \_text_ and after sending it, its shown as _text_. 138 | 139 | Check out more information and the syntax on the following websites: 140 | 141 | * [markdownguide](https://www.markdownguide.org/) 142 | * [Syntax](https://www.markdownguide.org/basic-syntax/) 143 | * [commonmark.org](https://commonmark.org/help/) 144 | 145 | And many other websites... -------------------------------------------------------------------------------- /anki-markdown/RELEASE_NOTES.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | **3.2** | 23/02/2021 4 | 5 | * Add support for blockquote (starting line with `>`) 6 | * Make preview resizable 7 | * Make it compatible with upcoming changes on fill-the-blanks add-on 8 | * Fix bug to use its css styles on review 9 | 10 | **3.1** | 28/04/2020 11 | 12 | * Fix bug on editor 13 | * Add support for bold and italic shortcuts 14 | 15 | **3.0** | 18/03/2020 16 | 17 | * Make the addon work with >= Anki 2.1.20 18 | * Big change on the editor, improving plain text edition 19 | * Disable purple indicator 20 | * Related issue: #24 21 | 22 | **2.4** | 09/07/2019 23 | 24 | * Handle issue on timer for previewer 25 | * Related issue: #21 26 | 27 | **2.3** | 09/05/2019 28 | 29 | * Add feature: Preview 30 | * Improve how to handle pasting (on editor) 31 | * Other small adjustments 32 | 33 | **2.2** | 25/04/2019 34 | 35 | * Better handling of chars: `< > &` 36 | * Added handling for pasting data, when editing 37 | * Now, if the Markdown is On, the data will pasted as plain text 38 | * Refactor for using it along with other addons 39 | 40 | > More precisely, make it works with my new Addon: *Fill the blanks* 41 | 42 | **2.1** | 16/03/2019 43 | 44 | * Fix: Formating area was around everything, must be around parts only 45 | * Pre processing HTML escaped chars 46 | 47 | **2.0** | 26/02/2019 48 | 49 | * Large refactor 50 | * Added conversion from HTML to MD 51 | * Added options to execute the conversions immediately (in-place) (Either HTML to MD or MD to HTML) 52 | * Handles notes edition, preventing Anki from formatting the inputs as HTML 53 | * Added options to invoke the conversions as a batch operation (on Browser view) 54 | * Added visual demarcation to parts handled by this add on (left border) 55 | * Dropped the configurations *trim* and *replace-spaces* as they aren't necessary anymore 56 | 57 | **1.1** | 24/10/2018 58 | 59 | * Support for trim and replace-spaces configuration, both globally and locally 60 | * Config renamed: showMdButton -> show-md-button 61 | * There is no longer the limitation for code block, as trimmimg may is customizable 62 | 63 | **1.0** 64 | 65 | * Initial version 66 | * Interprets text surrounded by as Markdown and converts it to HTML 67 | -------------------------------------------------------------------------------- /anki-markdown/doc/manual-conversion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssricardo/anki-plugins/044a4894343f2af4c01ca6a4dc172458678cdee5/anki-markdown/doc/manual-conversion.gif -------------------------------------------------------------------------------- /anki-markdown/doc/markdown-mode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssricardo/anki-plugins/044a4894343f2af4c01ca6a4dc172458678cdee5/anki-markdown/doc/markdown-mode.gif -------------------------------------------------------------------------------- /anki-markdown/doc/markdown-preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssricardo/anki-plugins/044a4894343f2af4c01ca6a4dc172458678cdee5/anki-markdown/doc/markdown-preview.gif -------------------------------------------------------------------------------- /anki-markdown/doc/md-tags-cards.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssricardo/anki-plugins/044a4894343f2af4c01ca6a4dc172458678cdee5/anki-markdown/doc/md-tags-cards.png -------------------------------------------------------------------------------- /anki-markdown/src/__init__.py: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------- 2 | # Module for anki-markdown addon 3 | # ------------------------------------------------------------- 4 | 5 | __version__ = "3.2" 6 | 7 | try: 8 | from .controller import run 9 | run() 10 | except ImportError as ie: 11 | print(""" [WARNING] Anki-Markdown ::: It wasn\'t possible to resolve imports. 12 | Probably anki was not found, duo to: Running In test mode !!! """) 13 | 14 | print(ie) -------------------------------------------------------------------------------- /anki-markdown/src/a-md.css: -------------------------------------------------------------------------------- 1 | h1, h2, h3, h4 { 2 | font-weight: 400; 3 | } 4 | h1, h2, h3, h4, h5, p { 5 | margin-bottom: 10px; 6 | padding: 0; 7 | } 8 | h1 { 9 | font-size: 42px; 10 | } 11 | h2 { 12 | font-size: 32px; 13 | margin: 24px 0 6px; 14 | } 15 | h3 { 16 | font-size: 22px; 17 | } 18 | h4 { 19 | font-size: 20px; 20 | } 21 | h5 { 22 | font-size: 18px; 23 | } 24 | 25 | .amd blockquote { 26 | margin: 3px; 27 | padding-left: 5px; 28 | border-left: 3px solid orange; 29 | background-color: rgba(158, 157, 157, 0.3); 30 | } 31 | 32 | .amd code { 33 | font-family: Consolas, Monaco, Andale Mono, monospace; 34 | line-height: 1.2; 35 | font-size: 13px; 36 | } 37 | amd, .amd { 38 | border-left: 2px solid #7e08ed; 39 | padding-left: 5px; 40 | display: block; 41 | } 42 | 43 | pre.amd { 44 | margin: 0px; 45 | padding: 0; 46 | border-left: 2px solid #7e08ed; 47 | 48 | padding: 2px 10px; 49 | white-space: pre-wrap; 50 | } 51 | 52 | .amd textarea { 53 | resize: vertical; 54 | overflow: hidden; 55 | min-height: 50px; 56 | height: 80px; 57 | max-height: 500px; 58 | width: 98%; 59 | } 60 | 61 | .nightMode .amd textarea { 62 | color: #FFF; 63 | } 64 | 65 | .amd_edit_notice { 66 | float: right; 67 | color: orange; 68 | } 69 | 70 | .amd table { 71 | width: 100%; 72 | } 73 | 74 | .amd table th { 75 | border-bottom: 1px dashed; 76 | border-left: 1px solid; 77 | border-right: 1px solid; 78 | } 79 | 80 | .amd table td { 81 | border-right: 1px solid; 82 | } 83 | 84 | .amd table tr td:last-child { 85 | border-right: none; 86 | } 87 | 88 | /* Preview */ 89 | #prev_layout { 90 | border: 0; 91 | width: 100%; 92 | table-layout: fixed; 93 | } 94 | 95 | #prev_toggler { 96 | background-color: #777; 97 | width: 20px; 98 | text-align: center; 99 | line-height: 1.1; 100 | cursor: pointer; 101 | color: #FFF; 102 | vertical-align: middle; 103 | padding-top: 40px; 104 | max-width: 80px; 105 | } 106 | 107 | #fd_w_prev { 108 | vertical-align: top; 109 | } 110 | 111 | #fd_w_prev td { 112 | } 113 | 114 | #col_field { 115 | } 116 | 117 | #preview { 118 | width: 40%; 119 | padding-left: 10px; 120 | padding-top: 10px; 121 | overflow: auto; 122 | 123 | resize: horizontal; 124 | min-width: 80px; 125 | max-width: 800px; 126 | } 127 | 128 | #prev_layout .field { 129 | overflow: auto; 130 | } -------------------------------------------------------------------------------- /anki-markdown/src/a-md.js: -------------------------------------------------------------------------------- 1 | let mdNotice = '
Markdown ON
'; 2 | 3 | function pasteAmdContent(inputValue) { 4 | let focused = $(':focus'); 5 | if (! focused || focused == 'undefined') { 6 | return; 7 | } 8 | let selection = window.getSelection() 9 | if (focused.is('input') || focused.is('textarea')) { 10 | let newVal = (selection && selection != '') ? focused.val().replace(selection, inputValue) : focused.val() + inputValue; 11 | focused.val(newVal); 12 | } else { 13 | let newVal = (selection && selection != '') ? focused.text().replace(selection, inputValue) : focused.text() + inputValue; 14 | focused.text(newVal); 15 | } 16 | } 17 | 18 | function showMarkDownNotice() { 19 | let shownNotice = $('.amd_edit_notice').length; 20 | if (! shownNotice) { 21 | $('#fields').prepend(mdNotice); 22 | } 23 | } 24 | 25 | function convertToTextArea(originalField) { 26 | var attrs = { }; 27 | 28 | var name = originalField.attr('name'); 29 | var id = originalField.attr('id'); 30 | var text = originalField.text(); 31 | 32 | $("