Unicode RE in genericwiki.py?
Matej Cepl <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Organization | Northeastern University, Boston, MA |
| Message-ID | <[email protected]> |
Hi,
I am hacking extensively on genericwiki.py (so that it would produce
alternatively LaTeX output---for inclusion into LyX), but now I have
problem with the old HTML part. See this (one line broken for presentation
in email):
wikinamepattern = r'\b(([A-Z]\w+){2,})\b' # original
mailurlpattern = r'mailto\:[\"\-\_\.\w]+\@[\-\_\.\w]+\w'
newsurlpattern = r'news\:(?:\w+\.){1,}\w+'
fileurlpattern = r'(?:http|https|file|ftp):[/-_.\w-]\
+[\/\w][?&+=%\w/-_.#]*'
[...snip...]
# Turn '[xxx:address label]' into labeled link
body = re.sub(r'(?u)\[(' +
fileurlpattern + '|' +
mailurlpattern + '|' +
newsurlpattern + ')\s+(.+?)\]',
r'<a href="\1">\2</a>', body)
The problem is how to persuade pyblosxom that it would break correctly this
text:
[http://threehouses.typepad.com/three_houses/2005/09/petr_chelcicky_.html
Charis Enns], quite interesting Canadian missionary in Tábor (which is an
interesting combination in itself), wrote about her wacky dream to
translate [http://en.wikipedia.org/wiki/Petr_Chelčický Petr Chelčický?s]
work(s) into English.
My source wiki files (as well as HTML pages which are produced by pyblosxom)
are in UTF-8 so the link to the wikipedia has really character Č
(which is correct--check on wikipedia). However, even when I have ?u in RE,
then still the genericwiki gives as a result
[<a
href="http://en.wikipedia.org/wiki/Petr_Chel">http://en.wikipedia.org/wiki/Petr_Chel</a>čický
Petr Chelčický?s]
which is complete nonsense. Can anybody help me how to parse Unicode
correctly, please?
Thanks a lot,
Matej
--
Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
When you come to the fork in the road, take it
-- L.P. Berra
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php