aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp.d')
-rwxr-xr-xsrc/sdp.d199
1 files changed, 113 insertions, 86 deletions
diff --git a/src/sdp.d b/src/sdp.d
index 5ec249b..cf8af49 100755
--- a/src/sdp.d
+++ b/src/sdp.d
@@ -4,18 +4,21 @@
+/
/+ sdp: sisu document parser, see http://sisudoc.org +/
import
- compile_time_info, // sdp/compile_time_info.d
- ao_abstract_doc_source, // sdp/ao_abstract_doc_source.d
- ao_conf_make_meta, // sdp/ao_conf_make_meta.d
- ao_conf_make_meta_native, // sdp/ao_conf_make_meta_native.d
- ao_conf_make_meta_sdlang, // sdp/ao_conf_make_meta_sdlang.d
- ao_defaults, // sdp/ao_defaults.d
- ao_output_debugs, // sdp/ao_output_debugs.d
- ao_read_config_files, // sdp/ao_read_config_files.d
- ao_read_source_files, // sdp/ao_read_source_files.d
- ao_rgx, // sdp/ao_rgx.d
- output_hub, // output_hub.d
- output_html; // output_html.d
+ compile_time_info,
+ ao_abstract_doc_source,
+ ao_conf_make_meta,
+ ao_conf_make_meta_native,
+ ao_conf_make_meta_sdlang,
+ ao_defaults,
+ ao_output_debugs,
+ ao_read_config_files,
+ ao_read_source_files,
+ ao_rgx,
+ output_hub,
+ output_epub,
+ output_html,
+ output_xhtmls,
+ source_sisupod;
/+ sdlang http://sdlang.org +/
import sdlang; // sdlang.d
/+ std +/
@@ -29,6 +32,7 @@ private import
std.process,
std.stdio,
std.file,
+ std.path,
std.range,
std.regex,
std.string,
@@ -88,13 +92,15 @@ void main(string[] args) {
);
}
}
- bool[string] opt_action_bool = [
+ bool[string] _opt_action_bool = [
"assertions" : false,
"concordance" : false,
"digest" : false,
"docbook" : false,
"epub" : false,
"html" : false,
+ "html_seg" : false,
+ "html_scroll" : false,
"manifest" : false,
"ocn" : true,
"odt" : false,
@@ -121,38 +127,40 @@ void main(string[] args) {
];
auto helpInfo = getopt(args,
std.getopt.config.passThrough,
- "assert", "--assert set optional assertions on", &opt_action_bool["assertions"],
- "concordance", "--concordance file for document", &opt_action_bool["concordance"],
- "digest", "--digest hash digest for each object", &opt_action_bool["digest"],
- "docbook", "--docbook process docbook output", &opt_action_bool["docbook"],
- "epub", "--epub process epub output", &opt_action_bool["epub"],
- "html", "--html process html output", &opt_action_bool["html"],
- "manifest", "--manifest process manifest output", &opt_action_bool["manifest"],
- "ocn", "--ocn object cite numbers (default)", &opt_action_bool["ocn"],
- "odf", "--odf process odf:odt output", &opt_action_bool["odt"],
- "odt", "--odt process odf:odt output", &opt_action_bool["odt"],
- "pdf", "--pdf process pdf output", &opt_action_bool["pdf"],
- "pg", "--pg process postgresql output", &opt_action_bool["postgresql"],
- "postgresql", "--postgresql process postgresql output", &opt_action_bool["postgresql"],
- "qrcode", "--qrcode with document metadata", &opt_action_bool["qrcode"],
- "sisupod", "--sisupod sisupod source content bundled", &opt_action_bool["sisupod"],
- "source", "--source markup source text content", &opt_action_bool["source"],
- "sqlite", "--sqlite process sqlite output", &opt_action_bool["sqlite"],
- "text", "--text process text output", &opt_action_bool["text"],
- "txt", "--txt process text output", &opt_action_bool["text"],
- "verbose|v", "--verbose output to terminal", &opt_action_bool["verbose"],
- "xhtml", "--xhtml process xhtml output", &opt_action_bool["xhtml"],
- "xml-dom", "--xml-dom process xml dom output", &opt_action_bool["xml_dom"],
- "xml-sax", "--xml-sax process xml sax output", &opt_action_bool["xml_sax"],
- "section-toc", "--section-toc process table of contents (default)", &opt_action_bool["section_toc"],
- "section-body", "--section-body process document body (default)", &opt_action_bool["section_body"],
- "section-endnotes", "--section-endnotes process document endnotes (default)", &opt_action_bool["section_endnotes"],
- "section-glossary", "--section-glossary process document glossary (default)", &opt_action_bool["section_glossary"],
- "section-biblio", "--section-biblio process document biblio (default)", &opt_action_bool["section_biblio"],
- "section-bookindex", "--section-bookindex process document bookindex (default)", &opt_action_bool["section_bookindex"],
- "section-blurb", "--section-blurb process document blurb (default)", &opt_action_bool["section_blurb"],
- "backmatter", "--section-backmatter process document backmatter (default)", &opt_action_bool["backmatter"],
- "skip_output", "--skip-output", &opt_action_bool["skip_output"],
+ "assert", "--assert set optional assertions on", &_opt_action_bool["assertions"],
+ "concordance", "--concordance file for document", &_opt_action_bool["concordance"],
+ "digest", "--digest hash digest for each object", &_opt_action_bool["digest"],
+ "docbook", "--docbook process docbook output", &_opt_action_bool["docbook"],
+ "epub", "--epub process epub output", &_opt_action_bool["epub"],
+ "html", "--html process html output", &_opt_action_bool["html"],
+ "html_seg", "--html-seg process html output", &_opt_action_bool["html_seg"],
+ "html_scroll", "--html-seg process html output", &_opt_action_bool["html_scroll"],
+ "manifest", "--manifest process manifest output", &_opt_action_bool["manifest"],
+ "ocn", "--ocn object cite numbers (default)", &_opt_action_bool["ocn"],
+ "odf", "--odf process odf:odt output", &_opt_action_bool["odt"],
+ "odt", "--odt process odf:odt output", &_opt_action_bool["odt"],
+ "pdf", "--pdf process pdf output", &_opt_action_bool["pdf"],
+ "pg", "--pg process postgresql output", &_opt_action_bool["postgresql"],
+ "postgresql", "--postgresql process postgresql output", &_opt_action_bool["postgresql"],
+ "qrcode", "--qrcode with document metadata", &_opt_action_bool["qrcode"],
+ "sisupod", "--sisupod sisupod source content bundled", &_opt_action_bool["sisupod"],
+ "source", "--source markup source text content", &_opt_action_bool["source"],
+ "sqlite", "--sqlite process sqlite output", &_opt_action_bool["sqlite"],
+ "text", "--text process text output", &_opt_action_bool["text"],
+ "txt", "--txt process text output", &_opt_action_bool["text"],
+ "verbose|v", "--verbose output to terminal", &_opt_action_bool["verbose"],
+ "xhtml", "--xhtml process xhtml output", &_opt_action_bool["xhtml"],
+ "xml-dom", "--xml-dom process xml dom output", &_opt_action_bool["xml_dom"],
+ "xml-sax", "--xml-sax process xml sax output", &_opt_action_bool["xml_sax"],
+ "section-toc", "--section-toc process table of contents (default)", &_opt_action_bool["section_toc"],
+ "section-body", "--section-body process document body (default)", &_opt_action_bool["section_body"],
+ "section-endnotes", "--section-endnotes process document endnotes (default)", &_opt_action_bool["section_endnotes"],
+ "section-glossary", "--section-glossary process document glossary (default)", &_opt_action_bool["section_glossary"],
+ "section-biblio", "--section-biblio process document biblio (default)", &_opt_action_bool["section_biblio"],
+ "section-bookindex", "--section-bookindex process document bookindex (default)", &_opt_action_bool["section_bookindex"],
+ "section-blurb", "--section-blurb process document blurb (default)", &_opt_action_bool["section_blurb"],
+ "backmatter", "--section-backmatter process document backmatter (default)", &_opt_action_bool["backmatter"],
+ "skip_output", "--skip-output", &_opt_action_bool["skip_output"],
);
if (helpInfo.helpWanted) {
defaultGetoptPrinter("Some information about the program.", helpInfo.options);
@@ -210,70 +218,89 @@ void main(string[] args) {
/+ ↓ split header into make and meta +/
auto header_make_and_meta_tuple = head.headerContentAA(header, conf_doc_make_aa);
static assert(!isTypeTuple!(header_make_and_meta_tuple));
- string[string][string] dochead_make = header_make_and_meta_tuple[0];
- string[string][string] dochead_meta = header_make_and_meta_tuple[1];
+ string[string][string] _dochead_make = header_make_and_meta_tuple[0];
+ string[string][string] _dochead_meta = header_make_and_meta_tuple[1];
/+ ↓ document abstraction: process document, return abstraction as tuple +/
- auto t = abs.abstract_doc_source(content_body, dochead_make, dochead_meta, opt_action_bool);
+ auto t = abs.abstract_doc_source(content_body, _dochead_make, _dochead_meta, _opt_action_bool);
static assert(!isTypeTuple!(t));
- auto doc_ao_contents = t[0]; // head ~ toc ~ contents ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~blurb;
- auto doc_html_segnames = t[1];
+ auto doc_abstraction = t[0]; // head ~ toc ~ contents ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~blurb;
+ string[] doc_html_segnames = t[1];
string[][string] document_section_keys_sequenced = [
- "seg": ["head", "toc_seg", "body",],
+ "seg": ["head", "toc_seg", "body",],
"scroll": ["head", "toc_scroll", "body",]
];
- if (doc_ao_contents["endnotes_seg"].length > 1) {
- document_section_keys_sequenced["seg"] ~= "endnotes_seg";
+ if (doc_abstraction["endnotes"].length > 1) {
+ document_section_keys_sequenced["seg"] ~= "endnotes";
+ document_section_keys_sequenced["scroll"] ~= "endnotes";
}
- if (doc_ao_contents["endnotes_scroll"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "endnotes_scroll";
- }
- if (doc_ao_contents["glossary"].length > 1) {
- document_section_keys_sequenced["seg"] ~= "glossary";
+ if (doc_abstraction["glossary"].length > 1) {
+ document_section_keys_sequenced["seg"] ~= "glossary";
document_section_keys_sequenced["scroll"] ~= "glossary";
}
- if (doc_ao_contents["bibliography"].length > 1) {
- document_section_keys_sequenced["seg"] ~= "bibliography";
+ if (doc_abstraction["bibliography"].length > 1) {
+ document_section_keys_sequenced["seg"] ~= "bibliography";
document_section_keys_sequenced["scroll"] ~= "bibliography";
}
- if (doc_ao_contents["bookindex_seg"].length > 1) {
- document_section_keys_sequenced["seg"] ~= "bookindex_seg";
+ if (doc_abstraction["bookindex_seg"].length > 1) {
+ document_section_keys_sequenced["seg"] ~= "bookindex_seg";
}
- if (doc_ao_contents["bookindex_scroll"].length > 1) {
+ if (doc_abstraction["bookindex_scroll"].length > 1) {
document_section_keys_sequenced["scroll"] ~= "bookindex_scroll";
}
- if (doc_ao_contents["blurb"].length > 1) {
- document_section_keys_sequenced["seg"] ~= "blurb";
+ if (doc_abstraction["blurb"].length > 1) {
+ document_section_keys_sequenced["seg"] ~= "blurb";
document_section_keys_sequenced["scroll"] ~= "blurb";
}
- if ((opt_action_bool["html"])
- || (opt_action_bool["html_scroll"])
- || (opt_action_bool["html_seg"])
- || (opt_action_bool["epub"])) {
- document_section_keys_sequenced["seg"] ~= "tail";
+ if ((_opt_action_bool["html"])
+ || (_opt_action_bool["html_scroll"])
+ || (_opt_action_bool["html_seg"])
+ || (_opt_action_bool["epub"])) {
+ document_section_keys_sequenced["seg"] ~= "tail";
document_section_keys_sequenced["scroll"] ~= "tail";
}
+ struct DocumentMatters {
+ string[] keys_seq_seg() {
+ string[] _k = document_section_keys_sequenced["seg"];
+ return _k;
+ }
+ string[] keys_seq_scroll() {
+ string[] _k = document_section_keys_sequenced["scroll"];
+ return _k;
+ }
+ string[] segnames() {
+ string[] _k = doc_html_segnames;
+ return _k;
+ }
+ auto dochead_make() {
+ string[string][string] _k = _dochead_make;
+ return _k;
+ }
+ auto dochead_meta() {
+ string[string][string] _k = _dochead_meta;
+ return _k;
+ }
+ auto source_filename() {
+ string _k = fn_src;
+ return _k;
+ }
+ auto opt_action_bool() {
+ bool[string] _k = _opt_action_bool;
+ return _k;
+ }
+ }
+ auto doc_matters = DocumentMatters();
/+ ↓ debugs +/
debug(checkdoc) {
dbg.abstract_doc_source_debugs(
- doc_ao_contents,
- document_section_keys_sequenced,
- doc_html_segnames,
- dochead_make,
- dochead_meta,
- fn_src,
- opt_action_bool
+ doc_abstraction,
+ doc_matters,
);
}
/+ ↓ output hub +/
- if (!(opt_action_bool["skip_output"])) {
+ if (!(_opt_action_bool["skip_output"])) {
output.hub(
- doc_ao_contents,
- document_section_keys_sequenced,
- doc_html_segnames,
- dochead_make,
- dochead_meta,
- fn_src,
- opt_action_bool
+ doc_abstraction,
+ doc_matters,
);
}
scope(exit) {
@@ -285,7 +312,7 @@ void main(string[] args) {
}
destroy(content_body);
destroy(t);
- destroy(doc_ao_contents);
+ destroy(doc_abstraction);
destroy(doc_html_segnames);
destroy(fn_src);
}