AnkiDroid messed up the table

In the Version ⁨2.1.55 (f38c4e2f)⁩,When I opened a note including a table,I found it become mess.It is really a terrible thing.The table has wasted nearly an hour.I guess it is caused by AnkiDroid.It usually displays table in a wrong way.
Luckily,I restored the table with backup.
GIF 12-17-2022 12-20-03 AM
GIF 12-17-2022 12-03-15 AM
First gif is the note including broken table.Second gif is the recovered note.

I have identified the cause of the error.The cause is really the AnkiDroid.AnkiDroid messed the table and uploaded to AnkiDeskTop.This picture is the note just recovered in AnkiDroid.

Am I correct in guessing that you opened the note for editing in AnkiDroid? If so, I have run into this before. For me it was newlines in the HTML (some desktop Anki addons inserts “prettified” HTML into the note, i.e. with \n). The problem arises when you open a note for editing in AnkiDroid - it then converts any <br> to \n and on save it converts all \n to <br> leading to added <br>'s where they shouldn’t be resulting in weird rendering. My solution is to strip all \n from the notes (with search and replace - caveat, if you have notes that have <pre> tags those will possible have \n’s that shouldn’t be stripped).

Thank you for your help.I have found there are no \n’s in my note,And my main problem is about “AnkiDroid corrupting my table format”

I explain badly, \n is a control character that makes a newline. When rendering HTML \n is as space ( ) inside tags (there are exceptions) and not at all between tags. To create a newline in HTML the <br> tag is used. Your screenshot of the source has a lot of newlines:
image

As long as they are \n the card will display correctly, but if you open the note for editing in AnkiDroid all <br> tags will be converted to \n (so now you have the original \n plus the \n from the converted <br>'s). When saving all \n are converted to <br> leading to <br>'s where there was previously \n, including in places there shouldn’t be any <br>'s. Like between </td> (end of a table cell) and <td> start of a new one, i.e.:
<td>some</td>
<td>thing</td>

turns into
<td>some</td><br><td>thing</td>
Which results in weird rendering.

However if you are not opening the note for editing in AnkiDroid the above is not the cause of your problem, I merely mention this because I have personally run into the problem above earlier (before I stripped all my notes of \n).

3 Likes

You are absolutely right.Thank you very much again.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.