Open hssm opened 9 years ago
This problem has caused me a lot of unnecessary work as well. The Anki Windows version
handles HTML nicely, so I have to switch frequently and correct mistakes Ankidroid
introduced. I would appreciate if suggestion 2 would not be necessary.
Reported by tobias.vornholt@online.de
on 2015-01-26 20:44:23
This isn't a problem for most users because they include their formatting in the card
template rather than the fields themselves. I strongly suggest you do the same as this
may not get fixed for a while unfortuantely
Reported by perceptualchaos2
on 2015-01-27 00:07:38
I do that for basic formatting of course, but I´m afraid that doesn´t make much sense
when it comes to structuring longer cards with list etc. So I hope someone will tackle
this problem one day...
Reported by tobias.vornholt@online.de
on 2015-01-28 22:59:28
I agree that an edit-save cycle with no actual changes should not modify the content.
Reported by nicolas.raoul
on 2015-04-21 06:48:44
Accepted
I am having issues with this too, even editing tags to the card will trigger this behaviour.
I think users that care more about mark-up of the cards and e.g. use more lists (dl
tags and nested lists) run into this issue.
Reported by emil.rehnberg
on 2015-06-18 05:53:41
I have run into the same issues with automatic <br />
tags being entered when editing my cards. I would prefer if these did not generate when saving my cards as well. Has anyone looked into this bug as of recent?
I have this problem as well. Not being able to edit a card from my phone without rendering it unreadable is a big pain. Anyone dealing with this would be a hero.
I think the problem wont be solved until AnkiDroid supports HTML rendering when editing fields which would bring it inline with the desktop version.
This is causing quite a lot of extra work to me as well, would be great to have this fixed.
same issue here, two times I tried to correct a card on my phone and two times i had to fix it on desktop later. Learning to never edit on the phone, it's just not worth it.
Tip: Ctrl+Shift+X in the card browser opens raw HTML so you can find-replace all <br>
with nothing.
Same issue here.
Updating a note in AnkiDroid inserts six additional <br>
tags which messes with the template.
The only way to see and fix these tags is to edit the card in the desktop client.
It would indeed be great to "have this fixed" but no one has proposed a fix yet - we would welcome a fix for it https://github.com/ankidroid/Anki-Android/wiki/Contributing
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
shoo, shoo, stupid bot. still broken
@MightyPork you might like the preview of the visual editor: https://github.com/ankidroid/Anki-Android/issues/1377#issuecomment-616778637
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
Oh my god! This bug is driving me crazy! It's unfathomable that this bug was reported 5 years ago and still existing in late 2020
@fireheart2008 we would love to see it fixed! Do you have a solution you could propose?
Round 2 - let's add a preference. This should be viable now a user can add a custom toolbar button for <br/>
Was this supposed to be fixed on 2.14? I'm still getting it on 2.15.4, in some situations, as I reported here.
Have you tried the new preference mentioned here? https://github.com/ankidroid/Anki-Android/pull/7692
I thought I had to have it on. I haven't read correctly, sorry. Now, I turned it off and everything is perfect. Thanks!
NINE YEAR PERSISTENT BUG! It's 2024 and I am still getting this bug in a HUGE way. Edited a note with a table, it generated a number of line breaks <BR>
possibly equivalent to the number of rows in the table. You can't edit the HTML in Ankidroid directly so I had to fix it on desktop. For some reason after multiple syncs, I can't fix the note. Big headache and obviously a big problem, but I have no coding experience and am unlikely to be able to contribute to solving it.
@david-allison, as the other user mentioned, this bug still persists.
Turning off the option added in https://github.com/ankidroid/Anki-Android/pull/7692 may solve it. But, this is not a good solution for most people because this would be moving a step away from a WYSIWYG editor (because all the <br> tags are visible).
Also, I think that the title of the preference is misleading. I think that it should be "Replace HTML with newlines" because it replaces <br> tags with newlines when enabled.
Desktop:
AnkiDroid: (displays incorrectly)
After syncing to Desktop without making any edit to the note on AnkiDroid, no change happens in the HTML.
But after making a small edit
The linebreak in the HTML gets replaced by a <br> tag.
Turning off the option added in https://github.com/ankidroid/Anki-Android/pull/7692 solves the issue in the sense that the HTML is no longer altered after editing the card in AnkiDroid. However, the card still displays incorrectly on AnkiDroid (same as the second image above). Also, as mentioned above, it is a suboptimal solution because it takes the note editor one step away from a WYSIWYG editor.
@BrayanDSO, please reopen this because the issue is not fixed yet, as I have demonstrated above.
I think I have encountered the same bug - or more like logic issue - and reported it on the Anki forum at:
https://forums.ankiweb.net/t/bug-report-newlines-duplicated-within-fields/40884
Newlines input into AnkiDroid fields are being converted to <br>
. This is in the file:
AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/NoteService.kt
Specifically in the function convertToHtmlNewline()
. The argument replaceNewlines
appears be set to true
. So all newlines in fields are converted to <br>
.
For reference, the code is:
/**
* @param replaceNewlines Converts [FieldEditText.NEW_LINE] to HTML linebreaks
*/
@VisibleForTesting
@CheckResult
fun getFieldsAsBundleForPreview(editFields: List<NoteField?>?, replaceNewlines: Boolean): Bundle {
val fields = Bundle()
// Save the content of all the note fields. We use the field's ord as the key to
// easily map the fields correctly later.
if (editFields == null) {
return fields
}
for (e in editFields) {
if (e?.fieldText == null) {
continue
}
val fieldValue = convertToHtmlNewline(e.fieldText!!, replaceNewlines)
fields.putString(e.ord.toString(), fieldValue)
}
return fields
}
fun convertToHtmlNewline(fieldData: String, replaceNewlines: Boolean): String {
return if (!replaceNewlines) {
fieldData
} else {
fieldData.replace(FieldEditText.NEW_LINE, "<br>")
}
}
This is being called from:
AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt
The code is:
private fun shouldReplaceNewlines(): Boolean {
return AnkiDroidApp.instance.sharedPrefs()
.getBoolean(PREF_NOTE_EDITOR_NEWLINE_REPLACE, true)
}
Looking through the interface, I found this option buried under:
Settings -> Advanced -> Workarounds -> Replace newlines with HTML
The text of this option is:
In the Note Editor, convert any instances of <br> to newlines when editing a card
Turing this off fixes the problem! But the logic seems reversed, as newlines are instead being converted to <br>
and vice versa.
As a solution, could this option please be turned off by default? Having this option on by defaut is frighteningly confusing. And maybe the text of the option clarified by changing to:
In the Note Editor, convert all newlines to be stored internally within the card as <br> (HTML line breaks)
Originally reported on Google Code with ID 2408
Reported by
post@johannesrohrer.de
on 2014-11-17 11:56:10