05-25-2016, 05:52 PM | #1 |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
[Plugin] ODTImport
ODTImport: Import ODT documents into Sigil as epubs.
(based on Writer2LaTeX) Current Version: "0.4.0" This plugin is a very simple Writer2LaTeX 1.4 wrapper, which allows you to import OpenOffice ODT files. Credits: Since I'm not that familiar with the ODT file format and Writer2LaTeX, I asked st_albert for help with the configuration and stylesheet files and he kindly provided sample configuration/stylesheet files (config.xml and epub.css) as well as an ODF text document template file (custom-styles.ott). If you want to test the template file, unzip Custom-Stylesheet.zip and add the custom styles in LibreOffice/OpenOffice via Styles > Load Styles > From file > ODF Text Document Template > custom-styles.ott. This will add a number of custom styles that all start with custom, e.g. custom-body-text. Note that these styles are not intended as all purpose styles, they're merely provided to demonstrate how to map custom styles to stylesheet classes. For example, the following line in config.xml maps the LibreOffice/OpenOffice custom-body-text style to the p.custom-bodytext class in epub.css. Code:
<xhtml-style-map name="custom-body-text" family="paragraph" element="p" css="custom-bodytext" /> In this case you might find the RemoveInLineStyles plugin helpful, which will allow you to convert all inline styles to classes. Warning: Like all other input plugins this plugin will destroy the contents of the currently loaded ePub; make sure to only run it when no epub is loaded. System requirements: If you're using an older Sigil version, you'll need to install a Python interpreter and select its path in the Manage Plugins dialog box. Since Writer2LaTeX is a Java app, you'll also need to install Java, if you haven't already done so and the Java executable path must be added to the system path. I.e., if you enter java -version in a DOS/terminal window you should get a version number. Otherwise the plugin won't work. If you don't get a version number, please read the troubleshooting section of the epubcheck (Java) plugin. Installation 1. Select Manage Plugins from the Plugins menu. In the Manage Plugins dialog box, select Use Bundled Python, if it isn't already selected. (If your Sigil version doesn't have a Use Bundled Python option, click one of the Auto buttons to detect the path or Set to manually select the Python interpreter path. ) 2. Click Add Plugin and select ODTImport_v0.1.zip. This will install the plugin, which you can select via Plugins > input > ODTImport. (ODTImport_v0.4.0.zip comes with Writer2LaTeX 1.7.) Troubleshooting: If you get a WindowsError: [Error 2] error message, the Java binary couldn't be found. Installing/updating Java and re-booting your machine should take care of this problem. License: GNU General Public License v3 (GPL-3) Last edited by Doitsu; 02-12-2024 at 05:42 PM. |
05-25-2016, 11:11 PM | #2 |
Guru
Posts: 697
Karma: 150000
Join Date: Feb 2010
Device: none
|
I just gave it a pretty good workout in 0.9.5 on Kubuntu 16.10 and it works great. I was even able to replace the config.xml and epub.css with my own production versions with no trouble.
This makes it essentially as easy for me to go from LibreOffice to Sigil as it would be to use the LO writer2xhtml extension, but with greater flexibility, and no worries if the LO version gets ahead of the writer2xhtml extension version, and no longer functions. (As has happened from time to time in the past). For that matter, I suppose the import plugin should work with .odt files from other sources than LibreOffice or OpenOffice, perhaps with some tweaks of the config.xml file. Great work! Albert |
Advert | |
|
05-26-2016, 04:04 AM | #3 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Hi
Congratulations! As a first try, both of you pretty welll succeeded. I imported quite a complex odt file with some titles, lots of footnotes... It was converted straight out the box using the provided "custom" style-sheet. Now I will make further tries to tweak it to my own style-sheet and style-mappings. As we do not have the initial front panel writer2xhtml, provides, I think it will probably be necessary to use the metadata editor of Sigil to complete the missing fields we can't fill in LibreOffice. |
05-26-2016, 11:52 AM | #4 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
I did a second test with the same -complex- odt file.
This time I changed three elements - writer2latex.jar for version 1.5.2.alpha which is quite stable BTW - config.xml from my -renamed- writer2xhtml.xml file - epub.css from my -renamed- writer2xhtml-styles.css The result was even better than the previous one because I could use my custom settings. To get 100% of what I have with writer2xhtml, I should find a way to select some missing options. With writer2xhtml, these are usually selected on the panel (see screenshot). Using writer2latex there is probably a different way to select or express our choice before processing. It mainly concerns: - EPUB2 or EPUB3? - values in px or cm - one font-family for all the styles (and not for each style) - Document division (splitting the html file along h1 or h2 headings, etc.) - producing a toc.ncx Have you an idea how to do it? Last edited by roger64; 05-26-2016 at 12:30 PM. |
05-26-2016, 01:06 PM | #5 | |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Hopefully, st_albert will chime in with some helpful feedback. As for your points: - EPUB2 or EPUB3? For ePub3 output you'll need to change -epub command line parameter to epub3. Locate the following block in plugin.py and replace it with the following version: Spoiler:
- values in px or cm Should be enabled with the the following line in config.xml: Code:
<option name="convert_to_px" value="true" /> - one font-family for all the styles (and not for each style) No idea. Why don't you define a document font for the body element? - Document division (splitting the html file along h1 or h2 headings, etc.) AFAIK, this is defined via the following config.xml parameter: Code:
<option name="split_level" value="1" /> - producing a toc.ncx Should be enabled by the following option: Code:
<option name="include_ncx" value="true" /> |
|
Advert | |
|
05-26-2016, 03:26 PM | #6 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
@Doitsu
Thanks very much for your detailed answer. I will try all this tomorrow. I already select a font-family in the body of epub.css but that's not enough to get rid of all the unwanted font-family which are set in the styles. It's also like that for writer2xhtml and there is a need to order it specifically somewhere. As for this alpha version, I have been using it without any trouble for nearly a year... as a hobbyist. |
05-26-2016, 03:40 PM | #7 |
Guru
Posts: 697
Karma: 150000
Join Date: Feb 2010
Device: none
|
I think Doitsu covered most everything I know about configurations. As for controlling splits in the epub, I will add that there is another config option which more-or-less determines how to handle explicit page breaks in the ODF document. It is
Code:
<option name="page_break_split" value="explicit" /> @roger64: By the way, what does ver 1.5.2-alpha bring to the table vs. 1.4? I know both Doitsu and Roger64 are already familiar with this, but for those new to writer2latex, here is the user manual: |
05-26-2016, 09:45 PM | #8 |
Guru
Posts: 697
Karma: 150000
Join Date: Feb 2010
Device: none
|
Oh, and as for metadata, I see from the user manual that there is a way to add it to the .odt file via the writer2xhtml extension, but I don't see how to do so if using the stand-alone (and therefore, the Sigil plug-in).
This is an area where I'm blind. I never used it in the LO/OO extension, because I just edit the content.opf directly in Sigil. I gave my boss a "skeleton" file with blank metadata entries that we need to use. For a given book, she fills in what she wants, saves it as a .txt file, and I copy and paste it into content.opf as needed. There is a lot of metadata included. But, as JSWolf will no doubt point out, no one makes use of it at present. My boss wants it there, though, for the future. My feeling is, if you will excuse a slightly off-color analogy, that it is like losing bladder control while wearing a dark suit. It gives you a nice warm feeling, but nobody notices. That said, if anyone finds the way to include metadata via the plugin, I'd like to know how. |
05-26-2016, 10:02 PM | #9 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Up to now (till I find another odt file with more complex and untried features), everything seems to be working fine.
Two things are missing but can be easily dealt with : 1. - there seems to be no way to add automatically "resources" (fonts we wish to embed). We can however insert automatically any @font-face declaration. 2. - no metadata editor in the plugin but there is no real need for it(see further down) The missing option I was looking for was: Code:
<option name="use_default_font" value="true" /> road map Henrik Just published his road map from 1.4 to 1.6. for writer2xhtml, the two planned items have been implemented with version 1.5.2.alpha - Support for EPUB3 (including metadata) - toolbar for launching writer2xhtml or writer2latex from LibreOffice for writer2latex, I do not know since it's the first day I use it. metadata editor Of course since Sigil implemented a brand new metadata Editor, it seems spurious to try to double it in the odt plugin. writer2xhtml has one which is useful because it's used within LibreOffice (on the lower part of the screenshot above, click on "Edit document properties"). usermanual I was aware of the existence of this manual, but every time I tried to read it, I found it overwhelming. Last edited by roger64; 05-27-2016 at 04:45 AM. Reason: above comments |
05-30-2016, 01:54 PM | #10 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Using this plugin, I had a closer look at my config.xml file (coming from writer2xhtml). It was a total mess.
So I reordered all its options following the order of the user manual. I added the names of each group, using also the names provided by the user manual. Spoiler:
Options values are mine and can of course be modified. Consult the user manual from page 25. Last edited by roger64; 05-30-2016 at 01:58 PM. |
06-01-2016, 04:22 PM | #11 |
A curiosus lector!
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
|
Thank you Doitsu, as well as st_albert
This plugin is a sagacious move that seems to work pretty well, even with this initial version. Greetings! |
06-02-2016, 03:12 AM | #12 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Enhancement proposal
I. - Front panel
DiapDealer introduced a brilliant front panel with the version 0.2 of his DocXimport plugin (see screenshot). Such a kind of front panel would also very well suit ODTimport. 1. - Choice between EPUB2 and EPUB3 is now difficult for the average user. It could be made much easier (provided we use the 1.5.2. version) 2. - There are two major configuration files interesting the user: config.css and epub.css. However we can imagine there could exist several files of this kind, varying according the intended output (with or without fonts, dropcaps, illustrated book, etc.). This way the user would be able to choice which config.css or epub.css to use just by selecting a new path. If nothing is selected, it would mean that he intends to use the two current files. II. - Other goodies Further, there are some very few "weaknesses" of writer2xhtml that I know how to address everytime I produce an EPUB. However, they may pose a problem for beginners. Resources: Now, when I wish to embed fonts, the plugin allows me only to insert some @font-face declarations in epub.css. It would be good to be able to also designate and import in the EPUB the content of a "Resource" folder with fonts and the com.apple.ibooks.display-options.xml file. We may need to tick a box and select a path for this. cm to em: writer2xhtml offers the choice of px or cm for style sheet dimension units. Neither is really satisfying (relative units are better). I use the DiapDealer Toolbag in the Calibre Editor to convert cm to em in all style sheets. The conversion is not mathematically rigorous but practically it is very useful. We can imagine it could be automatically performed once the conversion to EPUB has been done provided the user ticked previously such an option. xhtml files writer2xhtml 1.5.2. produces EPUB3 with html(5) files (but EPUB2 with xhtml files). Theses files respect also the xhtml format that Epubcheck now recommends to write in such a case. Sigil can rename all the text files extension from html to xhtml. If this was done automatically after EPUB conversion, this would be a plus. Last edited by roger64; 06-02-2016 at 04:03 AM. |
06-02-2016, 04:21 AM | #13 | |||
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
Hi roger64,
Thanks for your feedback. As the plugin didn't generate much interest and was primarily designed for experienced Writer2LaTeX users who usually have the technical skills to modify/replace the default config and css files and the very simple Python plugin wrapper code, I'm somewhat reluctant to add a proper GUI, but I might add plugin prefs support that'll allow the user to modify some of the default settings. Quote:
Quote:
Quote:
Besides there's also dedicated AddiBooksXML plugin by DiapDealer. I might add a user font path to the plugin prefs settings and automatically add all fonts in that folder to the epub. If you specify your own stylesheet, it shouldn't have any cm values in it and using Writer2LaTeX without a custom stylesheet isn't recommended anyway. I.e., don't expect support for this feature. AFAIK, the epub3 standard supports both xhtml and html files and only requires that each type have the proper extension and file type declaration. I.e. it does not require XHTML files nor XHTML file extensions for HTML(5) files. Besides it's not possible to rename files with plugins without breaking links. (Only the GUI rename feature will properly update links.) |
|||
06-02-2016, 04:59 AM | #14 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Thanks to you.
The ODTimport plugin is certainly good for writer2latex users but also for common writer2xhtml users - hey I am one and I guess Arios is one too - and the number of its users can be greatly expanded to the whole community of writer2xhtml users. I have been using writer2xhtml for some years (4, 5?) and kept alive a MR thread about it (in French). By experience, I know that the main problem for explaining to someone how to use it is to make him understand the not so clear (say confusing) writer2xhtml GUI with different panels. With ODTimport, this problem magically disappears: It's enough to provide two files (config and epub) and the result is predictible, guaranteed. This is great. Once a beginner manages to obtain a nice result easily, the more chances he gets used to this software. That's why, I propose to offer an option to get rid of the very few remaining stumbling blocks. Paris has not been done in one day, and we will have time to speak again about it. Anyway, you know I am very keen to test it. Thanks again for your very nice work. |
06-06-2016, 02:38 AM | #15 |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
New version uploaded
I've slightly updated the plugin for the Writer2LaTeX 1.5.2 alpha version, which supports ePub3 output. You can also automatically add a com.apple.ibooks.display-options.xml file for iBooks if you enable the ibooks_xml value in the preferences json file.
The new version also comes with a general purpose stylesheet provided by roger64 who also streamlined the configuration file. It also has Sigil plugin prefs support. You can set the following values: Code:
{
"output_format": "epub3",
"ibooks_xml": true,
"initialdir": "C:/Users/User/Downloads"
}
Disclaimer: Since Writer2LaTeX 1.5.2 is still an alpha version, I don't recommend using it in a production environment. If you need to generate ePub3 books, I'd recommend using Writer2LaTeX 1.4 and the Sigil ePub3 output plugin. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] KindleUnpack - The Plugin | DiapDealer | Plugins | 495 | 10-19-2024 07:06 AM |
[FileType Plugin] YVES Bible Plugin | ClashTheBunny | Plugins | 27 | 01-16-2023 02:25 AM |
Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 03:24 AM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 01:27 PM |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 01:11 PM |