1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-02-12 20:05:50 +01:00

Added data files required by converter.

This commit is contained in:
2020-04-12 13:06:14 +02:00
parent 01e617f206
commit 18d3cc1510
6 changed files with 50979 additions and 0 deletions

2
MANIFEST.in Normal file
View File

@@ -0,0 +1,2 @@
graft ebook_converter/data
exclude .gitignore

View File

@@ -0,0 +1,404 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blake Ross <BlakeR1234@aol.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
@namespace url(http://www.w3.org/1999/xhtml);
@namespace svg url(http://www.w3.org/2000/svg);
/* blocks */
div, map, dt, isindex, form {
display: block;
}
body {
display: block;
}
p, dl, multicol {
display: block;
margin: 1em 0;
}
dd {
display: block;
margin-left: 40px;
}
blockquote {
display: block;
margin: 1em;
}
address {
display: block;
font-style: italic;
}
center {
display: block;
text-align: center;
}
blockquote[type=cite] {
display: block;
margin: 1em 0em;
border-color: blue;
border-width: thin;
}
h1 {
display: block;
font-size: 2em;
font-weight: bold;
margin: .67em 0;
}
h2 {
display: block;
font-size: 1.5em;
font-weight: bold;
margin: .83em 0;
}
h3 {
display: block;
font-size: 1.17em;
font-weight: bold;
margin: 1em 0;
}
h4 {
display: block;
font-weight: bold;
margin: 1.33em 0;
}
h5 {
display: block;
font-size: 0.83em;
font-weight: bold;
margin: 1.67em 0;
}
h6 {
display: block;
font-size: 0.67em;
font-weight: bold;
margin: 2.33em 0;
}
pre {
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0;
}
/* tables */
table {
display: table;
border-spacing: 2px;
border-collapse: separate;
margin-top: 0;
margin-bottom: 0;
text-indent: 0;
}
table[align="left"] {
float: left;
}
table[align="right"] {
float: right;
}
table[rules]:not([rules="none"]) {
border-collapse: collapse;
}
/* caption inherits from table not table-outer */
caption {
display: table-caption;
text-align: center;
}
table[align="center"] > caption {
margin-left: auto;
margin-right: auto;
}
table[align="center"] > caption[align="left"] {
margin-right: 0;
}
table[align="center"] > caption[align="right"] {
margin-left: 0;
}
tr {
display: table-row;
vertical-align: inherit;
}
col {
display: table-column;
}
colgroup {
display: table-column-group;
}
tbody {
display: table-row-group;
vertical-align: middle;
}
thead {
display: table-header-group;
vertical-align: middle;
}
tfoot {
display: table-footer-group;
vertical-align: middle;
}
/* for XHTML tables without tbody */
table > tr {
vertical-align: middle;
}
td {
display: table-cell;
vertical-align: inherit;
text-align: inherit;
padding: 1px;
}
th {
display: table-cell;
vertical-align: inherit;
font-weight: bold;
padding: 1px;
}
/* inlines */
b, strong {
/* ADE doesn't support bolder with embedded fonts */
font-weight: bold;
}
i, cite, em, var, dfn {
font-style: italic;
}
tt, code, kbd, samp {
font-family: monospace;
}
u, ins {
text-decoration: underline;
}
s, strike, del {
text-decoration: line-through;
}
blink {
text-decoration: blink;
}
big {
font-size: larger;
}
small {
font-size: smaller;
}
sub {
vertical-align: sub;
font-size: smaller;
line-height: normal;
}
sup {
vertical-align: super;
font-size: smaller;
line-height: normal;
}
nobr {
white-space: nowrap;
}
/* titles */
abbr[title], acronym[title] {
border-bottom: dotted 1px;
}
/* lists */
ul, menu, dir {
display: block;
list-style-type: disc;
margin: 1em 0;
}
ol {
display: block;
list-style-type: decimal;
margin: 1em 0;
}
ol[type="a"] {
list-style-type: lower-alpha;
}
ol[type="A"] {
list-style-type: upper-alpha;
}
ol[type="i"] {
list-style-type: lower-roman;
}
ol[type="I"] {
list-style-type: upper-roman;
}
li {
display: list-item;
}
/* nested lists have no top/bottom margins */
ul ul, ul ol, ul dir, ul menu, ul dl,
ol ul, ol ol, ol dir, ol menu, ol dl,
dir ul, dir ol, dir dir, dir menu, dir dl,
menu ul, menu ol, menu dir, menu menu, menu dl,
dl ul, dl ol, dl dir, dl menu, dl dl {
margin-top: 0;
margin-bottom: 0;
}
/* 2 deep unordered lists use a circle */
ol ul, ul ul, menu ul, dir ul,
ol menu, ul menu, menu menu, dir menu,
ol dir, ul dir, menu dir, dir dir {
list-style-type: circle;
}
/* 3 deep (or more) unordered lists use a square */
ol ol ul, ol ul ul, ol menu ul, ol dir ul,
ol ol menu, ol ul menu, ol menu menu, ol dir menu,
ol ol dir, ol ul dir, ol menu dir, ol dir dir,
ul ol ul, ul ul ul, ul menu ul, ul dir ul,
ul ol menu, ul ul menu, ul menu menu, ul dir menu,
ul ol dir, ul ul dir, ul menu dir, ul dir dir,
menu ol ul, menu ul ul, menu menu ul, menu dir ul,
menu ol menu, menu ul menu, menu menu menu, menu dir menu,
menu ol dir, menu ul dir, menu menu dir, menu dir dir,
dir ol ul, dir ul ul, dir menu ul, dir dir ul,
dir ol menu, dir ul menu, dir menu menu, dir dir menu,
dir ol dir, dir ul dir, dir menu dir, dir dir dir {
list-style-type: square;
}
/* leafs */
/* <hr> noshade and color attributes are handled completely by
* the nsHTMLHRElement attribute mapping code
*/
hr {
display: block;
height: 2px;
border: 1px inset;
margin: 0.5em auto 0.5em auto;
color: gray;
}
hr[size="1"] {
border-style: solid none none none;
}
img[usemap], object[usemap] {
color: blue;
}
frameset {
display: block ! important;
position: static ! important;
float: none ! important;
border: none ! important;
}
frame {
border: none ! important;
}
iframe {
border: 2px inset;
}
noframes {
display: none;
}
spacer {
position: static ! important;
float: none ! important;
}
/* hidden elements */
area, base, basefont, head, meta, script, style, title,
noembed, param, link {
display: none;
}
/* Explicit line-breaks are blocks, sure... */
br {
display: block;
}
/* Images, embedded object, and SVG size defaults */
img, object, svg|svg {
width: auto;
height: auto;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,491 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:rtf="http://rtf2xml.sourceforge.net/"
xmlns:c="calibre"
extension-element-prefixes="c"
exclude-result-prefixes="rtf"
>
<xsl:template match = "rtf:para">
<xsl:choose>
<xsl:when test = "parent::rtf:paragraph-definition[@name='heading 1']|
parent::rtf:paragraph-definition[@name='heading 2']|
parent::rtf:paragraph-definition[@name='heading 3']|
parent::rtf:paragraph-definition[@name='heading 4']|
parent::rtf:paragraph-definition[@name='heading 5']|
parent::rtf:paragraph-definition[@name='heading 6']|
parent::rtf:paragraph-definition[@name='heading 7']|
parent::rtf:paragraph-definition[@name='heading 8']|
parent::rtf:paragraph-definition[@name='heading 9']
">
<xsl:variable name="head-number" select="substring(parent::rtf:paragraph-definition/@name, 9)"/>
<xsl:element name="h{$head-number}">
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name = "para"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="rtf:style-group">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="rtf:paragraph-definition">
<xsl:choose>
<xsl:when test = "parent::rtf:paragraph-definition[@name='heading 1']|
parent::rtf:paragraph-definition[@name='heading 2']|
parent::rtf:paragraph-definition[@name='heading 3']|
parent::rtf:paragraph-definition[@name='heading 4']|
parent::rtf:paragraph-definition[@name='heading 5']|
parent::rtf:paragraph-definition[@name='heading 6']|
parent::rtf:paragraph-definition[@name='heading 7']|
parent::rtf:paragraph-definition[@name='heading 8']|
parent::rtf:paragraph-definition[@name='heading 9']
">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:element name="div">
<xsl:attribute name="class">
<xsl:value-of select="@style-number"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name = "para">
<xsl:element name = "p">
<xsl:choose>
<xsl:when test = "normalize-space(.) or child::*">
<xsl:call-template name = "para-content"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>&#160;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<xsl:template name = "para_off">
<xsl:if test = "normalize-space(.) or child::*">
<xsl:element name = "p">
<xsl:attribute name = "class">
<xsl:value-of select = "../@style-number"/>
</xsl:attribute>
<xsl:call-template name = "para-content"/>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template name = "para-content">
<xsl:apply-templates/>
</xsl:template>
<xsl:template name = "para-content_off">
<xsl:choose>
<xsl:when test = "@italics = 'true' ">
<emph rend = "paragraph-emph-italics">
<xsl:apply-templates/>
</emph>
</xsl:when>
<xsl:when test = "@bold = 'true' ">
<emph rend = "paragraph-emph-bold">
<xsl:apply-templates/>
</emph>
</xsl:when>
<xsl:when test = "@underlined and @underlined != 'false'">
<emph rend = "paragraph-emph-underlined">
<xsl:apply-templates/>
</emph>
</xsl:when>
<xsl:when test = "(@strike-through = 'true')
or (@double-strike-through = 'true')
or (@emboss = 'true')
or (@engrave = 'true')
or (@small-caps = 'true')
or (@shadow = 'true')
or (@hidden = 'true')
or (@outline = 'true')
">
<emph rend = "paragraph-emph">
<xsl:apply-templates/>
</emph>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="make-header">
<head>
<xsl:element name="meta">
<xsl:attribute name="name">
<xsl:text>generator</xsl:text>
</xsl:attribute>
<xsl:attribute name="content">
<xsl:text>http://calibre-ebook.com</xsl:text>
</xsl:attribute>
</xsl:element>
<xsl:choose>
<xsl:when test="/rtf:doc/rtf:preamble/rtf:doc-information">
<xsl:apply-templates select="/rtf:doc/rtf:preamble/rtf:doc-information" mode="header"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="html-head"/>
</xsl:otherwise>
</xsl:choose>
</head>
</xsl:template>
<xsl:template match="rtf:doc-information"/>
<xsl:template match="rtf:doc-information" mode="header">
<link rel="stylesheet" type="text/css" href="styles.css"/>
<xsl:if test="not(rtf:title)">
<title>unnamed</title>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="rtf:creation-time|rtf:doc-notes|rtf:author|rtf:revision-time">
<xsl:element name="meta">
<xsl:attribute name="name">
<xsl:value-of select="name(.)"/>
</xsl:attribute>
<xsl:attribute name="content">
<xsl:apply-templates/>
</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:creation-time|rtf:revision-time">
<xsl:element name="meta">
<xsl:attribute name="name">
<xsl:value-of select="name(.)"/>
</xsl:attribute>
<xsl:attribute name="content">
<xsl:value-of select="@year"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="@month"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="@day"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:operator|rtf:editing-time|rtf:number-of-pages|rtf:number-of-words|rtf:number-of-characters"/>
<xsl:template match="rtf:title">
<xsl:element name="title">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template name="html-head">
<title>unnamed</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</xsl:template>
<xsl:template name="make-css-stylesheet">
<xsl:document href="styles.css" method="text">
<xsl:for-each select="//rtf:paragraph-definition">
<xsl:if test = "generate-id(.) = generate-id(key('style-types', @style-number))">
<xsl:text>div.</xsl:text>
<xsl:value-of select="@style-number"/>
<xsl:text>{</xsl:text>
<xsl:call-template name="parse-styles-attrs"/>
<xsl:text>}&#xA;</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>span.italic{font-style:italic}&#xA;</xsl:text>
<xsl:text>span.no-italic{font-style:normal}&#xA;</xsl:text>
<xsl:text>span.bold{font-weight:bold}&#xA;</xsl:text>
<xsl:text>span.no-bold{font-weight:normal}&#xA;</xsl:text>
<xsl:text>span.underline{text-decoration:underline}&#xA;</xsl:text>
<xsl:text>span.no-underline{text-decoration:none}&#xA;</xsl:text>
<xsl:text>span.italic-bold{font-style:italic;font-weight:bold}&#xA;</xsl:text>
<xsl:text>span.italic-underline{font-style:italic;text-decoration:underline}&#xA;</xsl:text>
<xsl:text>span.bold-underline{font-weight:bold;text-decoration:underline}&#xA;</xsl:text>
<xsl:text>&#xA;</xsl:text>
</xsl:document>
</xsl:template>
<xsl:template name="parse-styles-attrs">
<!--<xsl:text>position:relative;</xsl:text>
<xsl:if test="@space-before">
<xsl:text>padding-top:</xsl:text>
<xsl:value-of select="@space-before"/>
<xsl:text>pt;</xsl:text>
</xsl:if>
<xsl:if test="@space-after">
<xsl:text>padding-bottom:</xsl:text>
<xsl:value-of select="@space-after"/>
<xsl:text>pt;</xsl:text>
</xsl:if>-->
<xsl:if test="@left-indent">
<xsl:text>padding-left:</xsl:text>
<xsl:value-of select="@left-indent"/>
<xsl:text>pt;</xsl:text>
</xsl:if>
<xsl:if test="@right-indent">
<xsl:text>padding-right:</xsl:text>
<xsl:value-of select="@right-indent"/>
<xsl:text>pt;</xsl:text>
</xsl:if>
<xsl:if test="@first-line-indent">
<xsl:text>text-indent:</xsl:text>
<xsl:value-of select="@first-line-indent"/>
<xsl:text>pt;</xsl:text>
</xsl:if>
<xsl:if test="@bold='true'">
<xsl:text>font-weight:</xsl:text>
<xsl:value-of select="'bold'"/>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:if test="@italics='true'">
<xsl:text>font-style:</xsl:text>
<xsl:value-of select="'italic'"/>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:if test="@underlined and @underlined != 'false'">
<xsl:text>text-decoration:underline</xsl:text>
<xsl:text>;</xsl:text>
</xsl:if>
<!--<xsl:if test="@line-spacing">
<xsl:text>line-height:</xsl:text>
<xsl:value-of select="@line-spacing"/>
<xsl:text>pt;</xsl:text>
</xsl:if>-->
<xsl:if test="(@align = 'just')">
<xsl:text>text-align: justify;</xsl:text>
</xsl:if>
<xsl:if test="(@align = 'cent')">
<xsl:text>text-align: center;</xsl:text>
</xsl:if>
<xsl:if test="(@align = 'left')">
<xsl:text>text-align: left;</xsl:text>
</xsl:if>
<xsl:if test="(@align = 'right')">
<xsl:text>text-align: right;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="rtf:inline">
<xsl:variable name="num-attrs" select="count(@*)"/>
<xsl:choose>
<xsl:when test="@footnote-marker">
<xsl:text>[</xsl:text>
<xsl:value-of select="count(preceding::rtf:footnote) + 1"/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="(@superscript)">
<xsl:element name="sup">
<xsl:element name="span">
<xsl:attribute name="class">
<c:inline-class/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:when test="(@underscript or @subscript)">
<xsl:element name="sub">
<xsl:element name="span">
<xsl:attribute name="class">
<c:inline-class/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="span">
<xsl:attribute name="class">
<c:inline-class/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="rtf:footnote"/>
<xsl:template match="rtf:footnote" mode="bottom">
<xsl:element name="div">
<xsl:attribute name="class">
<xsl:text>footnote</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:list[@list-type='unordered']">
<xsl:element name="ul">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:list[@list-type='ordered']">
<xsl:element name="ol">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:item">
<xsl:element name="li">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:item/rtf:style-group/rtf:paragraph-definition/rtf:para" priority="2">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="rtf:table">
<xsl:element name="table">
<xsl:attribute name="id">
<xsl:value-of select="generate-id(.)"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:row">
<xsl:element name="tr">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:cell">
<xsl:element name="td">
<xsl:if test="@class">
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!--
<xsl:include href="blocks.xsl"/>
<xsl:include href="fields.xsl"/>
-->
<xsl:output method = "xml"/>
<xsl:key name="style-types" match="rtf:paragraph-definition" use="@style-number"/>
<xsl:variable name = "delete-list-text">true</xsl:variable>
<xsl:variable name = "delete-field-blocks">true</xsl:variable>
<xsl:variable name = "delete-annotation">false</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="make-css-stylesheet"/>
<html>
<xsl:call-template name="make-header"/>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="rtf:doc">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="rtf:preamble">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="rtf:page-break">
<br style = "page-break-after:always"/>
</xsl:template>
<xsl:template match="rtf:hardline-break">
<br/>
</xsl:template>
<xsl:template match="rtf:rtf-definition|rtf:font-table|rtf:color-table|rtf:style-table|rtf:page-definition|rtf:list-table|rtf:override-table|rtf:override-list|rtf:list-text"/>
<xsl:template match="rtf:body">
<xsl:element name="body">
<xsl:apply-templates/>
<xsl:if test = "//rtf:footnote">
<hr/>
</xsl:if>
<xsl:for-each select="//rtf:footnote">
<xsl:apply-templates select="." mode="bottom"/>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="rtf:section">
<xsl:element name="div">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match = "rtf:field-block">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match = "rtf:field[@type='hyperlink']">
<xsl:element name ="a">
<xsl:attribute name = "href">
<xsl:choose>
<xsl:when test="@argument">
<xsl:value-of select="@argument"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test = "not(contains(@link, '/'))">#</xsl:if>
<xsl:value-of select = "@link"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match = "rtf:field[@type='bookmark-start']">
<xsl:element name ="a">
<xsl:attribute name = "id">
<xsl:value-of select = "@number"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match = "rtf:field">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="rtf:pict">
<img src = "{@num}"/>
</xsl:template>
<xsl:template match="*">
<xsl:message>
<xsl:text>no match for element: "</xsl:text>
<xsl:value-of select="name(.)"/>
<xsl:text>" &#xA;</xsl:text>
</xsl:message>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

View File

@@ -22,6 +22,7 @@ classifier =
[options]
packages = find:
include_package_data = True
install_requires =
filelock
python-dateutil
@@ -37,3 +38,6 @@ install_requires =
[options.entry_points]
console_scripts =
ebook-converter=ebook_converter.main:run
[options.package_data]
* = *.types *.css, *.html, *.xsl