Modify

Opened 8 years ago

Closed 8 years ago

#192 closed defect (fixed)

FootNoteMacro fails to form footnote hints for UTF-8 strings

Reported by: adem@… Owned by: athomas
Priority: normal Component: FootNoteMacro
Severity: normal Keywords:
Cc: Trac Release: 0.8

Description

When some non-english text is included into FootNote macro, like this in russian: 1, the macro forms an incorrect hint for the footnote. The important requrement is the text must entered and showed in Unicode (UTF-8) encoding.
The macro trims a footnote text to 16 bytes length, however UTF-8 characters may have not only one-byte length. So the trimmed footnote hint may have not only less than 16 characters, but also the wrong last character, like the footnote above shows.


  1. 1. Это сноска на русском языке


Attachments (0)

Change History (7)

comment:1 Changed 8 years ago by athomas

Are you using the 0.9 or 0.8 macro?

comment:2 Changed 8 years ago by adem@…

I am using 0.9.
Besides, I placed an example here, in the ticked description. It works and clearly shows the problem.

comment:3 Changed 8 years ago by athomas

Honestly, I have no idea what to do about this. args comes in as ASCII and seemingly any attempt to re-encode it as utf-8 raises an exception. Patches welcome.

comment:4 Changed 8 years ago by re_guzy

  • Trac Release set to 0.8

I am Japanese ,and had the same problem.

I changed the 53rd line of 0.9 as follows.
It works for me.

before

 (id, id, i + 1, wiki_to_oneliner(unescape(v), env)))

after

 (id, id, i + 1, wiki_to_oneliner(v, env)))

comment:5 follow-up: Changed 8 years ago by betelgeuse

Index: 0.10/FootNote.py
===================================================================
--- 0.10/FootNote.py    (revision 1497)
+++ 0.10/FootNote.py    (working copy)
@@ -33,7 +33,7 @@
        """Un-escapes &, <, > and \""""
        if not text:
                return ''
-       return str(text).replace('&amp;', '&') \
+       return unicode(text).replace('&amp;', '&') \
                .replace('&lt;', '<') \
                .replace('&gt;', '>') \
                .replace('&#34;', '"')
@@ -70,4 +70,4 @@
                        if not existing:
                                hdf.footnotes.append(args)
                full_id = "%i.%i" % (hdf.footnote_set, id)
-               return '<sup><a title="%s" style="font-size: 8pt; font-weight: bold;" id="FootNoteRef%s" href="#FootNote%s">%i</a></sup>' % (args[:16] + "...", full_id, full_id, id)
+       return '<sup><a title="%s..." style="font-size: 8pt; font-weight: bold;" id="FootNoteRef%s" href="#FootNote%s">%i</a></sup>' % (args[:16], full_id, full_id, id)

This fixed the problem in 0.10 for me.

comment:6 in reply to: ↑ 5 Changed 8 years ago by anonymous

Replying to betelgeuse:

This fixed the problem in 0.10 for me.

For me too ! Please Commit to Project...

comment:7 Changed 8 years ago by athomas

  • Resolution set to fixed
  • Status changed from new to closed

(In [1733]) Fix for unicode issue. Closes #192, thanks betelgeuse.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from athomas. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.