FolioReader / FolioReader-Android

A Java ePub reader and parser framework for Android.
BSD 3-Clause "New" or "Revised" License
2.24k stars 710 forks source link

Fix attribute class redefined error on some epub files #457

Open marcqtan opened 4 years ago

marcqtan commented 4 years ago

Some epubs, have an html content with "class" attribute. FolioReader will fail since it's also defining its class attribute.

Fixed this by adding a logic to check if the class attribute already exist, if it does then just append the class attribute of FolioReader to the already existing class attribute of the Epub file. Otherwise, just add the class attribute directly to the htmlcontent.

Example epub html content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html
 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:epub="http://www.idpf.org/2007/ops"
 xml:lang="ja"
 class="hltr"  ------->  class attr already defined here
>
<head>
<meta charset="UTF-8"/>
<title> Vol.1</title>
<link rel="stylesheet" type="text/css" href="../style/book-style.css"/>
</head>

<body class="image-page">
<div id="m016" class="main">
<h1><img class="fit" src="../image/tobira.jpg" alt=""/></h1>
</div>
</body>
</html>

With my fix the class attribute will become like class="lora nightmode hltr" (sample only)

Will fix #456

mrifni commented 4 years ago

how are you finding this library so far, i am looking for a open source epub reader for ios and android and couldnt find anything so far except this, also is there a flutter version if you know?

marcqtan commented 4 years ago

how are you finding this library so far, i am looking for a open source epub reader for ios and android and couldnt find anything so far except this, also is there a flutter version if you know?

yes. i'm actually using flutter to display epub files. I'm using epub_kitty package which is also using this library (folioreader).

yashdevelops commented 3 years ago

@marcqtan Please help me bro ! I'm getting a crash in my folio reader app opening EPUB books. I have raised a issue please have a look and help. I have been stuck in this since weeks. Please.

https://github.com/FolioReader/FolioReader-Android/issues/468

mrifni commented 3 years ago

can someone review these PRs and feedback the contributor ?