aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sdp.d3
-rw-r--r--src/sdp/abstraction.d8
-rw-r--r--src/sdp/ao_abstract_doc_source.d40
-rw-r--r--src/sdp/ao_defaults.d7
-rw-r--r--src/sdp/ao_rgx.d8
-rw-r--r--src/sdp/defaults.d186
-rw-r--r--src/sdp/output_epub3.d60
-rw-r--r--src/sdp/output_html.d24
-rw-r--r--src/sdp/output_hub.d44
-rw-r--r--src/sdp/output_xhtmls.d38
-rw-r--r--src/sdp/paths_output.d287
-rw-r--r--src/sdp/paths_source.d59
-rw-r--r--src/sdp/source_sisupod.d103
13 files changed, 543 insertions, 324 deletions
diff --git a/src/sdp.d b/src/sdp.d
index 27b2d85..ca4f8c0 100755
--- a/src/sdp.d
+++ b/src/sdp.d
@@ -17,7 +17,8 @@ import
ao_read_config_files,
ao_read_source_files,
ao_rgx,
- output_hub;
+ output_hub,
+ paths_source;
/+ sdlang http://sdlang.org +/
import sdlang; // sdlang.d
/+ std +/
diff --git a/src/sdp/abstraction.d b/src/sdp/abstraction.d
index 714ab41..d6124a0 100644
--- a/src/sdp/abstraction.d
+++ b/src/sdp/abstraction.d
@@ -11,7 +11,8 @@ template SiSUabstraction() {
ao_read_config_files,
ao_read_source_files,
ao_rgx,
- output_hub;
+ output_hub,
+ paths_source;
/+ sdlang http://sdlang.org +/
import sdlang; // sdlang.d
/+ std +/
@@ -91,6 +92,11 @@ template SiSUabstraction() {
string[string][string] _k = _make_and_meta[makeMeta.meta];
return _k;
}
+ auto src_path_info() {
+ string _pwd = env["pwd"];
+ auto _k = SiSUpathsSRC!()(_pwd, fn_src);
+ return _k;
+ }
auto source_filename() {
string _k = fn_src;
return _k;
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d
index 24fcd48..f7eca53 100644
--- a/src/sdp/ao_abstract_doc_source.d
+++ b/src/sdp/ao_abstract_doc_source.d
@@ -363,8 +363,9 @@ template SiSUdocAbstraction() {
);
}
line = (line).replaceAll(rgx.true_dollar, "$$$$");
- // dollar represented as $$ needed to stop submatching on $
- // (substitutions using ${identifiers} must take into account (i.e. happen earlier))
+ /+ dollar represented as $$ needed to stop submatching on $
+ (substitutions using ${identifiers} must take into account (i.e. happen earlier))
+ +/
debug(source) { // source lines
writeln(line);
}
@@ -414,7 +415,6 @@ template SiSUdocAbstraction() {
writeln(__LINE__);
writeln(line);
}
- // _glossary_block_(line, type);
type["glossary_section"] = State.on;
type["biblio_section"] = State.off;
type["blurb_section"] = State.off;
@@ -618,7 +618,6 @@ template SiSUdocAbstraction() {
"code block status: none or closed"
);
if (type["blocks"] == TriState.closing) {
- // blocks closed, unless followed by book index
debug(check) { // block
writeln(__LINE__);
writeln(line);
@@ -668,14 +667,13 @@ template SiSUdocAbstraction() {
&& ((type["para"] == State.off)
&& (type["heading"] == State.off))) {
/+ heading make set +/
- _heading_make_set_(line, line_occur, heading_match_rgx, type);
+ line = _heading_make_set_(line, line_occur, heading_match_rgx, type);
}
/+ TODO node info: all headings identified at this point,
- extract node info here??
- how long can it wait?
- should be incorporated in composite objects
- should happen before endnote links set (they need to be moved down?)
- // node_construct.node_emitter_heading segment anchor tag
+/
if (line.matchFirst(rgx.heading)) {
/+ heading match +/
@@ -791,7 +789,6 @@ template SiSUdocAbstraction() {
writeln(segment_anchor_tag_that_object_belongs_to);
}
the_document_body_section ~= comp_obj_heading;
- // track previous heading and make assertions
debug(objectrelated1) { // check
writeln(line);
}
@@ -850,7 +847,6 @@ template SiSUdocAbstraction() {
line == null,
"line variable should be empty, should not occur"
);
- // check what happens when paragraph separated by 2 newlines
}
} // close else for line empty
} // close else for not the above
@@ -959,7 +955,6 @@ template SiSUdocAbstraction() {
comp_obj_heading_.parent_ocn = 1;
comp_obj_heading_.parent_lev_markup = 0;
the_bibliography_section ~= comp_obj_heading_;
- // ---
comp_obj_heading_ = comp_obj_heading_.init;
comp_obj_heading_.use = "backmatter";
comp_obj_heading_.is_of = "para";
@@ -1454,7 +1449,6 @@ template SiSUdocAbstraction() {
foreach (ref obj; the_bookindex_section["scroll"]) {
if (obj.is_a == "heading") {
debug(dom) {
- // writeln(obj.text);
}
if (obj.heading_lev_markup == 4) {
obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
@@ -1540,7 +1534,6 @@ template SiSUdocAbstraction() {
comp_obj_heading_.use = "empty";
comp_obj_heading_.is_of = "para";
comp_obj_heading_.is_a = "heading";
- // comp_obj_heading_.text = "(skip) this is the DOM tail";
comp_obj_heading_.ocn = 0;
comp_obj_para.obj_cite_number = "";
comp_obj_heading_.segment_anchor_tag = "";
@@ -1892,6 +1885,7 @@ template SiSUdocAbstraction() {
debug(quote) { // quote (curly) close
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
type["blocks"] = TriState.closing;
type["quote"] = TriState.closing;
type["curly_quote"] = TriState.off;
@@ -1906,6 +1900,7 @@ template SiSUdocAbstraction() {
debug(quote) { // quote (tic) close
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
type["blocks"] = TriState.closing;
type["quote"] = TriState.closing;
type["tic_quote"] = TriState.off;
@@ -1933,6 +1928,7 @@ template SiSUdocAbstraction() {
debug(group) {
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
type["blocks"] = TriState.closing;
type["group"] = TriState.closing;
type["curly_group"] = TriState.off;
@@ -1947,6 +1943,7 @@ template SiSUdocAbstraction() {
debug(group) {
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
type["blocks"] = TriState.closing;
type["group"] = TriState.closing;
type["tic_group"] = TriState.off;
@@ -1974,6 +1971,7 @@ template SiSUdocAbstraction() {
debug(block) { // block (curly) close
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
type["blocks"] = TriState.closing;
type["block"] = TriState.closing;
type["curly_block"] = TriState.off;
@@ -1988,6 +1986,7 @@ template SiSUdocAbstraction() {
debug(block) {
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key].stripRight;
type["blocks"] = TriState.closing;
type["block"] = TriState.closing;
type["tic_block"] = TriState.off;
@@ -2078,6 +2077,7 @@ template SiSUdocAbstraction() {
ocn_emit(type["ocn_status"]);
type["verse_new"] = State.off;
} else if (line.matchFirst(rgx.newline_eol_delimiter_only)) {
+ processing["verse"] = processing["verse"].stripRight;
verse_line = TriState.off;
type["verse_new"] = State.on;
}
@@ -2170,6 +2170,7 @@ template SiSUdocAbstraction() {
ocn_emit(type["ocn_status"]);
type["verse_new"] = State.off;
} else if (line.matchFirst(rgx.newline_eol_delimiter_only)) {
+ processing["verse"] = processing["verse"].stripRight;
type["verse_new"] = State.on;
verse_line = TriState.off;
}
@@ -2232,6 +2233,9 @@ template SiSUdocAbstraction() {
debug(code) { // code (curly) close
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key]
+ .replaceFirst(rgx.newline_eol_delimiter_only, "")
+ .stripRight;
type["blocks"] = TriState.closing;
type["code"] = TriState.closing;
type["curly_code"] = TriState.off;
@@ -2246,6 +2250,9 @@ template SiSUdocAbstraction() {
debug(code) { // code (tic) close
writeln(line);
}
+ an_object[an_object_key] = an_object[an_object_key]
+ .replaceFirst(rgx.newline_eol_delimiter_only, "")
+ .stripRight;
type["blocks"] = TriState.closing;
type["code"] = TriState.closing;
type["tic_code"] = TriState.off;
@@ -2464,7 +2471,6 @@ template SiSUdocAbstraction() {
header_tag_value="";
}
}
- //
void _table_closed_make_special_notation_table_(
char[] line,
return ref string[string] an_object,
@@ -2513,7 +2519,6 @@ template SiSUdocAbstraction() {
string[string] obj_cite_number_poem,
string[string][string] dochead_make_aa,
) {
- // line.empty, post contents, empty variables ---------------
assert(
line.empty,
"line should be empty"
@@ -2966,6 +2971,7 @@ template SiSUdocAbstraction() {
}
}
}
+ return line;
}
auto _heading_matched_(L,C,O,K,Lv,Lc,T,Me)(
return ref L line,
@@ -3748,7 +3754,6 @@ template SiSUdocAbstraction() {
switch (obj_["is"]) {
case "heading":
static __gshared string anchor_tag = "";
- // TODO WORK ON, you still need to ensure that level 1 anchor_tags are unique
obj_txt["munge"]=_configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, dochead_make_aa);
obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"]);
if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) {
@@ -4955,9 +4960,10 @@ template SiSUdocAbstraction() {
static assert(is(typeof(bib_arr_json) == JSONValue[]));
}
foreach (bibent; biblio_unordered) {
- // update bib to include deemed_author, needed for:
- // sort_bibliography_array_by_deemed_author_year_title
- // either: sort on multiple fields, or; create such sort field
+ /+ update bib to include deemed_author, needed for:
+ sort_bibliography_array_by_deemed_author_year_title
+ either: sort on multiple fields, or; create such sort field
+ +/
JSONValue j = parseJSON(bibent);
if (!empty(j["fulltitle"].str)) {
if (!empty(j["author_raw"].str)) {
diff --git a/src/sdp/ao_defaults.d b/src/sdp/ao_defaults.d
index 21352e2..0f1ba2a 100644
--- a/src/sdp/ao_defaults.d
+++ b/src/sdp/ao_defaults.d
@@ -309,7 +309,7 @@ template SiSUnode() {
}
int[string] node_metadata_heading_int() {
auto _node = [
- "ocn" : 0,
+ "ocn" : 0, // decide whether to use or keep?
"ptr_doc_object" : 0,
"ptr_html_segnames" : 0,
"ptr_heading" : 0,
@@ -325,6 +325,7 @@ template SiSUnode() {
"is" : "",
"ocn" : "",
"attrib" : "",
+ // "segment_anchor_tag" : "",
];
return _node;
}
@@ -334,6 +335,10 @@ template SiSUnode() {
"indent_base" : 0,
"indent_hang" : 0,
"bullet" : 0, // bool (0|1)
+ // "ptr_doc_object" : 0,
+ // "ptr_html_segnames" : 0,
+ // "parent_ocn" : 0,
+ // "parent_lev_markup" : 9,
];
return _node;
}
diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d
index 0844a5f..8c73423 100644
--- a/src/sdp/ao_rgx.d
+++ b/src/sdp/ao_rgx.d
@@ -89,8 +89,8 @@ template SiSUrgxInit() {
static block_open = ctRegex!("^((code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)[{].*?$)|^`{3} (code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)|^[{]table(~h)?(?P<columns>(?:[ ]+[0-9]+;)+)[}]");
static block_poem_open = ctRegex!("^((poem[{].*?$)|`{3} poem)");
/+ blocked markup tics +/
- static block_tic_open = ctRegex!("^`{3} (code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)");
- static block_tic_code_open = ctRegex!("^`{3} (?:code)(?:[.]([a-z][0-9a-z_]+))?(?:[ ]+([#]))?");
+ static block_tic_open = ctRegex!("^`{3} (code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)"); // what of numbered code?
+ static block_tic_code_open = ctRegex!("^`{3} (?:code)(?:[.]([a-z][0-9a-z_]+))?(?:[ ]+([#]))?"); // extract additional info
static block_tic_poem_open = ctRegex!("^`{3} (poem)");
static block_tic_group_open = ctRegex!("^`{3} (group)");
static block_tic_block_open = ctRegex!("^`{3} (block)");
@@ -99,7 +99,7 @@ template SiSUrgxInit() {
static block_tic_close = ctRegex!("^(`{3})$","m");
/+ blocked markup curly +/
static block_curly_open = ctRegex!(`^((code([.][a-z][0-9a-z_]+)?|poem|group|block|quote|table)[{].*?$)`);
- static block_curly_code_open = ctRegex!(`^(?:code(?:[.]([a-z][0-9a-z_]+))?[{]([#]?)\s*$)`);
+ static block_curly_code_open = ctRegex!(`^(?:code(?:[.]([a-z][0-9a-z_]+))?[{]([#]?)\s*$)`); // extract additional info
static block_curly_code_close = ctRegex!(`^([}]code)`);
static block_curly_poem_open = ctRegex!(`^(poem[{].*?$)`);
static block_curly_poem_close = ctRegex!(`^([}]poem)`);
@@ -182,7 +182,7 @@ template SiSUrgxInit() {
auto language_codes =
ctRegex!("(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)");
auto language_code_and_filename =
- ctRegex!("(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)/[A-Za-z0-9._-].+?[.](?:sst|ssm)$");
+ ctRegex!("(?:^|[/])(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)/[A-Za-z0-9._-].+?[.](?:sst|ssm)$");
static newline = ctRegex!("\n", "mg");
static strip_br = ctRegex!("^<br>\n|<br>\n*$");
static space = ctRegex!(`[ ]`, "mg");
diff --git a/src/sdp/defaults.d b/src/sdp/defaults.d
index 537b4ba..bbfd8d8 100644
--- a/src/sdp/defaults.d
+++ b/src/sdp/defaults.d
@@ -2,192 +2,6 @@
default settings
+/
-template SiSUpaths() {
- struct DirPaths {
- string base_filename(string fn_src) {
- return baseName(stripExtension(fn_src));
- }
- }
- struct SiSUpodPaths {
- string base_filename(string fn_src) {
- return baseName(stripExtension(fn_src));
- }
- string sisupod_filename(string fn_src) {
- return "sisupod".chainPath(base_filename(fn_src) ~ ".zip").array;
- }
- string base(string fn_src) {
- return "sisupod".chainPath(base_filename(fn_src)).array;
- }
- }
- struct SiSUpodPathsZipped {
- auto spod_pths = SiSUpodPaths();
- string base_filename(string fn_src) {
- return spod_pths.base_filename(fn_src);
- }
- string sisupod_filename(string fn_src) {
- return spod_pths.sisupod_filename(fn_src);
- }
- string base(string fn_src) {
- return spod_pths.base(fn_src);
- }
- auto doc_root(string fn_src) {
- return "doc";
- }
- auto doc(string fn_src) {
- return doc_root(fn_src);
- }
- auto doc_lng(string fn_src, string lng) {
- return doc_root(fn_src).chainPath(lng).array;
- }
- auto conf(string fn_src) {
- return doc_root(fn_src).chainPath("_sisu").array;
- }
- auto image(string fn_src) {
- return conf(fn_src).chainPath("image").array;
- }
- auto css(string fn_src) {
- return conf(fn_src).chainPath("css").array;
- }
- auto fn_doc(string fn_src, string lng) {
- return (doc_lng(fn_src, lng)).chainPath(baseName(fn_src)).array;
- }
- auto fn_doc_insert(string fn_src, string fn_insert, string lng) {
- return (doc_lng(fn_src, lng)).chainPath(baseName(fn_insert)).array;
- }
- }
- struct SiSUpodPathsFilesystemArchive {
- auto spod_pths = SiSUpodPaths();
- string base_filename(string fn_src) {
- return spod_pths.base_filename(fn_src);
- }
- string sisupod_filename(string fn_src) {
- return spod_pths.sisupod_filename(fn_src);
- }
- string base(string fn_src) {
- return spod_pths.base(fn_src);
- }
- auto doc_root(string fn_src) {
- return base(fn_src).chainPath("doc").array;
- }
- auto doc(string fn_src) {
- return doc_root(fn_src);
- }
- auto doc_lng(string fn_src, string lng) {
- return doc_root(fn_src).chainPath(lng).array;
- }
- auto conf(string fn_src) {
- return doc_root(fn_src).chainPath("_sisu").array;
- }
- auto image(string fn_src) {
- return conf(fn_src).chainPath("image").array;
- }
- auto css(string fn_src) {
- return conf(fn_src).chainPath("css").array;
- }
- auto fn_doc(string fn_src, string lng) {
- return (doc_lng(fn_src, lng)).chainPath(baseName(fn_src)).array;
- }
- auto fn_doc_insert(string fn_src, string fn_insert, string lng) {
- return (doc_lng(fn_src, lng)).chainPath(baseName(fn_insert)).array;
- }
- }
- struct HtmlPaths {
- string base_filename(string fn_src) {
- return baseName(stripExtension(fn_src));
- }
- string base() {
- return "en".chainPath("html").array;
- }
- string seg(string fn_src) {
- return base.chainPath(base_filename(fn_src)).array;
- }
- string fn_scroll(string fn_src) {
- return base.chainPath(base_filename(fn_src) ~ ".html").array;
- }
- string fn_seg(string fn_src, string seg_filename) {
- return seg(fn_src).chainPath(seg_filename ~ ".html").array;
- }
- }
- struct Epub3paths {
- string dirtop() {
- return "".chainPath("").array;
- }
- string base_filename(string fn_src) {
- return baseName(stripExtension(fn_src));
- }
- string base() {
- return "en".chainPath("epub3").array;
- }
- string epub_file(string fn_src) {
- return base.chainPath(base_filename(fn_src) ~ ".epub").array;
- }
- string docdir(string fn_src) {
- return base.chainPath(base_filename(fn_src)).array;
- }
- string doc_meta_inf(string fn_src) {
- return dirtop.chainPath("META-INF").array;
- }
- string doc_oebps(string fn_src) {
- return dirtop.chainPath("OEBPS").array;
- }
- string doc_oebps_css(string fn_src) {
- return doc_oebps(fn_src).chainPath("css").array;
- }
- string doc_oebps_image(string fn_src) {
- return doc_oebps(fn_src).chainPath("image").array;
- }
- string fn_mimetypes(string fn_src) {
- return dirtop.chainPath("mimetypes").array;
- }
- string fn_dmi_container_xml(string fn_src) {
- return doc_meta_inf(fn_src).chainPath("container.xml").array;
- }
- string fn_oebps_toc_nav_xhtml(string fn_src) {
- return doc_oebps(fn_src).chainPath("toc_nav.xhtml").array;
- }
- string fn_oebps_toc_ncx(string fn_src) {
- return doc_oebps(fn_src).chainPath("toc.ncx").array;
- }
- string fn_oebps_content_opf(string fn_src) {
- return doc_oebps(fn_src).chainPath("content.opf").array;
- }
- string fn_oebps_content_xhtml(string fn_src, string seg_filename) {
- return doc_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array;
- }
- debug(epub_output) {
- string dbg_doc_meta_inf(string fn_src) {
- return docdir(fn_src).chainPath("META-INF").array;
- }
- string dbg_doc_oebps(string fn_src) {
- return docdir(fn_src).chainPath("OEBPS").array;
- }
- string dbg_doc_oebps_css(string fn_src) {
- return doc_oebps(fn_src).chainPath("css").array;
- }
- string dbg_doc_oebps_image(string fn_src) {
- return doc_oebps(fn_src).chainPath("image").array;
- }
- string dbg_fn_mimetypes(string fn_src) {
- return docdir(fn_src).chainPath("mimetypes").array;
- }
- string dbg_fn_dmi_container_xml(string fn_src) {
- return doc_meta_inf(fn_src).chainPath("container.xml").array;
- }
- string dbg_fn_oebps_toc_nav_xhtml(string fn_src) {
- return doc_oebps(fn_src).chainPath("toc_nav.xhtml").array;
- }
- string dbg_fn_oebps_toc_ncx(string fn_src) {
- return doc_oebps(fn_src).chainPath("toc.ncx").array;
- }
- string dbg_fn_oebps_content_opf(string fn_src) {
- return doc_oebps(fn_src).chainPath("content.opf").array;
- }
- string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) {
- return doc_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array;
- }
- }
- }
-}
template InternalMarkup() {
struct InlineMarkup {
auto en_a_o = "【"; auto en_a_c = "】"; // endnote en_a_o: '~{'; en_a_c: '}~';
diff --git a/src/sdp/output_epub3.d b/src/sdp/output_epub3.d
index 314fe64..f16b25b 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_xhtmls,
+ paths_output;
mixin InternalMarkup;
mixin outputXHTMLs;
string epub3_mimetypes() {
@@ -45,6 +46,7 @@ template outputEPub3() {
return o;
}
string epub3_oebps_content(D,I,P)(D doc_abstraction, I doc_matters, P parts) {
+ auto pth_epub3 = SiSUpathsEPUB!()(doc_matters.src_path_info, doc_matters.language);
string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters!
string content = format(q"¶ <?xml version='1.0' encoding='utf-8'?>
<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="EPB-UUID">
@@ -70,7 +72,7 @@ template outputEPub3() {
<!-- NCX epub2 navigation -->
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
<!-- CSS Style Sheets -->
- <item id="main-css" href="css/xhtml.css" media-type="text/css" />
+ <link rel="stylesheet" href="%s" type="text/css" id="main-css" />
<!-- nav epub3 navigation -->
<item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" />
¶",
@@ -91,16 +93,19 @@ template outputEPub3() {
uuid,
uuid,
uuid,
+ (pth_epub3.fn_oebps_css(doc_matters.source_filename)).chompPrefix("OEBPS/"),
);
content ~= " " ~ "<!-- Content Documents -->" ~ "\n ";
content ~= parts["manifest_documents"];
// TODO sort jpg & png
content ~= " " ~ "<!-- Images -->" ~ "\n ";
foreach (image; doc_matters.image_list) {
- content ~= format(q"¶ <item id="%s" href="image/%s" media-type="image/png" />
+ content ~= format(q"¶ <item id="%s" href="%s/%s" media-type="image/%s" />
¶",
- image, // strip image type, remove .png .jpg suffix, use in media-type="image/"
+ image.baseName.stripExtension,
+ (pth_epub3.doc_oebps_image(doc_matters.source_filename)).chompPrefix("OEBPS/"),
image,
+ image.extension.chompPrefix("."),
);
}
content ~= " " ~ "</manifest>" ~ "\n ";
@@ -208,9 +213,12 @@ template outputEPub3() {
foreach_reverse (k; 0 .. 7) {
switch (obj.dom_markedup[k]) {
case DomTags.close :
+ // writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); // --debug dom tags
toc ~= "</navPoint>";
break;
case DomTags.close_and_open :
+ // writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); // --debug dom tags
+ // writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); // --debug dom tags
++counter;
toc ~= "</navPoint>";
toc ~= format(q"¶<navPoint class="chapter" id="navpoint" playOrder="%s">
@@ -224,6 +232,7 @@ template outputEPub3() {
);
break;
case DomTags.open :
+ // writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); // --debug dom tags
++counter;
toc ~= format(q"¶<navPoint class="chapter" id="navpoint" playOrder="%s">
<navLabel>
@@ -375,7 +384,7 @@ template outputEPub3() {
doc_epub3[segment_filename] ~= to!string(t[0]);
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
- case "poem":
+ case "poem": // double check why both poem & verse
break;
case "verse":
auto t = xhtml_format.verse_seg(obj, suffix);
@@ -530,22 +539,29 @@ template outputEPub3() {
static assert(is(typeof(oebps_toc_ncx) == string));
static assert(is(typeof(oebps_content_opf) == string));
}
- mixin SiSUpaths;
- auto pth_epub3 = Epub3paths();
+ auto src_path_info = doc_matters.src_path_info;
+ string fn_rel_pth = doc_matters.source_filename;
+ string lng = doc_matters.language;
+ auto pth_epub3 = SiSUpathsEPUB!()(src_path_info, lng);
auto xhtml_format = outputXHTMLs();
/+ zip file +/
auto fn_epub = pth_epub3.epub_file(doc_matters.source_filename);
auto zip = new ZipArchive(); // ZipArchive zip = new ZipArchive();
/+ zip archive member files +/
try {
- if (!exists(pth_epub3.doc_meta_inf(doc_matters.source_filename))) {
- pth_epub3.doc_meta_inf(doc_matters.source_filename).mkdirRecurse;
+ if (!exists(pth_epub3.base)) {
+ pth_epub3.base.mkdirRecurse;
}
- if (!exists(pth_epub3.doc_oebps_css(doc_matters.source_filename))) {
- pth_epub3.doc_oebps_css(doc_matters.source_filename).mkdirRecurse;
- }
- if (!exists(pth_epub3.doc_oebps_image(doc_matters.source_filename))) {
- pth_epub3.doc_oebps_image(doc_matters.source_filename).mkdirRecurse;
+ debug(epub_output) {
+ if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.source_filename))) {
+ pth_epub3.dbg_doc_meta_inf(doc_matters.source_filename).mkdirRecurse;
+ }
+ if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.source_filename))) {
+ pth_epub3.dbg_doc_oebps_css(doc_matters.source_filename).mkdirRecurse;
+ }
+ if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename))) {
+ pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename).mkdirRecurse;
+ }
}
{ /+ OEBPS/[segments].xhtml (the document contents) +/
foreach (seg_filename; doc_matters.segnames) {
@@ -630,7 +646,7 @@ template outputEPub3() {
/+ create the zip file +/
createZipFile!()(fn_epub, zip.build());
}
- { /+ TODO OEBPS/toc.ncx (navigation toc epub2) +/
+ { /+ OEBPS/toc.ncx (navigation toc epub2) +/
debug(epub_output) {
fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.source_filename);
File(fn_dbg, "w").writeln(oebps_toc_ncx);
@@ -647,7 +663,7 @@ template outputEPub3() {
/+ create the zip file +/
createZipFile!()(fn_epub, zip.build());
}
- { /+ TODO OEBPS/content.opf (doc manifest) +/
+ { /+ OEBPS/content.opf (doc manifest) +/
debug(epub_output) {
fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.source_filename);
File(fn_dbg, "w").writeln(oebps_content_opf);
@@ -666,19 +682,19 @@ template outputEPub3() {
}
{ /+ OEBPS/_sisu/image (images) +/
foreach (image; doc_matters.image_list) {
- if (exists("_sisu/image/"~ image)) {
- ("_sisu/image/"~ image)
- .copy((pth_epub3.doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ image);
+ 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(
- "_sisu/image/", image, " -> ",
- pth_epub3.doc_oebps_image(doc_matters.source_filename), "/", image
+ doc_matters.src_path_info.image_root, image, " -> ",
+ pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename), "/", image
);
}
- auto fn_src = "_sisu/image/"~ 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;
if (exists(fn_src)) {
{
diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d
index 431b81c..d5b1a22 100644
--- a/src/sdp/output_html.d
+++ b/src/sdp/output_html.d
@@ -25,7 +25,8 @@ template outputHTML() {
create_zip_file,
defaults,
output_rgx,
- output_xhtmls;
+ output_xhtmls,
+ paths_output;
mixin outputXHTMLs;
void scroll(D,I)(
@@ -167,18 +168,20 @@ template outputHTML() {
}
}
doc = xhtml_format.scroll_head(doc_matters.dochead_meta) ~ doc_html ~ xhtml_format.tail;
- scroll_write_output(doc_matters.source_filename, doc);
+ scroll_write_output(doc_matters, doc);
}
- void scroll_write_output(Fn,C)(
- Fn fn_src,
+ void scroll_write_output(M,C)(
+ M doc_matters,
C doc,
) {
debug(asserts) {
- static assert(is(typeof(fn_src) == string));
static assert(is(typeof(doc) == string[]));
}
- mixin SiSUpaths;
- auto pth_html = HtmlPaths();
+ string fn_src = doc_matters.source_filename;
+ auto src_path_info = doc_matters.src_path_info;
+ string fn_rel_pth = doc_matters.source_filename;
+ string lng = doc_matters.language;
+ auto pth_html = SiSUpathsHTML!()(src_path_info, lng);
try {
if (!exists(pth_html.base)) {
pth_html.base.mkdirRecurse;
@@ -240,6 +243,7 @@ template outputHTML() {
segment_filename = obj.segment_anchor_tag;
doc_html[segment_filename] ~= xhtml_format.seg_head(doc_matters.dochead_meta);
foreach (top_level_heading; top_level_headings) {
+ // writeln(top_level_heading);
doc_html[segment_filename] ~= top_level_heading;
}
auto t = xhtml_format.heading_seg(obj, suffix);
@@ -413,8 +417,10 @@ template outputHTML() {
}
mixin SiSUoutputRgxInit;
auto rgx = Rgx();
- mixin SiSUpaths;
- auto pth_html = HtmlPaths();
+ auto src_path_info = doc_matters.src_path_info;
+ string fn_rel_pth = doc_matters.source_filename;
+ string lng = doc_matters.language;
+ auto pth_html = SiSUpathsHTML!()(src_path_info, lng);
auto xhtml_format = outputXHTMLs();
auto m = doc_matters.source_filename.matchFirst(rgx.src_fn);
try {
diff --git a/src/sdp/output_hub.d b/src/sdp/output_hub.d
index 9e4f971..c38b8e5 100644
--- a/src/sdp/output_hub.d
+++ b/src/sdp/output_hub.d
@@ -29,47 +29,55 @@ template outputHub() {
source_sisupod,
create_zip_file,
output_rgx,
- output_xhtmls;
+ output_xhtmls,
+ paths_output;
void outputHub(D,I)(D doc_abstraction, I doc_matters) {
mixin SiSUoutputRgxInit;
auto rgx = Rgx();
if ((doc_matters.opt_action_bool["verbose"])) {
writeln(doc_matters.keys_seq.seg);
}
- if (doc_matters.opt_action_bool["source"]) {
- /+ mixin outputSource; +/
- writeln("source");
- }
- if (doc_matters.opt_action_bool["sisupod"]) {
- if ((doc_matters.opt_action_bool["verbose"])) {write("sisupod source processing... ");}
+ if ((doc_matters.opt_action_bool["source"])
+ || (doc_matters.opt_action_bool["sisupod"])) {
+ if ((doc_matters.opt_action_bool["verbose"])
+ && (doc_matters.opt_action_bool["source"]))
+ { write("sisu source processing... "); }
+ if ((doc_matters.opt_action_bool["verbose"])
+ && (doc_matters.opt_action_bool["sisupod"]))
+ { write("sisupod source processing... "); }
SiSUpod!()(doc_matters);
- if ((doc_matters.opt_action_bool["verbose"])) {writeln("sisupod done");}
+ if ((doc_matters.opt_action_bool["verbose"])
+ && (doc_matters.opt_action_bool["source"]))
+ { writeln("sisu source done"); }
+ if ((doc_matters.opt_action_bool["verbose"])
+ && (doc_matters.opt_action_bool["sisupod"]))
+ { writeln("sisupod done"); }
}
if (doc_matters.opt_action_bool["text"]) {
/+ mixin outputText; +/
writeln("text processing");
}
if (doc_matters.opt_action_bool["html"]) {
- if ((doc_matters.opt_action_bool["verbose"])) {write("html scroll processing... ");}
+ if ((doc_matters.opt_action_bool["verbose"])) { write("html scroll processing... "); }
outputHTML!().scroll(doc_abstraction, doc_matters);
- if ((doc_matters.opt_action_bool["verbose"])) {writeln("html scroll done");}
- if ((doc_matters.opt_action_bool["verbose"])) {write("html seg processing... ");}
+ if ((doc_matters.opt_action_bool["verbose"])) { writeln("html scroll done"); }
+ if ((doc_matters.opt_action_bool["verbose"])) { write("html seg processing... "); }
outputHTML!().seg(doc_abstraction, doc_matters);
- if ((doc_matters.opt_action_bool["verbose"])) {writeln("html seg done");}
+ if ((doc_matters.opt_action_bool["verbose"])) { writeln("html seg done"); }
} else if (doc_matters.opt_action_bool["html_seg"]) {
- if ((doc_matters.opt_action_bool["verbose"])) {write("html seg processing... ");}
+ if ((doc_matters.opt_action_bool["verbose"])) { write("html seg processing... "); }
outputHTML!().seg(doc_abstraction, doc_matters);
- if ((doc_matters.opt_action_bool["verbose"])) {writeln("html seg done");}
+ if ((doc_matters.opt_action_bool["verbose"])) { writeln("html seg done"); }
} else if (doc_matters.opt_action_bool["html_scroll"]) {
- if ((doc_matters.opt_action_bool["verbose"])) {write("html scroll processing... ");}
+ if ((doc_matters.opt_action_bool["verbose"])) { write("html scroll processing... "); }
outputHTML!().scroll(doc_abstraction, doc_matters);
- if ((doc_matters.opt_action_bool["verbose"])) {writeln("html scroll done");}
+ if ((doc_matters.opt_action_bool["verbose"])) { writeln("html scroll done"); }
}
if (doc_matters.opt_action_bool["epub"]) {
- if ((doc_matters.opt_action_bool["verbose"])) {write("epub3 processing... ");}
+ if ((doc_matters.opt_action_bool["verbose"])) { write("epub3 processing... "); }
outputEPub3!()(doc_abstraction, doc_matters);
// epub.css_write;
- if ((doc_matters.opt_action_bool["verbose"])) {writeln("epub3 done");}
+ if ((doc_matters.opt_action_bool["verbose"])) { writeln("epub3 done"); }
}
if (doc_matters.opt_action_bool["pdf"]) {
/+ mixin outputPDF; +/
diff --git a/src/sdp/output_xhtmls.d b/src/sdp/output_xhtmls.d
index 804b82f..b85123e 100644
--- a/src/sdp/output_xhtmls.d
+++ b/src/sdp/output_xhtmls.d
@@ -25,7 +25,8 @@ template outputXHTMLs() {
create_zip_file,
defaults,
output_rgx,
- output_xhtmls;
+ output_xhtmls,
+ paths_output;
mixin SiSUoutputRgxInit;
struct outputXHTMLs {
auto rgx = Rgx();
@@ -146,7 +147,6 @@ template outputXHTMLs() {
string o;
o = format(q"¶ <a name="bottom" id="bottom"></a>
<a name="end" id="end"></a>
- </div>
</body>
</html>¶");
return o;
@@ -204,7 +204,7 @@ template outputXHTMLs() {
if (obj.inline_notes_reg) {
_txt = (_txt).replaceAll(
rgx.inline_notes_delimiter_al_regular_number_note,
- ("<a href=\"#note_$1\"><note id=\"noteref_$1\">&#160;<sup>$1</sup>&#160;</note></a>")
+ ("<a href=\"#note_$1\"><note id=\"noteref_$1\">&#160;<sup>$1</sup> </note></a>")
);
}
debug(markup_endnotes) {
@@ -251,7 +251,7 @@ template outputXHTMLs() {
}
_txt = (_txt).replaceAll(
rgx.inline_notes_delimiter_al_regular_number_note,
- ("<a href=\"#note_$1\"><note id=\"noteref_$1\">&#160;<sup>$1</sup>&#160;</note></a>")
+ ("<a href=\"#note_$1\"><note id=\"noteref_$1\">&#160;<sup>$1</sup> </note></a>")
);
} else if (_txt.match(rgx.inline_notes_delimiter_al_regular_number_note)) {
debug(markup) {
@@ -305,14 +305,19 @@ template outputXHTMLs() {
string _txt,
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
+ string _horizontal_rule = "<hr />";
+ if (obj.heading_lev_markup == 0) {
+ _horizontal_rule = "";
+ }
string o;
if (obj.obj_cite_number.empty) {
- o = format(q"¶<br /><hr /><br />
+ o = format(q"¶%s
<div class="substance">
<h%s class="%s">%s
%s
</h%s>
</div>¶",
+ _horizontal_rule,
obj.heading_lev_markup,
obj.is_a,
tags,
@@ -320,13 +325,14 @@ template outputXHTMLs() {
obj.heading_lev_markup,
);
} else {
- o = format(q"¶<br /><hr /><br />
+ o = format(q"¶%s
<div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
<h%s class="%s" id="%s"><a name="%s"></a>%s
%s
</h%s>
</div>¶",
+ _horizontal_rule,
obj.obj_cite_number,
obj.obj_cite_number,
obj.heading_lev_markup,
@@ -541,25 +547,21 @@ template outputXHTMLs() {
string o;
if (obj.obj_cite_number.empty) {
o = format(q"¶ <div class="substance">
- <p class="%s">
- %s
- </p>
+ <p class="%s">%s</p>
</div>¶",
obj.is_a,
- _txt
+ _txt.stripRight
);
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <p class="%s" id="%s">
- %s
- </p>
+ <p class="%s" id="%s">%s</p>
</div>¶",
obj.obj_cite_number,
obj.obj_cite_number,
obj.is_a,
obj.obj_cite_number,
- _txt
+ _txt.stripRight
);
}
return o;
@@ -600,9 +602,7 @@ template outputXHTMLs() {
string o;
if (obj.obj_cite_number.empty) {
o = format(q"¶ <div class="substance">
- <p class="%s">
- %s
- </p>
+ <p class="%s">%s</p>
</div>¶",
obj.is_a,
_txt
@@ -610,9 +610,7 @@ template outputXHTMLs() {
} else {
o = format(q"¶ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <p class="%s" id="%s">
- %s
- </p>
+ <p class="%s" id="%s">%s</p>
</div>¶",
obj.obj_cite_number,
obj.obj_cite_number,
diff --git a/src/sdp/paths_output.d b/src/sdp/paths_output.d
new file mode 100644
index 0000000..9c91384
--- /dev/null
+++ b/src/sdp/paths_output.d
@@ -0,0 +1,287 @@
+/++
+ default settings
++/
+import std.array,
+ std.path,
+ std.regex,
+ std.stdio;
+import ao_rgx;
+template SiSUpathsSisupod() {
+ mixin SiSUrgxInit;
+ auto rgx = Rgx();
+ string base_dir = "sisupod";
+ string suffix = ".zip";
+ auto SiSUpathsSisupod()() {
+ struct _PathsStruct {
+ string base_filename(string fn_src) {
+ return fn_src.baseName.stripExtension;
+ }
+ string sisupod_filename(string fn_src) {
+ return base_dir.chainPath(base_filename(fn_src) ~ suffix).array;
+ }
+ string base(string fn_src) {
+ return base_dir.chainPath(base_filename(fn_src)).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsSisupodZipped() {
+ mixin SiSUrgxInit;
+ auto rgx = Rgx();
+ auto SiSUpathsSisupodZipped(Ps,Lng)(
+ Ps src_pth_info,
+ Lng lng,
+ ) {
+ struct _PathsStruct {
+ auto spod_pths = SiSUpathsSisupod!()(); // SiSUpodPaths();
+ string base_filename(string fn_src) {
+ return spod_pths.base_filename(fn_src);
+ }
+ string sisupod_filename(string fn_src) {
+ return spod_pths.sisupod_filename(fn_src);
+ }
+ string base(string fn_src) {
+ return spod_pths.base(fn_src);
+ }
+ auto pod_root(string fn_src) {
+ return "sisudoc";
+ }
+ auto text_root(string fn_src) {
+ return pod_root(fn_src).chainPath("text").array;
+ }
+ auto media_root(string fn_src) {
+ return pod_root(fn_src).chainPath("docmedia").array;
+ }
+ auto conf_root(string fn_src) {
+ return pod_root(fn_src).chainPath("conf").array;
+ }
+ auto doc(string fn_src) {
+ return text_root(fn_src); // or pod_root?
+ }
+ auto doc_lng(string fn_src) {
+ return text_root(fn_src).chainPath(lng).array;
+ }
+ auto image_root(string fn_src) {
+ return media_root(fn_src).chainPath("image").array;
+ }
+ auto css(string fn_src) {
+ return conf_root(fn_src).chainPath("css").array;
+ }
+ auto fn_doc(string fn_src) {
+ return (doc_lng(fn_src)).chainPath(fn_src.baseName).array;
+ }
+ auto fn_doc_insert(string fn_src, string fn_insert) {
+ return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsSisupodFileSystem() {
+ mixin SiSUrgxInit;
+ auto rgx = Rgx();
+ auto SiSUpathsSisupodFileSystem(Ps,Lng)(
+ Ps src_pth_info,
+ Lng lng,
+ ) {
+ struct _PathsStruct {
+ auto spod_pths = SiSUpathsSisupod!()(); // SiSUpodPaths();
+ string base_filename(string fn_src) {
+ return spod_pths.base_filename(fn_src);
+ }
+ string sisupod_filename(string fn_src) {
+ return spod_pths.sisupod_filename(fn_src);
+ }
+ string base(string fn_src) {
+ return spod_pths.base(fn_src);
+ }
+ auto pod_root(string fn_src) {
+ return base(fn_src).chainPath("sisudoc").array;
+ }
+ auto text_root(string fn_src) {
+ return pod_root(fn_src).chainPath("text").array;
+ }
+ auto media_root(string fn_src) {
+ return pod_root(fn_src).chainPath("docmedia").array;
+ }
+ auto conf_root(string fn_src) {
+ return pod_root(fn_src).chainPath("conf").array;
+ }
+ auto doc(string fn_src) {
+ return pod_root(fn_src);
+ }
+ auto doc_lng(string fn_src) {
+ return text_root(fn_src).chainPath(lng).array;
+ }
+ auto image_root(string fn_src) {
+ return media_root(fn_src).chainPath("image").array;
+ }
+ auto css(string fn_src) {
+ return conf_root(fn_src).chainPath("css").array;
+ }
+ auto fn_doc(string fn_src) {
+ return (doc_lng(fn_src)).chainPath(fn_src.baseName).array;
+ }
+ auto fn_doc_insert(string fn_src, string fn_insert) {
+ return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUoutPaths() {
+ auto SiSUoutPaths(Ps,Lng)(
+ Ps src_pth_info,
+ Lng lng,
+ ) {
+ struct _PathsStruct {
+ string output_root() {
+ return "sisugen";
+ }
+ string output_base() {
+ return output_root.chainPath(lng).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsHTML() {
+ mixin SiSUrgxInit;
+ auto rgx = Rgx();
+ auto SiSUpathsHTML(Ps,Lng)(
+ Ps src_pth_info,
+ Lng lng,
+ ) {
+ auto out_pth = SiSUoutPaths!()(src_pth_info, lng);
+ string base_dir = "html";
+ string suffix = ".html";
+ struct _PathsStruct {
+ string base_filename(string fn_src) {
+ return fn_src.baseName.stripExtension;
+ }
+ string base() {
+ return (out_pth.output_base).chainPath(base_dir).array;
+ }
+ string image() {
+ return (out_pth.output_root).chainPath("image").array;
+ }
+ string css() {
+ return (out_pth.output_root).chainPath("css").array;
+ }
+ string fn_css() {
+ return css.chainPath("html.css").array;
+ }
+ string seg(string fn_src) {
+ return base.chainPath(base_filename(fn_src)).array;
+ }
+ string fn_scroll(string fn_src) {
+ return base.chainPath(base_filename(fn_src) ~ suffix).array;
+ }
+ string fn_seg(string fn_src, string seg_filename) {
+ return seg(fn_src).chainPath(seg_filename ~ suffix).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsEPUB() {
+ mixin SiSUrgxInit;
+ auto rgx = Rgx();
+ auto SiSUpathsEPUB(Ps,Lng)(
+ Ps src_pth_info,
+ Lng lng,
+ ) {
+ auto out_pth = SiSUoutPaths!()(src_pth_info, lng);
+ string base_dir = "epub";
+ struct _PathsStruct {
+ string base() {
+ return (out_pth.output_base).chainPath(base_dir).array;
+ }
+ string base_filename(string fn_src) {
+ return fn_src.baseName.stripExtension;
+ }
+ string epub_file(string fn_src) {
+ return base.chainPath(base_filename(fn_src) ~ ".epub").array;
+ }
+ string dirtop() {
+ return "".chainPath("").array;
+ }
+ string doc_meta_inf(string fn_src) {
+ return dirtop.chainPath("META-INF").array;
+ }
+ string doc_oebps(string fn_src) {
+ return dirtop.chainPath("OEBPS").array;
+ }
+ string doc_oebps_css(string fn_src) {
+ return doc_oebps(fn_src).chainPath("css").array;
+ }
+ string doc_oebps_image(string fn_src) {
+ return doc_oebps(fn_src).chainPath("image").array;
+ }
+ string fn_mimetypes(string fn_src) {
+ return dirtop.chainPath("mimetypes").array;
+ }
+ string fn_dmi_container_xml(string fn_src) {
+ return doc_meta_inf(fn_src).chainPath("container.xml").array;
+ }
+ string fn_oebps_toc_nav_xhtml(string fn_src) {
+ return doc_oebps(fn_src).chainPath("toc_nav.xhtml").array;
+ }
+ string fn_oebps_toc_ncx(string fn_src) {
+ return doc_oebps(fn_src).chainPath("toc.ncx").array;
+ }
+ string fn_oebps_content_opf(string fn_src) {
+ return doc_oebps(fn_src).chainPath("content.opf").array;
+ }
+ string fn_oebps_content_xhtml(string fn_src, string seg_filename) {
+ return doc_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array;
+ }
+ string fn_oebps_css(string fn_src) {
+ return doc_oebps_css(fn_src).chainPath("epub.css").array;
+ }
+ debug(epub_output) {
+ string dbg_docdir(string fn_src) {
+ return base.chainPath(base_filename(fn_src)).array;
+ }
+ string dbg_docdir_oebps(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("OEBPS").array;
+ }
+ string dbg_doc_meta_inf(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("META-INF").array;
+ }
+ string dbg_doc_oebps(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("OEBPS").array;
+ }
+ string dbg_doc_oebps_css(string fn_src) {
+ return dbg_doc_oebps(fn_src).chainPath("css").array;
+ }
+ string dbg_doc_oebps_image(string fn_src) {
+ return dbg_doc_oebps(fn_src).chainPath("image").array;
+ }
+ string dbg_fn_mimetypes(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("mimetypes").array;
+ }
+ string dbg_fn_dmi_container_xml(string fn_src) {
+ return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array;
+ }
+ string dbg_fn_oebps_toc_nav_xhtml(string fn_src) {
+ return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array;
+ }
+ string dbg_fn_oebps_toc_ncx(string fn_src) {
+ return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array;
+ }
+ string dbg_fn_oebps_content_opf(string fn_src) {
+ return dbg_docdir_oebps(fn_src).chainPath("content.opf").array;
+ }
+ string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) {
+ return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array;
+ }
+ string dbg_fn_oebps_css(string fn_src) {
+ return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array;
+ }
+ }
+ }
+ return _PathsStruct();
+ }
+}
diff --git a/src/sdp/paths_source.d b/src/sdp/paths_source.d
new file mode 100644
index 0000000..f60949d
--- /dev/null
+++ b/src/sdp/paths_source.d
@@ -0,0 +1,59 @@
+/++
+ read configuration files<BR>
+ - read config files<BR>
+ ao_config_files.d
++/
+import std.array,
+ std.path,
+ std.regex,
+ std.stdio;
+import ao_rgx;
+template SiSUpathsSRC() {
+ mixin SiSUrgxInit;
+ auto rgx = Rgx();
+ auto SiSUpathsSRC(D,Fn)(
+ D _pwd,
+ Fn _fn_src,
+ ) {
+ struct SisuSrcPaths {
+ auto pwd() {
+ return _pwd;
+ }
+ auto language() {
+ // use command line info as well?
+ string _k;
+ if (auto m = _fn_src.match(rgx.language_code_and_filename)) {
+ _k = m.captures[1];
+ } else {
+ _k = "en";
+ }
+ return _k;
+ }
+ auto doc_root() {
+ return "sisudoc";
+ }
+ auto text_root() {
+ return doc_root.chainPath("text").array;
+ }
+ auto media_root() {
+ return doc_root.chainPath("docmedia").array;
+ }
+ auto conf_root() {
+ return doc_root.chainPath("conf").array;
+ }
+ auto image_root() {
+ return media_root.chainPath("image").array;
+ }
+ auto doc_src_fn_with_path_for_text_root_and_lng() {
+ return text_root.chainPath(language).array;
+ }
+ auto doc_src_with_relative_path() {
+ return pwd.chainPath(_fn_src).array;
+ }
+ auto doc_src_fn() {
+ return _fn_src.baseName.array;
+ }
+ }
+ return SisuSrcPaths();
+ }
+}
diff --git a/src/sdp/source_sisupod.d b/src/sdp/source_sisupod.d
index cf15348..9b48ddb 100644
--- a/src/sdp/source_sisupod.d
+++ b/src/sdp/source_sisupod.d
@@ -25,60 +25,70 @@ template SiSUpod() {
create_zip_file,
defaults,
output_rgx,
- output_xhtmls;
+ output_xhtmls,
+ paths_output;
void SiSUpod(T)(T doc_matters) {
debug(asserts) {
// static assert(is(typeof(doc_matters) == tuple));
}
mixin SiSUoutputRgxInit;
- mixin SiSUpaths;
- auto pth_sisupod = SiSUpodPathsZipped();
- auto pth_sisupod_filesystem = SiSUpodPathsFilesystemArchive();
+ string pwd = doc_matters.environment["pwd"];
+ auto src_path_info = doc_matters.src_path_info;
+ string lng = doc_matters.language;
+ auto pth_sisudoc_src = doc_matters.src_path_info;
+ auto pth_sisupod = SiSUpathsSisupodZipped!()(src_path_info, lng);
+ auto pth_sisupod_filesystem = SiSUpathsSisupodFileSystem!()(src_path_info, lng);
mixin SiSUlanguageCodes;
auto lang = Lang();
auto rgx = Rgx();
assert (doc_matters.source_filename.match(rgx.src_fn));
try {
/+ create directory structure +/
- if (!exists(pth_sisupod_filesystem.doc(doc_matters.source_filename))) {
- pth_sisupod_filesystem.doc(doc_matters.source_filename).mkdirRecurse;
- }
- if (!exists(pth_sisupod_filesystem.conf(doc_matters.source_filename))) {
- pth_sisupod_filesystem.conf(doc_matters.source_filename).mkdirRecurse;
- }
- if (!exists(pth_sisupod_filesystem.css(doc_matters.source_filename))) {
- pth_sisupod_filesystem.css(doc_matters.source_filename).mkdirRecurse;
- }
- if (!exists(pth_sisupod_filesystem.image(doc_matters.source_filename))) {
- pth_sisupod_filesystem.image(doc_matters.source_filename).mkdirRecurse;
- }
- if (!exists(pth_sisupod_filesystem.doc_lng(doc_matters.source_filename, doc_matters.language))) {
- pth_sisupod_filesystem.doc_lng(doc_matters.source_filename, doc_matters.language).mkdirRecurse;
+ if (doc_matters.opt_action_bool["source"]) {
+ if (!exists(pth_sisupod_filesystem.text_root(doc_matters.source_filename))) {
+ pth_sisupod_filesystem.text_root(doc_matters.source_filename).mkdirRecurse;
+ }
+ if (!exists(pth_sisupod_filesystem.conf_root(doc_matters.source_filename))) {
+ pth_sisupod_filesystem.conf_root(doc_matters.source_filename).mkdirRecurse;
+ }
+ if (!exists(pth_sisupod_filesystem.media_root(doc_matters.source_filename))) {
+ pth_sisupod_filesystem.media_root(doc_matters.source_filename).mkdirRecurse;
+ }
+ if (!exists(pth_sisupod_filesystem.css(doc_matters.source_filename))) {
+ pth_sisupod_filesystem.css(doc_matters.source_filename).mkdirRecurse;
+ }
+ if (!exists(pth_sisupod_filesystem.image_root(doc_matters.source_filename))) {
+ pth_sisupod_filesystem.image_root(doc_matters.source_filename).mkdirRecurse;
+ }
+ if (!exists(pth_sisupod_filesystem.doc_lng(doc_matters.source_filename))) {
+ pth_sisupod_filesystem.doc_lng(doc_matters.source_filename).mkdirRecurse;
+ }
}
debug(sisupod) {
writeln(__LINE__, ": ",
doc_matters.source_filename, " -> ",
pth_sisupod_filesystem.fn_doc(
doc_matters.source_filename,
- doc_matters.language
));
}
- auto zip = new ZipArchive();
+ auto zip = new ZipArchive(); // ZipArchive zip = new ZipArchive();
auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename);
{ /+ bundle images +/
foreach (image; doc_matters.image_list) {
debug(sisupodimages) {
writeln(
- "_sisu/image/", image, " -> ",
- pth_sisupod.image(doc_matters.source_filename), "/", image
+ pth_sisudoc_src.image_root.to!string, "/", image, " -> ",
+ pth_sisupod.image_root(doc_matters.source_filename), "/", image
);
}
- auto fn_src = "_sisu/image/"~ image;
- auto fn_out = pth_sisupod.image(doc_matters.source_filename).to!string ~ "/" ~ image;
- auto fn_out_filesystem = pth_sisupod_filesystem.image(doc_matters.source_filename).to!string ~ "/" ~ image;
+ auto fn_src = pth_sisudoc_src.image_root.to!string ~ "/" ~ image;
+ auto fn_out = pth_sisupod.image_root(doc_matters.source_filename).to!string ~ "/" ~ image;
+ auto fn_out_filesystem = pth_sisupod_filesystem.image_root(doc_matters.source_filename).to!string ~ "/" ~ image;
if (exists(fn_src)) {
- fn_src.copy(fn_out_filesystem);
- {
+ if (doc_matters.opt_action_bool["source"]) {
+ fn_src.copy(fn_out_filesystem);
+ }
+ if (doc_matters.opt_action_bool["sisupod"]) {
auto zip_arc_member_file = new ArchiveMember();
zip_arc_member_file.name = fn_out;
auto zip_data = new OutBuffer();
@@ -91,12 +101,14 @@ template SiSUpod() {
}
}
{ /+ bundle sisu_document_make +/
- auto fn_src = "_sisu/sisu_document_make"; // check (_sisu/sisu_document_make)
- auto fn_out = pth_sisupod.conf(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make";
- auto fn_out_filesystem = pth_sisupod_filesystem.conf(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make";
+ auto fn_src = pth_sisudoc_src.conf_root.to!string ~ "/" ~ "sisu_document_make"; // check (_sisu/sisu_document_make)
+ auto fn_out = pth_sisupod.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make";
+ auto fn_out_filesystem = pth_sisupod_filesystem.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make";
if (exists(fn_src)) {
- fn_src.copy(fn_out_filesystem);
- {
+ if (doc_matters.opt_action_bool["source"]) {
+ fn_src.copy(fn_out_filesystem);
+ }
+ if (doc_matters.opt_action_bool["sisupod"]) {
auto zip_arc_member_file = new ArchiveMember();
zip_arc_member_file.name = fn_out;
auto zip_data = new OutBuffer();
@@ -109,11 +121,13 @@ template SiSUpod() {
}
{ /+ bundle primary file +/
auto fn_src = doc_matters.source_filename;
- auto fn_out = pth_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).to!string;
- auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc(doc_matters.source_filename, doc_matters.language).to!string;
+ auto fn_out = pth_sisupod.fn_doc(doc_matters.source_filename).to!string;
+ auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc(doc_matters.source_filename).to!string;
if (exists(fn_src)) {
- fn_src.copy(fn_out_filesystem);
- {
+ if (doc_matters.opt_action_bool["source"]) {
+ fn_src.copy(fn_out_filesystem);
+ }
+ if (doc_matters.opt_action_bool["sisupod"]) {
auto zip_arc_member_file = new ArchiveMember();
zip_arc_member_file.name = fn_out;
auto zip_data = new OutBuffer();
@@ -133,23 +147,22 @@ template SiSUpod() {
pth_sisupod.fn_doc_insert(
doc_matters.source_filename,
insert_file,
- doc_matters.language
));
}
auto fn_src = insert_file;
auto fn_out = pth_sisupod.fn_doc_insert(
doc_matters.source_filename,
insert_file,
- doc_matters.language
).to!string;
auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc_insert(
doc_matters.source_filename,
insert_file,
- doc_matters.language
).to!string;
if (exists(fn_src)) {
- fn_src.copy(fn_out_filesystem);
- {
+ if (doc_matters.opt_action_bool["source"]) {
+ fn_src.copy(fn_out_filesystem);
+ }
+ if (doc_matters.opt_action_bool["sisupod"]) {
auto zip_arc_member_file = new ArchiveMember();
zip_arc_member_file.name = insert_file;
auto zip_data = new OutBuffer();
@@ -178,20 +191,20 @@ template SiSUpod() {
catch (ZipException ex) {
// Handle errors
}
- if (doc_matters.source_filename == "en/the_wealth_of_networks.yochai_benkler.sst") {
+ if (doc_matters.source_filename == "sisudoc/text/en/the_wealth_of_networks.yochai_benkler.sst") {
assert(
((data).sha256Of).toHexString
- == "DDE0013C13C6A4F06D4BE72087E2CDEF47697CA38A6A2D65BA7207DB6B144271",
+ == "626F83A31ED82F42CF528E922C1643498A137ABA3F2E5AFF8A379EA79EA22A1E",
"\nsisupod: sha256 value for "
~ doc_matters.source_filename
~ " has changed, is now: "
~ ((data).sha256Of).toHexString
);
}
- if (doc_matters.source_filename == "en/sisu_markup_stress_test.sst") {
+ if (doc_matters.source_filename == "sisudoc/text/en/sisu_markup_stress_test.sst") {
assert(
((data).sha256Of).toHexString
- == "112C0AEDD2518A1803D91A7CF5785274A3116C0779A631782D0C0813B212C68A",
+ == "AAE0C87AB3F6D5F7385AEEA6EE661F56D40475CFE87AD930C78C9FE07FFB0D91",
"\nsisupod: sha256 value for "
~ doc_matters.source_filename
~ " has changed, is now: "