From 0524cd606d45ecc6ee52dc7c8f1655398c75712c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 2 Mar 2018 17:36:21 -0500 Subject: make auto numbering related --- org/default_misc.org | 9 ++-- org/meta_abstraction.org | 128 +++++++++++++++++--------------------------- org/meta_conf_make_meta.org | 76 +++++++++++++++++++------- org/sdp.org | 8 ++- 4 files changed, 117 insertions(+), 104 deletions(-) (limited to 'org') diff --git a/org/default_misc.org b/org/default_misc.org index 2fcef58..da1d0ae 100644 --- a/org/default_misc.org +++ b/org/default_misc.org @@ -32,6 +32,7 @@ module sdp.meta.defaults; #+END_SRC ** template: flags regex initialize :regex_flags: +*** flags #+name: meta_defaults_template_init_flags #+BEGIN_SRC d @@ -77,6 +78,8 @@ template SiSUrgxInitFlags() { } #+END_SRC +*** node + #+name: meta_defaults_template_node #+BEGIN_SRC d template SiSUnode() { @@ -205,8 +208,8 @@ import std.conv : to; #+END_SRC -* 2. defaults shared by meta & output (generic) -** template: internal markup :markup: +** defaults shared by meta & output (generic) +*** template: internal markup :markup: #+name: defaults_template_markup #+BEGIN_SRC d @@ -242,7 +245,7 @@ template InternalMarkup() { } #+END_SRC -** template language codes +*** template language codes #+name: defaults_template_language_codes #+BEGIN_SRC d diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 959de0c..b8ab4e6 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -5433,113 +5433,83 @@ private: static assert(is(typeof(munge_) == string)); static assert(is(typeof(obj_) == string[string])); } - if (conf_make_meta.make.num_top.length > 0) { - static __gshared int heading_num_top_level=9; - static __gshared int heading_num_depth=2; - static __gshared int heading_num_0 = 0; - static __gshared int heading_num_1 = 0; - static __gshared int heading_num_2 = 0; - static __gshared int heading_num_3 = 0; - static __gshared string heading_number_auto_composite = ""; - if (heading_num_top_level==9) { - if (conf_make_meta.make.num_depth.length > 0) { - heading_num_depth = conf_make_meta.make.num_depth.to!uint; - } - switch (conf_make_meta.make.num_top) { - case "A": - break; - case "B": - heading_num_top_level=1; - break; - case "C": - heading_num_top_level=2; - break; - case "D": - heading_num_top_level=3; - break; - case "1": - heading_num_top_level=4; - break; - case "2": - heading_num_top_level=5; - break; - case "3": - heading_num_top_level=6; - break; - case "4": - heading_num_top_level=7; - break; - default: - break; - } + static __gshared int[] heading_num = [ 0, 0, 0, 0 ]; + static __gshared string heading_number_auto_composite = ""; + if (conf_make_meta.make.auto_num_top_lv) { + if (obj_["lev_markup_number"].to!int == 0) { + heading_num[0] = 0; + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; + heading_number_auto_composite = ""; } /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/ if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv > obj_["lev_markup_number"].to!uint ) { - heading_num_1 = 0; - heading_num_2 = 0; - heading_num_3 = 0; + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == obj_["lev_markup_number"].to!uint ) { - heading_num_0 ++; - heading_num_1 = 0; - heading_num_2 = 0; - heading_num_3 = 0; + heading_num[0] ++; + heading_num[1] = 0; + heading_num[2] = 0; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == (obj_["lev_markup_number"].to!uint - 1) ) { - heading_num_1 ++; - heading_num_2 = 0; - heading_num_3 = 0; + heading_num[1] ++; + heading_num[2] = 0; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == (obj_["lev_markup_number"].to!uint - 2) ) { - heading_num_2 ++; - heading_num_3 = 0; + heading_num[2] ++; + heading_num[3] = 0; } else if ( - heading_num_top_level + conf_make_meta.make.auto_num_top_lv == (obj_["lev_markup_number"].to!uint - 3) ) { - heading_num_3 ++; + heading_num[3] ++; } - if (heading_num_3 > 0) { + if (heading_num[3] > 0) { heading_number_auto_composite - = (heading_num_depth == 3) - ? ( heading_num_0.to!string ~ "." - ~ heading_num_1.to!string ~ "." - ~ heading_num_2.to!string ~ "." - ~ heading_num_3.to!string + = (conf_make_meta.make.num_depth.to!uint == 3) + ? ( heading_num[0].to!string ~ "." + ~ heading_num[1].to!string ~ "." + ~ heading_num[2].to!string ~ "." + ~ heading_num[3].to!string ) : ""; - } else if (heading_num_2 > 0) { + } else if (heading_num[2] > 0) { heading_number_auto_composite - = ((heading_num_depth >= 2) - && (heading_num_depth <= 3)) - ? ( heading_num_0.to!string ~ "." - ~ heading_num_1.to!string ~ "." - ~ heading_num_2.to!string + = ((conf_make_meta.make.num_depth.to!uint >= 2) + && (conf_make_meta.make.num_depth.to!uint <= 3)) + ? ( heading_num[0].to!string ~ "." + ~ heading_num[1].to!string ~ "." + ~ heading_num[2].to!string ) : ""; - } else if (heading_num_1 > 0) { + } else if (heading_num[1] > 0) { heading_number_auto_composite - = ((heading_num_depth >= 1) - && (heading_num_depth <= 3)) - ? ( heading_num_0.to!string ~ "." - ~ heading_num_1.to!string + = ((conf_make_meta.make.num_depth.to!uint >= 1) + && (conf_make_meta.make.num_depth.to!uint <= 3)) + ? ( heading_num[0].to!string ~ "." + ~ heading_num[1].to!string ) : ""; - } else if (heading_num_0 > 0) { + } else if (heading_num[0] > 0) { heading_number_auto_composite - = ((heading_num_depth >= 0) - && (heading_num_depth <= 3)) - ? (heading_num_0.to!string) + = ((conf_make_meta.make.num_depth.to!uint >= 0) + && (conf_make_meta.make.num_depth.to!uint <= 3)) + ? (heading_num[0].to!string) : ""; } else { heading_number_auto_composite = ""; @@ -5548,7 +5518,7 @@ private: writeln(heading_number_auto_composite); } if ((!empty(heading_number_auto_composite)) - && (obj_["lev_markup_number"].to!uint >= heading_num_top_level)) { + && (obj_["lev_markup_number"].to!uint >= conf_make_meta.make.auto_num_top_lv)) { munge_=(munge_) .replaceFirst(rgx.heading, "$1~$2 " ~ heading_number_auto_composite ~ ". ") diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index fff5275..e784a87 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -74,8 +74,9 @@ struct ConfCompositeMakeStr { string home_button_image; string home_button_text; string italics; - string num_top; - string num_depth; + string auto_num_top_at_level; + int auto_num_top_lv = 9; + int num_depth = 2; string[][] substitute; string texpdf_font; } @@ -122,10 +123,13 @@ struct confCompositeMakeBuild { } return _out; } - auto num_top(string _mk) { + auto auto_num_top_at_level(string _mk) { return _mk; } - auto num_depth(string _mk) { + auto auto_num_top_lv(int _mk) { + return _mk; + } + auto num_depth(int _mk) { return _mk; } auto substitute(string[][] _mk) { @@ -153,8 +157,9 @@ struct ConfCompositeMakeInit { string home_button_image; string home_button_text; string[] italics; - string num_top; - string num_depth; + string auto_num_top_at_level; + int auto_num_top_lv = 9; + int num_depth = 2; string[][] substitute; string texpdf_font; } @@ -328,7 +333,7 @@ static auto ptr_head_sub_make "home_button_image", "home_button_text", "footer", "headings", - "num_top", "num_depth", + "auto_num_top_at_level", "auto_num_top_lv", "num_depth", "breaks", "substitute", "bold", @@ -370,9 +375,8 @@ auto config_jsonstr = `{ }`; #+END_SRC -* 1. JSON to SiSUstruct -** 1. module json :module:sdp:meta_conf_make_meta_json: -*** 0. module template +* 1. JSON to SiSUstruct :module:sdp:meta_conf_make_meta_json: +** 0. module template #+BEGIN_SRC d :tangle ../src/sdp/meta/conf_make_meta_json.d /++ @@ -419,7 +423,7 @@ static template contentJSONtoSiSUstruct() { } #+END_SRC -*** make +** make #+name: json_objects #+BEGIN_SRC d @@ -485,15 +489,46 @@ if ("make" in _json.object) { ) { _struct_composite.make_str.italics = _json.object["make"]["italics"].str; } - if ("num_top" in _json.object["make"] - && (_json.object["make"]["num_top"].type().to!string == "STRING") - ) { - _struct_composite.make_str.num_top = _json.object["make"]["num_top"].str; + if ("auto_num_top_at_level" in _json.object["make"] // str == A - D, 1 - 4 + && (_json.object["make"]["auto_num_top_at_level"].type().to!string == "STRING") + ) { + _struct_composite.make_str.auto_num_top_at_level = _json.object["make"]["auto_num_top_at_level"].str; + switch (_json.object["make"]["auto_num_top_at_level"].str) { + case "A": + break; + case "B": + _struct_composite.make_str.auto_num_top_lv = 1; + break; + case "C": + _struct_composite.make_str.auto_num_top_lv = 2; + break; + case "D": + _struct_composite.make_str.auto_num_top_lv = 3; + break; + case "1": + _struct_composite.make_str.auto_num_top_lv = 4; + break; + case "2": + _struct_composite.make_str.auto_num_top_lv = 5; + break; + case "3": + _struct_composite.make_str.auto_num_top_lv = 6; + break; + case "4": + _struct_composite.make_str.auto_num_top_lv = 7; + break; + default: + break; + } } if ("num_depth" in _json.object["make"] + && (_json.object["make"]["num_depth"].type().to!string == "INTEGER") + ) { + _struct_composite.make_str.num_depth = _json.object["make"]["num_depth"].integer.to!int; + } else if ("num_depth" in _json.object["make"] && (_json.object["make"]["num_depth"].type().to!string == "STRING") ) { - _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; + _struct_composite.make_str.num_depth = _json.object["make"]["num_depth"].str.to!int; } if ("substitute" in _json.object["make"]) { string[][] _sub; @@ -534,14 +569,15 @@ if ("make" in _json.object) { _struct_composite.make.home_button_image = _mk.home_button_image(_struct_composite.make_str.home_button_image); _struct_composite.make.home_button_text = _mk.home_button_text(_struct_composite.make_str.home_button_text); _struct_composite.make.italics = _mk.italics(_struct_composite.make_str.italics); - _struct_composite.make.num_top = _mk.num_top(_struct_composite.make_str.num_top); + _struct_composite.make.auto_num_top_at_level = _mk.auto_num_top_at_level(_struct_composite.make_str.auto_num_top_at_level); + _struct_composite.make.auto_num_top_lv = _mk.auto_num_top_lv(_struct_composite.make_str.auto_num_top_lv); _struct_composite.make.num_depth = _mk.num_depth(_struct_composite.make_str.num_depth); _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); _struct_composite.make.texpdf_font = _mk.texpdf_font(_struct_composite.make_str.texpdf_font); } #+END_SRC -*** conf +** conf #+name: json_objects #+BEGIN_SRC d @@ -713,7 +749,7 @@ if ("search" in _json.object) { } #+END_SRC -*** meta +** meta #+name: json_objects #+BEGIN_SRC d @@ -1075,7 +1111,7 @@ header. │   ├── home_button_image │   ├── home_button_text │   ├── italics - │   ├── num_top + │   ├── auto_num_top_at_level │   ├── substitute │   └── texpdf_font └── meta // metadata diff --git a/org/sdp.org b/org/sdp.org index 8530c4a..463b03f 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -441,7 +441,7 @@ struct OptActions { auto _opt_action = OptActions(); #+END_SRC -***** getopt processing path, _manifest[] >> +***** getopt processing path, _manifest[] >> #+NAME: sdp_args #+BEGIN_SRC d @@ -978,7 +978,7 @@ char_repeat_number = (char_repeat_number > min_repeat_number) ? char_repeat_number : min_repeat_number; writefln( - "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n(%s: %s)\n%s", + "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n(%s: %s)\n%s", markup.repeat_character_by_number_provided("-", char_repeat_number), doc_matters.conf_make_meta.meta.title_full, doc_matters.conf_make_meta.meta.creator_author, @@ -1014,6 +1014,10 @@ writefln( (doc_abstraction["blurb"].length > 1) ? (to!int(doc_abstraction["blurb"].length)) : 0, + "number of segments:", + (doc_matters.xml.segnames.length > 1) + ? (to!int(doc_matters.xml.segnames.length)) + : 0, __FILE__, __LINE__, markup.repeat_character_by_number_provided("-", min_repeat_number), -- cgit v1.2.3