aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-01-26 15:17:59 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commit2598e9f10a362f15fef081504d69757001b39cfb (patch)
tree76966a2d60a8ebb3ee67f3cef9a03926b7399d7b /src
parentoutput, template & struct names (diff)
output, message passing, minor
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sdp.d2
-rw-r--r--src/sdp/ao_abstract_doc_source.d15
-rw-r--r--src/sdp/ao_conf_make_meta_native.d2
-rw-r--r--src/sdp/ao_conf_make_meta_sdlang.d2
-rw-r--r--src/sdp/ao_output_debugs.d2
-rw-r--r--src/sdp/ao_read_source_files.d3
-rw-r--r--src/sdp/ao_rgx.d2
-rw-r--r--src/sdp/output_epub.d32
-rw-r--r--src/sdp/output_html.d29
9 files changed, 34 insertions, 55 deletions
diff --git a/src/sdp.d b/src/sdp.d
index 94ef276..04cca77 100755
--- a/src/sdp.d
+++ b/src/sdp.d
@@ -43,9 +43,9 @@ private import
mixin(import("version.txt"));
mixin CompileTimeInfo;
-mixin RgxInit;
/++ A SiSU document parser writen in D. +/
void main(string[] args) {
+ mixin SiSUrgxInit;
mixin SiSUregisters;
mixin SiSUheaderExtractHub;
mixin SiSUheaderExtractSDLang;
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d
index cd121c5..ed4e637 100644
--- a/src/sdp/ao_abstract_doc_source.d
+++ b/src/sdp/ao_abstract_doc_source.d
@@ -7,16 +7,13 @@ template SiSUdocAbstraction() {
private:
struct SiSUdocAbstraction {
/+ ↓ abstraction imports +/
- import
- ao_defaults, // sdp/ao_defaults.d
- ao_object_setter, // sdp/ao_object_setter.d
- ao_rgx; // sdp/ao_rgx.d
+ import ao_object_setter;
/+ ↓ abstraction mixins +/
mixin ObjectSetter;
mixin InternalMarkup;
+ mixin SiSUrgxInit;
/+ ↓ abstraction struct init +/
/+ initialize +/
- auto rgx = Rgx();
ObjGenericComposite[][string] the_table_of_contents_section;
ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section;
ObjGenericComposite[] the_dom_tail_section;
@@ -3104,7 +3101,6 @@ template SiSUdocAbstraction() {
}
}
body {
- auto rgx = Rgx();
obj_txt["munge"]=obj_txt_in;
obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.para_attribs, "");
obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, "");
@@ -3124,7 +3120,6 @@ template SiSUdocAbstraction() {
}
}
body {
- auto rgx = Rgx();
obj_txt["munge"]=obj_txt_in;
obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, "");
obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, "");
@@ -3222,6 +3217,7 @@ template SiSUdocAbstraction() {
}
}
struct ObjInlineMarkup {
+ auto rgx = Rgx();
auto munge = ObjInlineMarkupMunge();
string[string] obj_txt;
auto obj_inline_markup_and_anchor_tags(O,K,Ma)(
@@ -3732,7 +3728,6 @@ template SiSUdocAbstraction() {
}
}
body {
- auto rgx = Rgx();
if (matchFirst(obj_txt_in, rgx.para_bullet)) {
_obj_attributes =" \"bullet\": \"true\","
~ " \"indent_hang\": 0,"
@@ -4447,6 +4442,7 @@ template SiSUdocAbstraction() {
int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7;
int obj_cite_number;
int[string] p_; // p_ parent_
+ auto rgx = Rgx();
ObjGenericComposite node_location_emitter(Lv,Ta,N,C,P,I)(
Lv lev_markup_number,
Ta segment_anchor_tag,
@@ -4464,7 +4460,6 @@ template SiSUdocAbstraction() {
static assert(is(typeof(ptr_) == int));
static assert(is(typeof(is_) == string));
}
- auto rgx = Rgx();
assert(is_ != "heading");
assert(to!int(obj_cite_number_) >= 0);
}
@@ -4533,7 +4528,6 @@ template SiSUdocAbstraction() {
static assert(is(typeof(is_) == string));
static assert(is(typeof(html_segnames_ptr) == int));
}
- auto rgx = Rgx();
assert(is_ == "heading");
assert(to!int(obj_cite_number_) >= 0);
assert(
@@ -4547,7 +4541,6 @@ template SiSUdocAbstraction() {
}
}
body {
- auto rgx = Rgx();
int obj_cite_number = to!int(obj_cite_number_);
switch (to!int(lev_markup_number)) { // switch (to!string(lv)) {
case 0:
diff --git a/src/sdp/ao_conf_make_meta_native.d b/src/sdp/ao_conf_make_meta_native.d
index 6fe38e9..cc907b2 100644
--- a/src/sdp/ao_conf_make_meta_native.d
+++ b/src/sdp/ao_conf_make_meta_native.d
@@ -13,7 +13,7 @@ template SiSUheaderExtractNative() {
struct HeaderDocMetadataAndMakeNativeToAA {
mixin SiSUregisters;
mixin SiSUrgxInitFlags;
- mixin RgxInit;
+ mixin SiSUrgxInit;
auto rgx = Rgx();
enum State { off, on }
string hm, hs;
diff --git a/src/sdp/ao_conf_make_meta_sdlang.d b/src/sdp/ao_conf_make_meta_sdlang.d
index 801df7e..fe1696d 100644
--- a/src/sdp/ao_conf_make_meta_sdlang.d
+++ b/src/sdp/ao_conf_make_meta_sdlang.d
@@ -9,7 +9,7 @@ template SiSUheaderExtractSDLang() {
ao_rgx;
struct HeaderExtractSDL {
mixin SiSUregisters;
- mixin RgxInit;
+ mixin SiSUrgxInit;
auto rgx = Rgx();
private auto sdlangToAAmake(C,Tag)(C conf, Tag conf_sdlang) {
debug(asserts){
diff --git a/src/sdp/ao_output_debugs.d b/src/sdp/ao_output_debugs.d
index 8b22f28..2872833 100644
--- a/src/sdp/ao_output_debugs.d
+++ b/src/sdp/ao_output_debugs.d
@@ -7,7 +7,7 @@ template SiSUoutputDebugs() {
auto ref const S contents,
auto ref T doc_matters,
) {
- mixin RgxInit;
+ mixin SiSUrgxInit;
mixin InternalMarkup;
auto rgx = Rgx();
auto markup = InlineMarkup();
diff --git a/src/sdp/ao_read_source_files.d b/src/sdp/ao_read_source_files.d
index 34aed22..f25ed7e 100644
--- a/src/sdp/ao_read_source_files.d
+++ b/src/sdp/ao_read_source_files.d
@@ -10,9 +10,6 @@ template SiSUmarkupRaw() {
std.stdio,
std.utf,
std.conv : to;
- private import
- ao_rgx; // ao_defaults.d
- mixin RgxInit;
auto rgx = Rgx();
struct MarkupRaw {
final sourceContent(in string fn_src) {
diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d
index f800a12..286aa76 100644
--- a/src/sdp/ao_rgx.d
+++ b/src/sdp/ao_rgx.d
@@ -1,7 +1,7 @@
/++
regex: regular expressions used in sisu document parser
+/
-template RgxInit() {
+template SiSUrgxInit() {
struct Rgx {
mixin SiSUlanguageCodes;
/+ misc +/
diff --git a/src/sdp/output_epub.d b/src/sdp/output_epub.d
index c7c13ef..4c23600 100644
--- a/src/sdp/output_epub.d
+++ b/src/sdp/output_epub.d
@@ -154,7 +154,6 @@ template outputEPub() {
string[][string] doc_epub;
string[] doc;
string segment_filename;
- string[] seg_filenames;
string[] top_level_headings = ["","","",""];
auto mimetypes = epub_mimetypes;
auto meta_inf_container_xml = epub_container_xml;
@@ -193,7 +192,6 @@ template outputEPub() {
}
break;
case 4:
- seg_filenames ~= obj.segment_anchor_tag;
segment_filename = obj.segment_anchor_tag;
doc_epub[segment_filename] ~= xhtml_format.seg_head(doc_matters.dochead_meta);
foreach (top_level_heading; top_level_headings) {
@@ -307,8 +305,7 @@ template outputEPub() {
}
writeln(doc_matters.keys_seq_seg);
epub_write_output_files(
- doc_matters.source_filename,
- seg_filenames,
+ doc_matters,
doc_epub,
mimetypes,
meta_inf_container_xml,
@@ -316,18 +313,15 @@ template outputEPub() {
oebps_content_opf,
);
}
- void epub_write_output_files(Fn,FnS,De,Mt,Mic,Ot,Oc)(
- Fn fn_src,
- FnS seg_filenames,
- De doc_epub,
+ void epub_write_output_files(C,EpD,Mt,Mic,Ot,Oc)(
+ C doc_matters,
+ EpD doc_epub,
Mt mimetypes,
Mic meta_inf_container_xml,
Ot oebps_toc_ncx,
Oc oebps_content_opf,
) {
debug(asserts){
- static assert(is(typeof(fn_src) == string));
- static assert(is(typeof(seg_filenames) == string[]));
static assert(is(typeof(doc_epub) == string[][string]));
static assert(is(typeof(mimetypes) == string));
static assert(is(typeof(meta_inf_container_xml) == string));
@@ -339,12 +333,12 @@ template outputEPub() {
// doc = xhtml_format.scroll_head ~ doc_epub ~ xhtml_format.tail;
auto xhtml_format = outputXHTMLs();
try {
- mkdirRecurse(pth_epub.doc_meta_inf(fn_src));
- mkdirRecurse(pth_epub.doc_oebps_css(fn_src));
- mkdirRecurse(pth_epub.doc_oebps_image(fn_src));
+ mkdirRecurse(pth_epub.doc_meta_inf(doc_matters.source_filename));
+ mkdirRecurse(pth_epub.doc_oebps_css(doc_matters.source_filename));
+ mkdirRecurse(pth_epub.doc_oebps_image(doc_matters.source_filename));
/+ OEBPS/[segments].xhtml +/
- foreach (seg_filename; seg_filenames) {
- auto f = File(pth_epub.fn_oebps_content_xhtml(fn_src, seg_filename), "w");
+ foreach (seg_filename; doc_matters.segnames) {
+ auto f = File(pth_epub.fn_oebps_content_xhtml(doc_matters.source_filename, seg_filename), "w");
/+ // f.writeln(seg_head); // not needed built and inserted earlier +/
foreach (docseg; doc_epub[seg_filename]) {
f.writeln(docseg);
@@ -352,16 +346,16 @@ template outputEPub() {
f.writeln(xhtml_format.tail); // needed for each lev4
}
/+ mimetypes +/
- auto f = File(pth_epub.fn_mimetypes(fn_src), "w");
+ auto f = File(pth_epub.fn_mimetypes(doc_matters.source_filename), "w");
f.writeln(mimetypes);
/+ META-INF/container.xml +/
- f = File(pth_epub.fn_dmi_container_xml(fn_src), "w");
+ f = File(pth_epub.fn_dmi_container_xml(doc_matters.source_filename), "w");
f.writeln(meta_inf_container_xml);
/+ OEBPS/toc.ncx +/
- f = File(pth_epub.fn_oebps_toc_ncx(fn_src), "w");
+ f = File(pth_epub.fn_oebps_toc_ncx(doc_matters.source_filename), "w");
f.writeln(oebps_toc_ncx);
/+ OEBPS/content.opf +/
- f = File(pth_epub.fn_oebps_content_opf(fn_src), "w");
+ f = File(pth_epub.fn_oebps_content_opf(doc_matters.source_filename), "w");
f.writeln(oebps_content_opf);
}
catch (ErrnoException ex) {
diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d
index ec8b74e..0406b3c 100644
--- a/src/sdp/output_html.d
+++ b/src/sdp/output_html.d
@@ -2,9 +2,9 @@ template outputHTML() {
struct outputHTML {
mixin outputXHTMLs;
- void scroll_write_output_file(Fn,D)(
+ void scroll_write_output_file(Fn,C)(
Fn fn_src,
- D doc,
+ C doc,
) {
debug(asserts){
static assert(is(typeof(fn_src) == string));
@@ -135,25 +135,22 @@ template outputHTML() {
doc = xhtml_format.scroll_head(doc_matters.dochead_meta) ~ doc_html ~ xhtml_format.tail;
scroll_write_output_file(doc_matters.source_filename, doc);
}
- void seg_write_output_files(Fn,FnS,D)(
- Fn fn_src,
- FnS seg_filenames,
- D doc_html,
+ void seg_write_output_files(M,C)(
+ M doc_matters,
+ C doc_html,
) {
debug(asserts){
- static assert(is(typeof(fn_src) == string));
- static assert(is(typeof(seg_filenames) == string[]));
static assert(is(typeof(doc_html) == string[][string]));
}
mixin SiSUpaths;
auto pth_html = HtmlPaths();
auto xhtml_format = outputXHTMLs();
- auto m = matchFirst(fn_src, rgx.src_fn);
+ auto m = matchFirst(doc_matters.source_filename, rgx.src_fn);
try {
- mkdirRecurse(pth_html.seg(fn_src));
- foreach (seg_filename; seg_filenames) {
+ mkdirRecurse(pth_html.seg(doc_matters.source_filename));
+ foreach (seg_filename; doc_matters.segnames) {
// writeln(__LINE__, ": ", fn);
- auto f = File(pth_html.fn_seg(fn_src, seg_filename), "w");
+ auto f = File(pth_html.fn_seg(doc_matters.source_filename, seg_filename), "w");
/+ // f.writeln(seg_head); // not needed built and inserted earlier +/
foreach (docseg; doc_html[seg_filename]) {
f.writeln(docseg);
@@ -165,16 +162,15 @@ template outputHTML() {
// Handle error
}
}
- void seg(C,T)(
+ void seg(C,M)(
auto ref const C contents,
- auto ref T doc_matters,
+ auto ref M doc_matters,
) {
auto xhtml_format = outputXHTMLs();
auto rgx = Rgx();
string[][string] doc_html;
string[] doc;
string segment_filename;
- string[] seg_filenames;
string[] top_level_headings = ["","","",""];
foreach (part; doc_matters.keys_seq_seg) {
foreach (obj; contents[part]) {
@@ -207,7 +203,6 @@ template outputHTML() {
}
break;
case 4:
- seg_filenames ~= obj.segment_anchor_tag;
segment_filename = obj.segment_anchor_tag;
doc_html[segment_filename] ~= xhtml_format.seg_head(doc_matters.dochead_meta); // consider placing seg_head here as can more easily populate it with lev4 info
foreach (top_level_heading; top_level_headings) {
@@ -314,7 +309,7 @@ template outputHTML() {
}
}
writeln(doc_matters.keys_seq_seg);
- seg_write_output_files(doc_matters.source_filename, seg_filenames, doc_html);
+ seg_write_output_files(doc_matters, doc_html);
}
auto html_css() {
string css;