Ankidroid edit for newline

The edit for newline function only works when I edit the card for the first time. When I import a deck I have to manually edit, then finish editing a card for the newlines to work. How do I automatically get all the <“br”> to become new lines?

If you’re importing files like .txt or .csv, I think the import window’s “Allow HTML in fields” toggle is what you’re looking for. Here’s a link to a brief Anki manual section: link.

Examples:

No HTML in fields
image

HTML in fields
image

Are you importing in that way above, or are you importing actual package files that end with .apkg?

If you’re having issues with .apkg, it’s likely that those decks are affected in a way that requires more effort to fix.

Yes I am importing in apkg

Is Settings > Advanced > Replace newlines with HTML on or off?

1 Like

It’s on. I’m not sure if I had it on when I imported it though. When I edit and go back without it enabled it won’t generate newlines.

Just in case this is helpful, that feature is about the editor. It displays all <br> tags in the editor as newlines, and saving a note with that feature turned on converts all newlines to <br> tags. This feature was confusing for me at first, so BrayanDSO, one of the devs clarified it that way.

Will batch editing with a plugin work?

Are you only using AnkiDroid? I’m asking since you found an AnkiDroid setting.

Just in case: under Settings -> About, what version do you see for AnkiDroid? You should see 2.18.3 if you installed through Google Play.

Can you somehow show us what the issue looks like?


I’ve created an example, but I’m on desktop Anki. Please let me know if it’s what you’re dealing with. It’d be convenient if this was the problem, but I don’t think it is.

Example:

  1. This note’s {{meaning}} field contains <br> instead of a newline.
    image

  2. After pressing CTRL-SHIFT-x or pressing the < > button on the right side, we can see the HTML:
    image

  3. After pressing CTRL-ALT-f or Notes -> Find and Replace to bring up find and replace, filling the text fields with &lt;br&gt; and <br>, selecting the meaning field, and making sure all boxes are checked, we’re ready to submit a fix:
    image

  4. After pressing OK:
    image


If this is somehow conveniently your issue, you can select all affected cards and do these steps.

If it’s conveniently your issue but you inconveniently can’t edit like this, I can help (but it may be a while depending on IRL timing).

1 Like

New card


Editor (didn’t edit anything)

When I saved and left the editor

2 Likes

I have a laptop, but it is currently being repaired so I don’t have access to it for the time being…

As I said the newlines are being converted to HTML tags as you save the card. I once heard from a developer that you can use <pre> attribute for such cases. In what way I am not sure though. I showed him what I’m facing and he just mentioned <pre>.

People with coding knowledge can probably help you better. I just mentioned all I knew. I hope you solve your issue eventually.

Thank you, that makes it much more clear!


Where are you seeing the first and last images? In the browser list, previewing a card, or something else?


I think @sorata’s correct, but I want to believe this is something we can fix. It’d be nice if we could bulk edit like in my example above. In order to do that, we have to know what the HTML of the note is.

When you turn this setting off, what do you see?


Is this a public deck that you can give a link to? I’d like to look at it from my end as well.

2 Likes

This is setting in AnkiDroid, the semi-official Anki client for Android. Am I missing something? It seemed to me you are misunderstanding it to be a deck.

1 Like

Yes, I understand it’s a setting. But I also don’t know / understand everything that it does, and so I want to know what it’s doing and not doing. That requires seeing more.

The easiest way to achieve that is using the same deck on my end rather than trying to guess at how to initially create the issue.

To be clear: I have AnkiDroid to test with.

2 Likes
  1. Make sure that setting is turned off.
  2. Create a card with newlines and save. You will get a card without any new lines.
  3. Turn that setting on.
  4. Open the card in editor.
  5. Save it. Now the newlines appear. (because they were converted to HTML tags.)
2 Likes

Thank you!

I created it on my end with my phone then synced to my desktop for editing.

This bulk edit works on my end:
image

I confirmed that toggling that setting in my phone, editing, and saving produces the same result.

The HTML form

zzz





zzz

becomes

zzz<br><br><br><br><br><br>zzz

That doesn’t fix their situation directly because they don’t have their laptop.

2 Likes

No matter what option you choose, make sure to create a backup (Anki manual link). On AnkiDroid, that’d mean doing a sync AND exporting. Exporting safeguards against accidental syncs in the wrong direction.

You can export via the ⋮ next to sync → Export… → Export format: .colpkg and Include media → OK → choose a directory → save.


If I’m understanding correctly, it looks like you’ll have an easy fix when you get your laptop back. See my previous comment for the fix.

If it can’t wait until then, I recommend using someone else’s computer for the quick edit if you can. That way you know nothing else changed.

If those options don’t work, I can help during the week (or someone else can). I have work soon, so it’d be tomorrow. Whoever helps will need to have a file and know what you want fixed.

4 Likes

My heartfelt thanks to everyone! The problem has been fixed.

2 Likes

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