ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.78k stars 2.25k forks source link

[Bug] <style> tags in fields are ignored, which anki desktop and web do not #11073

Closed SimonHeimberg closed 2 years ago

SimonHeimberg commented 2 years ago
Reproduction Steps
  1. create a new card
  2. add this to a field shown on the front side (back side would also be fine):
<span class="bgRed">&nbsp;red&nbsp;</span>
<style>
  .nightMode .bgRed, .bgRed { background-color: red; }
</style>
  1. preview the card
Expected Result

the text "red" has red background, as it has on anki desktop and anki web.

Actual Result

the text "red" has no special background

(Use case: Trying to set the background color independent of the night mode. The colour seems to be inverted in ankidroid only, the hint is in anki manual, so it might not work in many ways.)

Debug info

AnkDroid Version = 2.15.6

Android Version = 9

Webview User Agent = Mozilla/5.0 (Linux; Android 9; GT-I9595 ...

(More info on demand, since I report the error on a desktop device.)

Research

Enter an [x] character to confirm the points below:

david-allison commented 2 years ago

Edit the card template and add .night_mode {} to disable auto-night mode inversion

The HTML should work. Have you checked the HTML inspector?

SimonHeimberg commented 2 years ago

By looking at "card.html" I have seen that all the newlines inside the style attribute are replaced by a <br> tag. A style tag with <br> inside is invalid of course. It works when I delete all newlines in <style>. Is this an effect of the setting to replace newlines? I understood it only the other way around. :-/

Thank you for the hint with .night_mode. I will try it.

So thank you very much. It is not an issue.

david-allison commented 2 years ago

@SimonHeimberg

To confirm: is there anything actionable here that I can help with?

We have plans to both swap out the editors for a visual editor, and before then, move the 'newline' setting inside the Note Editor.

github-actions[bot] commented 2 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] commented 2 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] commented 2 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically