Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 08-11-2020, 05:08 AM   #1
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
[Editor Plugin] Reformat plugin

This plugin simplifies, corrects and reformats books in EPUB format (especially in Polish language). It gets rid of the nested <span> and <div> tags, removes dummy paragraph classes and many more. The desired effect is an ebook in unified format, described below. Default CSS classes are contained in a special file default.css (no references added to this file in document, it serves as a guideline and source of class definitions).

Installation
Download the attached .zip file and install via Preferences->Advanced>Plugins->Load Plugin or as described in the Introduction to plugins thread. Plugin Reformat will be available in Calibre’s e-Book Editor in Plugins menu.

Main Features & EPUB ebook formatting guidelines
  1. An ebook preferably should consist only of :
    1. Cover (generated automatically by Calibre)
    2. Title, Author, Publisher (<h1-h4> tags in <intro> block)
    3. Dedication, Maps, Introduction (like in chapters)
    4. Chapters (<h1-h3> headers, <center>-<left>-<right> blocks, <diary>-<letter>-<stanza> for italicized blocks, <p> for paragraphs, <h4> for keywords)
    5. Copyright note (<center> and <br> tags)
  2. Info about the Author, more books from this author, publisher details – should be outside of the book, preferable in a special ebook ‘About.epub’
  3. Ebook text will be divided into chapter files based on <section>’s tags or <h1-h2> headers (when there are no <sections> yet) or TOC or bolded style class of a paragraph. Remove <section> tag to merge or add extra </section><section> tag to split files.
  4. All <div> tags will be replaced by default with <center> tag (if it contains some text) or reduced (removed, but with keeping it’s children). Blocks should be precisely defined with <diary-letter-stanza> tags or/and with formatting <center-left-right> tags. Blocks always add extra top & bottom margins.
  5. Only diary and letter blocks should contain paragraphs (as these are indented) – rest should use <br/> tags for line breaks
  6. All <span> tags which affects whole paragraph will be reduced.
  7. Regex expression will try to correct format, remove page numbers and unnecessary white characters (spaces, tabs, line breaks) and comments
  8. Common style classes are included in special file ‘default.css’. You can use classes from this file, and plugin will insert automatically their definition into CSS file.
  9. TOC is generated automatically based on <h1-h3> headers, except for <intro> blocks.
  10. References in text can be implemented using anchors e.g.
    <a id=”ref2” href=”#ref1”>
    with list of reference notes at the end of the book in the form:
    <dl>
    <dt><a id=”ref2” href=”#ref1”>1</a></dt><dd>note</dd>

    </dl>
    Attributes href will be automatically corrected to include proper file reference.
  11. This plugin is meant to be called several times (after manual corrections), until the desired effect. Stylesheet is every time updated, removing unused styles and adding new classes from default.css file if needed.

Example of using default CSS classes:

<section>
<intro>
<h2>author</h2>
<h1>title</h1>
</intro>
</section>

<section>
<h1><diary>Part I</diary>PartTitle</h1>
<center><img image.jpg></center>
</section>

<section>
<h2><diary>Chapter 1</diary>ChapterTitle</h2>
<p><br/>paragraph</p>
<p>paragraph</p>
...
<center>
<stanza>To be or not to be<br/>
That is a question</stanza>
</center>
...
<letter>
<left>Dear readers</left>
<p>text</p>
<right>author</right>
</letter>
...
</section>

...
Attached Files
File Type: docx Formatting guidelines.docx (16.9 KB, 3 views)
File Type: zip Reformat.zip (9.2 KB, 107 views)

Last edited by robert.swita; Today at 01:54 AM. Reason: update to v1.45
robert.swita is offline   Reply With Quote
Old 08-24-2020, 04:11 AM   #2
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v0.9

Some corrections.
This Calibre ebook-Edit Plugin has no GUI, it's meant to be called several times (after manual corrections), until the desired effect - that is - ebook in unified epub format, described little (by an example) in default.css file. Format is maybe controversial, as it uses default and custom tags (rarely classes).
TOC is generated automatically based on h1-h3 headers, except for <intro> blocks.
Splitting is generated based on <section>'s or h1-h2 headers (if there are no sections yet).

Last edited by robert.swita; 10-16-2020 at 02:29 AM.
robert.swita is offline   Reply With Quote
Advert
Old 09-02-2020, 09:41 AM   #3
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v.095
Minor bug fixes

Last edited by robert.swita; 10-16-2020 at 02:30 AM.
robert.swita is offline   Reply With Quote
Old 09-02-2020, 10:00 AM   #4
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v0.95
Updated info in _init_.py

Last edited by robert.swita; 10-16-2020 at 02:30 AM.
robert.swita is offline   Reply With Quote
Old 09-13-2020, 08:59 AM   #5
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v1.0

Rewritten splitting (much faster now)

Last edited by robert.swita; 10-16-2020 at 09:41 AM.
robert.swita is offline   Reply With Quote
Advert
Old 09-17-2020, 07:23 AM   #6
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v1.1

Fixing minor bugs, improving chapter detection heuristics

Last edited by robert.swita; 10-16-2020 at 05:35 AM.
robert.swita is offline   Reply With Quote
Old 09-18-2020, 03:56 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 59,906
Karma: 56644595
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, PRS-650, PRS-T1, nook STR, iPad 4, iPhone SE 2020, PW3
Will this be updated to work with Python 3?
JSWolf is offline   Reply With Quote
Old 09-19-2020, 06:56 AM   #8
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v1.2

This plugin should be compatible with python 2 & 3.
I've installed beta-version 4.99 of portable Calibre to check it out.
It loads plugin fine, but book-editor doesn't update it's menu and debug-info doesn't help much.
I've tried popular plugin ACE with the same result.
Can you confirm, that attached plugin is not python 3 - compatible and point out which plugin is? (and eventually how to check it)

Last edited by robert.swita; 10-16-2020 at 05:36 AM.
robert.swita is offline   Reply With Quote
Old 09-19-2020, 07:13 AM   #9
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 59,906
Karma: 56644595
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, PRS-650, PRS-T1, nook STR, iPad 4, iPhone SE 2020, PW3
Quote:
Originally Posted by robert.swita View Post
This plugin should be compatible with python 2 & 3.
I've installed beta-version 4.99 of portable Calibre to check it out.
It loads plugin fine, but book-editor doesn't update it's menu and debug-info doesn't help much.
I've tried popular plugin ACE with the same result.
Can you confirm, that attached plugin is not python 3 - compatible and point out which plugin is? (and eventually how to check it)
I'm not running the beta because not all the plugins i use are compatible. But I am planning on giving your plugin a try. But I don't want to install any new plugins that are not Calibre 5 ready. Thank you.
JSWolf is offline   Reply With Quote
Old 09-20-2020, 04:53 PM   #10
thiago.eec
Evangelist
thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.thiago.eec can grok the meaning of the universe.
 
Posts: 403
Karma: 155004
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by robert.swita View Post
It loads plugin fine, but book-editor doesn't update it's menu and debug-info doesn't help much.
I've tried popular plugin ACE with the same result.
Hi, I don't understand what is the problem. Can you explain it?
ACE is running fine here, using calibre 4.99.17 on Windows 10.
thiago.eec is offline   Reply With Quote
Old 09-21-2020, 04:14 AM   #11
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Hi, Sorry for the alarm. Everything is working under 4.99.
Strange behavior of the editor must've been a result of co-existing with earlier version of Calibre.
robert.swita is offline   Reply With Quote
Old 09-27-2020, 03:26 AM   #12
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v1.25

Minor corrections to the default.css file (see Format guidelines)

Last edited by robert.swita; 10-16-2020 at 05:36 AM.
robert.swita is offline   Reply With Quote
Old 10-09-2020, 04:38 PM   #13
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Reformat v1.3

Removed bug, which could (rarely) cause loosing data inside <span>'s.
Minor fixes.

Last edited by robert.swita; 10-16-2020 at 09:42 AM.
robert.swita is offline   Reply With Quote
Old 10-09-2020, 05:32 PM   #14
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 59,906
Karma: 56644595
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, PRS-650, PRS-T1, nook STR, iPad 4, iPhone SE 2020, PW3
Are you going to fix the first post so the plugin will be available in the plugin list in Calibre?
JSWolf is offline   Reply With Quote
Old 10-10-2020, 02:37 AM   #15
robert.swita
Member
robert.swita began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Aug 2020
Device: none
Thank you. Didn't really know, that the posts can be edited
robert.swita is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Editor Plugin] EpubCheck Doitsu Plugins 105 09-27-2020 12:28 PM
[Editor Plugin] LanguageTool Doitsu Plugins 7 12-12-2019 08:56 PM
[Plugin] ReworkChapterHeads - Add, replace and reformat chapter headings slowsmile Plugins 72 07-12-2019 11:36 PM
[Editor Plugin] - Enabling 'Customize plugin' dialog directly from the Editor thiago.eec Development 7 01-09-2019 08:05 PM
Editor plugin question DiapDealer Development 2 07-28-2014 10:23 PM


All times are GMT -4. The time now is 08:24 PM.


MobileRead.com is a privately owned, operated and funded community.