|Subject:||XHTML doesn't allow div element inside pre element|
|Date:||Wed, 10 Jan 2007 16:51:48 +0000|
|From:||Pete Gillin <firstname.lastname@example.org>|
The POD for Text::Diff::HTML suggests that: 'You will also likely want to wrap the output of your diff in a "<pre>" element.' This is great advice... except that the output includes div elements and the XHTML spec (XHTML 1.0 Strict, at least) does not allow div elements within a pre element. So either it is a bug that the documentation suggests that you wrap in a pre element and can obtain valid XHTML by doing so, or it is a bug that the output produced includes divs. As a workaround (because you're right, the pre element is very useful), I have subclassed Text::Diff::HTML are reimplemented the (file|hunk)_(header|footer) methods to do the same thing but with spans instead of divs. I humbly suggest that this change should (possibly optionally, or possibly with an option to revert to div to maintain backwards compatibility where essential) be adopted in Text::Diff::HTML. Best wishes, Pete. P.S. While I was subclassing, I also reimplemented the _header method in my subclass to honour options FILENAME_SUFFIX_[AB] which, if defined, are joined onto the end of the lines of the file header. This made it easy for me to mark up and apply style to each line separately, specifically to have the +++ and --- lines in colours related to the + and - lines in the hunk, which I feel improves readability. If you wanted to consider this for a subsequent version, that would be great too. P.P.S. I can supply patches for either of the above if that would help.