batterseapower / pinyin-toolkit

A plugin for the Anki Spaced Repetition System (http://ichi2.net/anki/)
http://batterseapower.github.com/pinyin-toolkit/
39 stars 14 forks source link

bug with colour and pinyin toolkit id link #151

Closed Nick3C closed 14 years ago

Nick3C commented 14 years ago

hi max, How's things Max? Still busy I presume :)

Reporting a bug in the latest code with anki snapshot 2 in relation to coloured hanzi.

For example the coloured hanzi of 外边 return html as follows:

<a name="pinyin-toolkit"></a><span style="color:#0000ff;">外</span><span style="color:#545454;">边</span>

However, this link breaks the colour display by reducing the size of the text when viewed in the main anki. I'm not entirely sure why but it does. Removing the a name fixes the problem.

As a comment shouldn't it be a and surround the entire inserted entry instead of an a? Also I presume this is to allow us to auto-wipe anything within the span on auto update? only problem will be if user edits within the span then it will still be removed.

Cheers

batterseapower commented 14 years ago

Hey,

Yes, the point of this tag is to mark generated fields. After much experimentation I found that an:

<a name="foo"></a>

tag at the start of the text was preserved even after Anki "cleans up" the HTML. I think I tried span, but it was stripped out by Anki.

When a user edits a field which contains this tag I strip the tag out to mark it is as non-generated again. This lets us do really good auto blanking.

I haven't seen the problem you described, but can you find an alternative tag we could use to mark the text that doesn't cause a size issue? I don't really mind what it is as long as it doesn't get removed after you tab away from the field or after opening and then closing the HTML editor for the field.

Nick3C commented 14 years ago

Ah I see.. what a good idea. It will be sad that it doesn't apply to those previously added, however... ah well :)

Anyway, I have found a solution. Put the at the end of the field instead of the start.Ordinarily Anki will remove this, but if you put a space in the middle of the tags, i.e. then it isn't removed and doesn't break the field. Probably other things will work but this was the first thing I found when experimenting.

I wonder whether the problem was linked to having a link in the model field. Did you try testing it on the sample deck?

batterseapower commented 14 years ago

Hmmm.

I've reproduced the bug, and tried your proposed solution. It appears to work, but the trailing space you get in all the fields is extremely ugly.

I also have no idea why the leading a tag causes the formatting to screw up.

Have you got any other ideas for markers we could use? I played around a lot but didn't find anything promising.

Weirdly, HTML that looks like this doesn't suffer from the font size problem:

<a name="pinyin-toolkit"></a><span style="color:#ffaa00;">m</span><span style="color:#ffaa00;">éi</span> <span style="color:#00aa00;">yǒu</span>