Anki Forums

Add Table [Official thread]

@ak47: I can’t really help with this. I would look at other add-ons or card type templates that offer multiple choice like functionality, e.g.

maybe make a new topic in the add-on or development category of this forum so that you get more visibility.

@ijgnd , Like I told you that I am myself a web developer. I can do this functionality myself once I get proper understanding of how Anki and it’s add-ons work. Since I have not contributed to an open source project like this I am finding it difficult to start. Just guide me on how to start and which all documentations to refer to save time.

You don’t really need any open source experience to start developing add-ons.
You can just duplicate the folder of an arbitrary add-on (within addons21) as a starting point for your own stuff.

Like @ijgnd said, Closet for Anki covers a broad range of functionality and its source code is a great reference for best practices of add-on development (also for the JavaScript part).

There’s also an official guide (explains the use of hooks, collection operations etc.): Introduction - Writing Anki Add-ons

And I consider AnkiWebView Inspector - AnkiWeb essential for my personal add-on development.

@ak47: Since I don’t really understand what you want from me there’s a good chance that you won’t like this link either: Hopefully there’s something useful for you. Some people said that found this collection useful.


When I create a table and then copy and paste it into another field so that I don’t have to retype all the headings, the table gets bigger. I know this is a minor thing, but when I have two variations of the same table on the same card, the tables aren’t the same size. Even the text isn’t the same size between the two tables, even though the styling part of the card template doesn’t contain anything that should change the size of the text. Any suggestions?


@Annapox: Anki is very flexible so a problem can be introduced in many different places. Do you see the review just when you are reviewing cards or do you also see this in the editor when you make a new note (or check it at the bottom of the browser)? If it’s just during reviews check your card styling in your card templates - there are some good youtube videos on this …

If it’s about the editor in the add/browser window: try without add-ons and check the font size you set for each field (that you see when you click the fields button in the upper left of the editor).

Ultimately you can check the html source code of both tables: in the editor put the cursor in a field and press ctrl+shift+x to see it (on macs it’s cmd+shift+x). Then compare the source code for both fields if there’s a difference. If there’s no difference it’s not about my add-on. Then at some place else different styling gets applie (most liekly cause for reviews it’s somewhere in the card templates).

The difference does also show up in the editor. I don’t see anything in the card styling or the editor settings that would cause the two tables to be different, but I did find a difference in the HTML code.

The original table starts with:

The copy starts with:

So now I know how to get all the tables looking the same, but any ideas how that would have happened in the first place? I haven’t messed with any of the code for the tables or for the add-on itself.

you didn’t post the html source code.

try this: cut a table from a field and paste it into it. Does this change the table? When you paste something into anki anki processes it which may slightly change how it looks.

ideally this shouldn’t happen so maybe there’s something in my add-on to fix. But it’s much easier for me if you show me html source code that leads to this problem.

Sorry, I did copy and paste it the code snippets that were different, but I forgot to use the “preformatted text” button. I’m having an off day, I guess. Let’s try this again. The original table starts with:

<table class="table_class_basic_full_width" style="font-size: 85%; width: 100%; border-collapse: collapse; border: 1px solid;">

When I copied and pasted the table into another field, that code changed into:

<table class="table_class_basic_full_width" style="width: 822px; border-collapse: collapse; border: 1px solid;">

So, I can fix it by changing the code so that it matches, but there’s still the question of why that change happens in the first place. For what it’s worth, if I copy and paste the copy of the table, the code of the new copy is identical to the code of the first copy, as far as I can tell.

I see. I’ll look into it in the coming weeks (when I’m less busy at work). In the meantime you could use my editor: paste raw unfiltered full html - AnkiWeb or if you don’t want more add-ons copy the html source from field a into the html source editor of field b - this avoids that anki processes (cleans) the input

Since ~2.1.20 when you copy and paste a table the styling seems to be removed by Anki fully. Annapox has a different problem: when pasting some styling is changed and not removed, e.g. the width is changed from relative to an absolute value. This reminds me of a problem I had with Custom Styles where css got changed to inline styling by chrome’s inserthtml. Maybe something similar goes on here.

The fact that coyping and pasting between fields removes stuff is not that unusual, e.g. only on MS Windows some hyperlinks made by another add-on got removed, see here.

Anyway the solution is the same: avoid the paste command and either copy the source code between fields or have a look at my editor: paste raw unfiltered full html - AnkiWeb.