Giter Site home page Giter Site logo

migaku-official / migaku-editor-addon Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 4.0 134 KB

Migaku Editor is an Anki add-on that makes it quicker and easier to edit cards while reviewing. If you have an issue please report it in the "Issues" tab. Reponses to issues can be slow on GitHub, for faster support consider joining our Discord server through our Patreon page.

License: GNU General Public License v3.0

Python 76.55% JavaScript 19.75% HTML 3.70%

migaku-editor-addon's People

Contributors

lucasmia avatar shanrauf avatar

Stargazers

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

Watchers

 avatar

migaku-editor-addon's Issues

Replacement issue with nested div tags in card templates

I am not sure if I brought this issue on because I tinkered with my card template, or what. However, I found that the text replacement fails if card fields are nested. That is, if div tags are nested, the regular expression fails to match them correctly.

This problem is not surprising, however, because regular expressions aren't actually capable of paren-balancing (extended regexes can, but it's messy). You need at least a stack-based solution, I think.

Since you have balanced tags it's really similar to a calculator. An outline of how to build the modified text would be:

  1. Check each character in the template (or word, whatever) and insert it unless it meets point 2 below.
  2. Finding an opening div tag means push the changed version (the one with the new JS) onto the stack plus a unique token, and insert the changed, unfinished version with this token instead of the field name we need.
  3. When you find a matching fieldname, find the div tag on the top of the stack, get its token, and find that token in the text you've already accumulated and replace it with the fieldname. Push the fieldname onto the stack. Insert the fieldname.
  4. When a closing div tag is found, pop the top two elements off the stack and insert them into the text along with the closing div tag.
  5. All other text is just inserted into the replacement text as normal.

If I understand the goal correctly, this solves the problem and shouldn't be too slow. Considering that the size of the template text is only maybe a thousand characters, searching character-wise shouldn't be an issue. It can maybe be improved by splitting the text on "<div", but I bet Python does a character-wise search anyway.

Image scaling feature

Hey,
first of all, great addon, it makes editing a whole lot easier.
But i wanted to ask if there is a way to turn off the "Quick Image Resizing" because it shuts off other addons which affect images?
Thanks for your help!

Templates as class attributes issue

Type:

  • bug
  • feature
  • enhancement
  • question

Environment:

  • OS: MacOS (but I imagine others as well)

Going to open a PR:

  • yes
  • no

Description:
Using templates as class attributes results in unexpected behaviour. For example, if we had a monolingual card indicator that was only visible when the card had the tag "jp-jp" then the relevant HTML might look like <span style="opacity: 0" class="{{Tags}}">JP-JP</span> with the CSS span[class*="jp-jp"] {opacity: 0.6 !important;}. With this bug, this code no longer functions, and an additional "> appears on the card.

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.