Formatting a Field

Nick's Avatar


19 Apr, 2013 12:44 AM

Hi all,

I was attempting to make some new card templates, and I noticed that HTML formatting (bold, italic, etc...) doesn't apply to fields. For example, if I wanted to make a card like:

Describe and write the equation for {{Law}}

< i>{{Definition}}</ i>
< b>{{Equation}}</ b>

the HTML formatting would not be seen, because the contents of the fields remains unaltered. (Note: the cards I am trying to make are more complicated, so the aesthetics are a little more important than in the simplified example I gave)

I would be perfectly content to have the entire field auto-formatted (e.g. anything typed into the "Definition" field ALWAYS comes out with italicized formatting), though it wouldn't be quite as nice as being able to format in the card template...but I cannot see how to do this either.

Any tips/workarounds? A quick Google search suggested that there might be a way to include an unformatted field (they implied that {{{Field}}} would work, but trial and error indicates otherwise). This would really help with my card creation!!

  1. Support Staff 1 Posted by Damien Elmes on 19 Apr, 2013 01:09 AM

    Damien Elmes's Avatar

    If you have formatting inside your fields you'll need to use {{text:FieldName}} to strip it.

  2. 2 Posted by Nick on 19 Apr, 2013 01:57 AM

    Nick's Avatar

    I don't have formatting in my fields...I just want to ADD formatting to the field text in the card template!

    Just tried this out, though, and this works for what I was trying to do! Definitely something for the User Manual, I didn't know you could pull the text out like that!
    Thanks so much!!

  3. 3 Posted by Soren Bjornstad on 19 Apr, 2013 02:13 AM

    Soren Bjornstad's Avatar

    It is mentioned:
    "To solve this, Anki provides the ability to strip formatting from fields
    when they are replaced. If you prefix a field name with text:, Anki will
    not include any formatting. So a dictionary link that worked even with
    formatted text would be: ..."

    Glad you figured out how to make it work, though.

  4. 4 Posted by Nick on 19 Apr, 2013 02:17 AM

    Nick's Avatar

    That implies that if you want to REMOVE formatting, Anki will do that. It doesn't necessarily imply that this will allow you to add new formatting; I read that sentence many times and never made that leap. To be honest, even your reply above, which was only framed as "will allow you to remove formatting" did not seem relevant to my question at first. It's simply not an obvious conclusion unless you are very familiar with this programming style, that's all I was trying to say. Didn't mean to offend; I did read through the entire manual before asking my question (several times), I swear!

  5. 5 Posted by Soren Bjornstad on 19 Apr, 2013 11:26 AM

    Soren Bjornstad's Avatar

    I'm sorry, but I don't understand how stripping formatting can allow you to
    add new formatting. (Obviously you do, though, since you have figured it
    out!) Could you explain what you've done?

  6. 6 Posted by Nick on 19 Apr, 2013 11:33 AM

    Nick's Avatar

    (I think) when you put it as {{text:Field}}, you're simply copying out the text of that field...that's why it removes the formatting. So while you can't add additional formatting to a Field on the card template, you can pull the string out as plaintext, which is formatable. Unless I'm completely wrong about why it works.

    At any rate, if you write your Card template as

    < i>{{text:Field}}

    it will output whatever you typed in your field, with italic (or whatever you use) formatting!

  7. 7 Posted by Soren Bjornstad on 19 Apr, 2013 07:58 PM

    Soren Bjornstad's Avatar

    <i>{{Field}}</i> should work just fine as well. Are you saying that didn't

  8. 8 Posted by Nick on 19 Apr, 2013 09:13 PM

    Nick's Avatar

    Yes, that is the initial problem I was having...I could not add formatting to my (unformatted) fields on the card.

    Ah well, either way I've got it working now, I suppose!

  9. Soren Bjornstad closed this discussion on 20 Apr, 2013 02:25 PM.

  10. Damien Elmes re-opened this discussion on 21 Apr, 2013 06:05 AM

  11. Support Staff 9 Posted by Damien Elmes on 21 Apr, 2013 06:05 AM

    Damien Elmes's Avatar

    There is a bug in Anki where copying from one field to another will copy
    across the plain formatting tags as well, and that probably explains why
    you need to strip the formatting even though you didn't think there was
    anything formatting there.

  12. Soren Bjornstad closed this discussion on 17 May, 2013 05:59 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac