Valid code
The part that contains the class name of the card type ("question" or "answer") is missing the closing double quotes after the class name:
\
AnkiDroid Version = 2.9alpha75
Android Version = 9
ACRA UUID = 1f29f610-893a-403f-83d5-25a26ba97fe0
Enter an [ x ] character to confirm the points below:
[ ] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
[ ] I have checked the manual and the FAQ and could not find a solution to my issue
[ ] I have searched for similar existing issues here and on the user forum
Glad to hear someone’s using this trick since we exposed the feature a while back.
Appears you are correct
You can get your first PR in here if you add an `\”” there to close the class attribute - that sort of editing is possible in github’s user interface just by hitting the pencil button on that page for the file. It will auto-fork and create a branch for you and walk you through creating the PR, you found it you should get the glory :-)
Yup, saw this and also similar issues with Basic2Model.java and BasicModel.java while was digging #4806 yesterday. Attached the patch:
diff --git a/api/src/main/java/com/ichi2/anki/api/Basic2Model.java b/api/src/main/java/com/ichi2/anki/api/Basic2Model.java
index 0b1d3386d86004e0a02f7051159a1f717520dbf1..a23061a79fa7c163805d20c7843f98a6a97f9b5c 100644
--- a/api/src/main/java/com/ichi2/anki/api/Basic2Model.java
+++ b/api/src/main/java/com/ichi2/anki/api/Basic2Model.java
@@ -9,6 +9,6 @@ class Basic2Model {
public static final String[] CARD_NAMES = {"Card 1", "Card 2"};
// Template for the question of each card
static final String[] QFMT = {"{{Front}}", "{{Back}}"};
- static final String[] AFMT = {"{{FrontSide}}\n\n<hr id=answer>\n\n{{Back}}",
- "{{FrontSide}}\n\n<hr id=answer>\n\n{{Front}}"};
+ static final String[] AFMT = {"{{FrontSide}}\n\n<hr id=\"answer\">\n\n{{Back}}",
+ "{{FrontSide}}\n\n<hr id=\"answer\">\n\n{{Front}}"};
}
diff --git a/api/src/main/java/com/ichi2/anki/api/BasicModel.java b/api/src/main/java/com/ichi2/anki/api/BasicModel.java
index 63cbb52e4a626f8d9fee6f798b59cbb8d5db7792..2065c13f6548a83ce024ede235ea4aaaae97d4a0 100644
--- a/api/src/main/java/com/ichi2/anki/api/BasicModel.java
+++ b/api/src/main/java/com/ichi2/anki/api/BasicModel.java
@@ -9,5 +9,5 @@ class BasicModel {
public static final String[] CARD_NAMES = {"Card 1"};
// Template for the question of each card
static final String[] QFMT = {"{{Front}}"};
- static final String[] AFMT = {"{{FrontSide}}\n\n<hr id=answer>\n\n{{Back}}"};
+ static final String[] AFMT = {"{{FrontSide}}\n\n<hr id=\"answer\">\n\n{{Back}}"};
}
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java
index d4815815a3fe275ec22c32627c84037817609afb..4697df1544733077aefc6e7a006ec8dcf7836cce 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java
@@ -123,10 +123,10 @@ public abstract class AbstractFlashcardViewer extends NavigationDrawerActivity {
public static final int DECK_OPTIONS = 1;
/** Constant for class attribute signaling answer */
- public static final String ANSWER_CLASS = "answer";
+ public static final String ANSWER_CLASS = "\"answer\"";
/** Constant for class attribute signaling question */
- public static final String QUESTION_CLASS = "question";
+ public static final String QUESTION_CLASS = "\"question\"";
/** Max size of the font for dynamic calculation of font size */
private static final int DYNAMIC_FONT_MAX_SIZE = 14;
@@ -2329,7 +2329,7 @@ public abstract class AbstractFlashcardViewer extends NavigationDrawerActivity {
*/
private static String enrichWithQADiv(String content, boolean isAnswer) {
StringBuilder sb = new StringBuilder();
- sb.append("<div class=\"");
+ sb.append("<div class=");
if (isAnswer) {
sb.append(ANSWER_CLASS);
} else {
May I (in a dignified way) beg and plead for you (or @Anthropos888 ) to submit that as a github PR? That’s the workflow for changes here - then we can review and integrate very easily. If that’s a pain I do understand, but it’ll be slower for me to get to it
Very good finds though, thank you for posting them - I had no idea
You can get your first PR in here if you add an `\”” there to close the class attribute - that sort of editing is possible in github’s user interface just by hitting the pencil button on that page for the file. It will auto-fork and create a branch for you and walk you through creating the PR, you found it you should get the glory :-)
Thanks! Hopefully that PR is OK?
Got the 2.9alpha77 update and the generated card.html looks good now. Thanks for the quick implementation!
@Anthropos888 you have now seen the inside of the sausage factory :-), welcome!