Anki Forums

What constitutes a valid field name? (Old templates broken)

From AnkiDroid Bug#9297 it seems like AnkiDesktop stopped accepting field names with spaces in between letters somewhere between version 2.1.13 and 2.1.44 (Based on the changelog, I suspect it’s 2.1.20). More specifically, AnkiDesktop now fails to recognise {{Definition: 大辞泉}} instead believing it to be a replacement for the non-existing field 大辞泉 thus failing to render anything.

After reading all changelogs after 2.1.13, reading the doc paged linked in 2.1.20’s changelog and reconsulting the regular template documentation¹, I cannot find any mention of spaces in the middle of a field being illegal or any other reason why Definition: 大辞泉 would be an invalid field name. On the contrary actually, the doc¹ even uses names with spaces {{Field 1}} and {{Field 2}} as examples.
It is ofc possible I missed something since it was a fair bit to read through `^^

It would be awesome if someone could clarify whether this specific breaking change was intentional and what exactly constitutes a valid field name.
If disallowing spaces inside field names was indeed intentional, I’m suggesting to update the documentation to use different examples and to also include a definition of valid field names in the docs.


¹: docs.ankiweb . net/templates/fields.html (I’m not allowed to use three links directly …)

Colons have a special meaning in field replacements, so they are no longer permitted in field names. Removing the colon from the field name and template should resolve the issue.

1 Like

Thanks! So it was the colon and not the space.

To come back to “what is a valid field name”, is it correct that everything which satisfies the following is a valid field name (and likely not break in the future)?:

  • must start with a non-whitespace character which also isn’t #, / or ^
    (For future compatibility perhaps best start with a non-ASCII-, ASCII-letter- or ASCII-number-glyph)
  • must end with a non-whitespace character
  • must not contain a colon : anywhere

Imho it would be good to add something like this to the docs, so it’s easier to find such errors and to minimise field names breaking with updates.

Recent Anki versions will warn you if you use a character that is not permitted when renaming or adding a field.