View Single Post
Old 04-07-2014, 11:45 AM   #624
Rev. Bob
Wizard
Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.
 
Rev. Bob's Avatar
 
Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
Quote:
Originally Posted by Perkin View Post
The self closing tags should have been caught in the elif clauses

change the -1 to a -2 in the line
Code:
elif entity[-1:] == '/>':
Edit: line 590 in modify.py in your last post' zip
I've made that change, and I've found another bug: if HR, BR, or IMG are coded as no-content containers rather than self-closing elements (stupid, but legal), the closing tags are removed but the opening tag is not converted to self-closing.

In other words, <hr></hr> is truncated to a bad <hr> instead of converted to a correct <hr/>.

The culprit seems to be the logic in lines 590-591 of the attached version's modify.py, in which those elements are always assumed to be self-closing:

Code:
elif entity[:3] == '<hr' or entity[:3] == '<br' or entity[:4] == '<img':
    this_entity.e_type = 3
To dodge that bug, I've simply commented that test out for now. Thus, those elements are tested like every other element, and the bad-but-okay form is preserved - but it would be nice if <foo a="x" b="y"></foo> could be converted to <foo a="x" b="y"/> across the board. I'm just not sure how to modify your code to do so.
Attached Files
File Type: zip Modify ePub - stripspans.zip (150.6 KB, 188 views)

Last edited by Rev. Bob; 04-07-2014 at 11:47 AM.
Rev. Bob is offline   Reply With Quote