aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output_epub3.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/output_epub3.d')
-rw-r--r--src/sdp/output_epub3.d45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/sdp/output_epub3.d b/src/sdp/output_epub3.d
index f16b25b..ea33f2e 100644
--- a/src/sdp/output_epub3.d
+++ b/src/sdp/output_epub3.d
@@ -25,7 +25,8 @@ template outputEPub3() {
create_zip_file,
defaults,
output_rgx,
- output_xhtmls,
+ output_xmls,
+ output_xmls_css,
paths_output;
mixin InternalMarkup;
mixin outputXHTMLs;
@@ -186,7 +187,7 @@ template outputEPub3() {
<!-- four required metadata items (for all NCX documents,
(including the relaxed constraints of OPS 2.0) -->
<title>%s%s</title>
- <link href="css/xhtml.css" rel="stylesheet" type="text/css" id="main-css" />
+ <link rel="stylesheet" href="css/epub.css" type="text/css" id="main-css" />
<meta name="dtb:uid" content="urn:uuid:%s" />
<!-- <meta name="epub-creator" content="SiSU http://www.jus.uio.no/sisu (this copy)" /> -->
<meta name="dtb:depth" content="%s" />
@@ -303,7 +304,7 @@ template outputEPub3() {
break;
case 4:
segment_filename = obj.segment_anchor_tag;
- doc_epub3[segment_filename] ~= xhtml_format.seg_head(doc_matters.dochead_meta);
+ doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters.dochead_meta);
foreach (top_level_heading; top_level_headings) {
doc_epub3[segment_filename] ~= top_level_heading;
}
@@ -531,6 +532,7 @@ template outputEPub3() {
Otn oebps_toc_ncx,
Oc oebps_content_opf,
) {
+ auto css = SiSUcss();
debug(asserts) {
static assert(is(typeof(doc_epub3) == string[][string]));
static assert(is(typeof(mimetypes) == string));
@@ -682,17 +684,21 @@ template outputEPub3() {
}
{ /+ OEBPS/_sisu/image (images) +/
foreach (image; doc_matters.image_list) {
- if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) {
- (doc_matters.src_path_info.image_root ~ "/" ~ image)
- .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ image);
+ debug(epub_output) {
+ if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) {
+ (doc_matters.src_path_info.image_root ~ "/" ~ image)
+ .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ image);
+ }
}
}
foreach (image; doc_matters.image_list) {
- debug(epub_images) {
- writeln(
- doc_matters.src_path_info.image_root, image, " -> ",
- pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename), "/", image
- );
+ debug(epub_output) {
+ debug(epub_images) {
+ writeln(
+ doc_matters.src_path_info.image_root, image, " -> ",
+ pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename), "/", image
+ );
+ }
}
auto fn_src = doc_matters.src_path_info.image_root ~ image;
auto fn_out = pth_epub3.doc_oebps_image(doc_matters.source_filename).to!string ~ "/" ~ image;
@@ -709,6 +715,23 @@ template outputEPub3() {
}
}
}
+ { /+ OEBPS/epub.css +/
+ debug(epub_output) {
+ fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.source_filename);
+ File(fn_dbg, "w").writeln(css.epub_css);
+ }
+ fn = pth_epub3.fn_oebps_css(doc_matters.source_filename);
+ /+ add zip archive file members (with their content) +/
+ auto zip_arc_member_file = new ArchiveMember();
+ // add OEBPS/content.opf to zip archive
+ zip_arc_member_file.name = fn;
+ auto zip_data = new OutBuffer();
+ zip_data.write(oebps_content_opf.dup); // cast as: char[]
+ zip_arc_member_file.expandedData = zip_data.toBytes();
+ zip.addMember(zip_arc_member_file);
+ /+ create the zip file +/
+ createZipFile!()(fn_epub, zip.build());
+ }
}
catch (ErrnoException ex) {
// Handle error