scanner / typogrify

Automatically exported from code.google.com/p/typogrify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

<pre> tags are affected by the widont filter #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Make a <pre> block and put in some content in. Run the typoogify filter on it .

What is the expected output? What do you see instead?
<pre> blocks are affected by the typogrify filter. IMHO and according to
the doc <pre> blocks should be left untouched.

What version of the product are you using? On what operating system?
Latest svn trunk.

Please provide any additional information below.
The problem is the regular expression in the widont() function. The problem
is due to the search for a closing "<p" which also matches "<pre". I fixed
this issue by excluding <pre> (see below). But since i'm not a regular
expression expert, I don't know if that's the right way to do it.

    widont_finder = re.compile(r"""(\s+)                                #
the space to replace
                                   ([^<>\s]+                            #
must be flollowed by non-tag non-space characters
                                   \s*                                  #
optional white space! 
                                   (</(a|em|span|strong|i|b)[^>]*>\s*)* #
optional closing inline tags with optional white space after each
                                   (</(p[^re]|h[1-6]|li|dt|dd)|$))        
        # end with a closing p, h1-6, li or the end of the string
                                   """, re.VERBOSE)

Original issue reported on code.google.com by pesch...@gmail.com on 1 Sep 2007 at 8:50

GoogleCodeExporter commented 9 years ago
Thanks! I'll definitely make sure this gets fixed.

Original comment by mintx...@gmail.com on 5 Sep 2007 at 3:47

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. I just got a fix in I'll be pushing a new release 
soon. It's slightly different from your 
method; instead of saying p not followed by an 'r' or an 'e'. I just check to 
make sure that the tag ends with > 
directly after the specified allowed tags.

Original comment by mintx...@gmail.com on 20 Nov 2007 at 6:55