Debian Codegraph @

manual/polish.rst

raw
1 .. _polish_api:
2
3 API documentation for the e-book editing tools
4 ===============================================
5
6 The e-book editing tools consist of a
7 :class:`calibre.ebooks.oeb.polish.container.Container` object that represents a
8 book as a collection of HTML + resource files, and various tools that can be
9 used to perform operations on the container. All the tools are in the form of
10 module level functions in the various ``calibre.ebooks.oeb.polish.*`` modules.
11
12 .. module:: calibre.ebooks.oeb.polish.container
13 :synopsis: The container object used to represent a book as a collection of its constituent HTML files.
14
15 You obtain a container object for a book at a path like this::
16
17 from calibre.ebooks.oeb.polish.container import get_container
18 container = get_container('Path to book file', tweak_mode=True)
19
20 If you are writing a plugin for the E-book editor, you get the current container
21 for the book being edited like this::
22
23 from calibre.gui2.tweak_book import current_container
24 container = current_container()
25 if container is None:
26 report_error # No book has been opened yet
27
28
29 The Container object
30 ----------------------
31
32 .. autoclass:: Container
33 :members:
34
35 Managing component files in a container
36 --------------------------------------------------------
37
38 .. module:: calibre.ebooks.oeb.polish.replace
39
40 .. autofunction:: replace_links
41
42 .. autofunction:: rename_files
43
44 .. autofunction:: get_recommended_folders
45
46 Pretty printing and auto fixing parse errors
47 --------------------------------------------------------
48
49 .. module:: calibre.ebooks.oeb.polish.pretty
50
51 .. autofunction:: fix_html
52
53 .. autofunction:: fix_all_html
54
55 .. autofunction:: pretty_html
56
57 .. autofunction:: pretty_css
58
59 .. autofunction:: pretty_xml
60
61 .. autofunction:: pretty_all
62
63
64 Managing book jackets
65 -----------------------
66
67 .. module:: calibre.ebooks.oeb.polish.jacket
68
69 .. autofunction:: remove_jacket
70
71 .. autofunction:: add_or_replace_jacket
72
73 Splitting and merging of files
74 ---------------------------------
75
76 .. module:: calibre.ebooks.oeb.polish.split
77
78 .. autofunction:: split
79
80 .. autofunction:: multisplit
81
82 .. autofunction:: merge
83
84 Managing covers
85 -------------------
86
87 .. module:: calibre.ebooks.oeb.polish.cover
88
89 .. autofunction:: set_cover
90
91 .. autofunction:: mark_as_cover
92
93 .. autofunction:: mark_as_titlepage
94
95 Working with CSS
96 -------------------
97
98 .. autofunction:: calibre.ebooks.oeb.polish.fonts.change_font
99
100 .. module:: calibre.ebooks.oeb.polish.css
101
102 .. autofunction:: remove_unused_css
103
104 .. autofunction:: filter_css
105
106
107 Working with the Table of Contents
108 -----------------------------------
109
110 .. module:: calibre.ebooks.oeb.polish.toc
111
112 .. autofunction:: from_xpaths
113
114 .. autofunction:: from_links
115
116 .. autofunction:: from_files
117
118 .. autofunction:: create_inline_toc
119
120
121 Edit book tool
122 --------------------
123
124 .. autoclass:: calibre.gui2.tweak_book.plugin.Tool
125 :show-inheritance:
126 :members:
127 :member-order: bysource
128
129
130 Controlling the editor's user interface
131 -----------------------------------------
132
133 The e-book editor's user interface is controlled by a single global *Boss*
134 object. This has many useful methods that can be used in plugin code to
135 perform common tasks.
136
137 .. module:: calibre.gui2.tweak_book.boss
138
139 .. autoclass:: Boss
140 :members:
141