javiereguiluz / easybook

Book publishing as easy as it should be (built with Symfony components)
https://easycorp.io/EasyBook
Other
754 stars 81 forks source link

Fix Duplicate Class Attribute (XHTML Error Syntax Fix) #174

Closed jaywilliams closed 8 years ago

jaywilliams commented 8 years ago

The internal link plugin and Epub2 publisher add a class="internal" attribute to all links. This causes an XHTML error if the link already has a class attribute. This patch fixes this issue by checking if a class attribute exists first, and prepends the "internal" class to the existing attribute.

Input:

Example line with a footnote[^1].
[^1]: http://www.example.com

Output (Before):

<sup id="fnref:1"><a class="internal" href="#fn:1" class="footnote-ref">1</a></sup>

Output (After):

<sup id="fnref:1"><a href="#fn:1" class="internal footnote-ref">1</a></sup>

Error Message in iBooks:

This page contains the following errors: error on line 416 at column 111: Attribute class redefined Below is a rendering of the page up to the first error.

Screenshot:

screen shot 2016-06-08 at 2 05 34 pm
javiereguiluz commented 8 years ago

@jaywilliams thanks for reporting this error and also for providing a pull request to fix it!

jaywilliams commented 8 years ago

It's my pleasure. Thank you, Javier, for building such a wonderful tool and sharing it with the world.