From 42942142d1379e7e5361a641f837beb54b23a2f1 Mon Sep 17 00:00:00 2001
From: Ralph Amissah <ralph@amissah.com>
Date: Mon, 28 Nov 2016 20:03:08 -0500
Subject: discrete objects marks, output html work in progress

---
 org/ao_abstract_doc_source.org   |  77 ++++++++++++++++---------
 org/ao_defaults.org              |   2 +-
 org/output.org                   | 118 +++++++++++++++++++++++++++++++++++----
 src/sdp/ao_abstract_doc_source.d |  50 ++++++++---------
 src/sdp/ao_object_setter.d       |  21 +++++++
 src/sdp/ao_rgx.d                 |   2 +-
 src/sdp/output_html.d            | 100 +++++++++++++++++++++++++++++----
 7 files changed, 296 insertions(+), 74 deletions(-)

diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org
index b3c4cd6..690c029 100644
--- a/org/ao_abstract_doc_source.org
+++ b/org/ao_abstract_doc_source.org
@@ -842,7 +842,7 @@ if (the_document_body_section.length > 0) {
 #+name: abs_post
 #+BEGIN_SRC d
 debug(objectrelated2) { // check
-    writeln(line);
+  writeln(line);
 }
 /+
   Backmatter:
@@ -1088,7 +1088,7 @@ if (the_endnotes_section["seg"].length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["seg"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1105,7 +1105,7 @@ if (the_endnotes_section["scroll"].length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["scroll"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                  // attrib
@@ -1122,7 +1122,7 @@ if (the_glossary_section.length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["seg"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1137,7 +1137,7 @@ if (the_glossary_section.length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["scroll"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1154,7 +1154,7 @@ if (the_bibliography_section.length > 1){
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["seg"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1169,7 +1169,7 @@ if (the_bibliography_section.length > 1){
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["scroll"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1186,7 +1186,7 @@ if (the_bookindex_section["seg"].length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["seg"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1203,7 +1203,7 @@ if (the_bookindex_section["scroll"].length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["scroll"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1220,7 +1220,7 @@ if (the_blurb_section.length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["seg"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -1235,7 +1235,7 @@ if (the_blurb_section.length > 1) {
   );
   toc_txt_= munge.url_links(toc_txt_);
   the_table_of_contents_section["scroll"] ~=
-    set_abstract_object.contents_para(
+    set_abstract_object.contents_toc(
       "toc",
       toc_txt_,
       "",                   // attrib
@@ -3195,7 +3195,7 @@ struct ObjInlineMarkup {
       );
       toc_txt_= munge.url_links(toc_txt_);
       the_table_of_contents_section["scroll"] ~=
-        set_abstract_object.contents_para(
+        set_abstract_object.contents_toc(
           "toc",
           toc_txt_,
           "",                   // attrib
@@ -3209,7 +3209,7 @@ struct ObjInlineMarkup {
         "base_position" : 0,
       ];
       the_table_of_contents_section["scroll"] ~=
-        set_abstract_object.contents_para(
+        set_abstract_object.contents_toc(
           "toc",
           "Table of Contents",
           "",                   // attrib
@@ -3227,7 +3227,7 @@ struct ObjInlineMarkup {
       toc_txt_ = "{ Table of Contents }../toc.fn_suffix";
       toc_txt_= munge.url_links(toc_txt_);
       the_table_of_contents_section["seg"] ~=
-        set_abstract_object.contents_para(
+        set_abstract_object.contents_toc(
           "toc",
           toc_txt_,
           "",                   // attrib
@@ -3247,7 +3247,7 @@ struct ObjInlineMarkup {
       );
       toc_txt_= munge.url_links(toc_txt_);
       the_table_of_contents_section["seg"] ~=
-        set_abstract_object.contents_para(
+        set_abstract_object.contents_toc(
           "toc",
           toc_txt_,
           "",                   // attrib
@@ -3268,7 +3268,7 @@ struct ObjInlineMarkup {
         "base_position" : to!int(obj_["lev_markup_number"]),
       ];
       the_table_of_contents_section["seg"] ~=
-        set_abstract_object.contents_para(
+        set_abstract_object.contents_toc(
           "toc",
           toc_txt_,
           "",                   // attrib
@@ -3290,7 +3290,7 @@ struct ObjInlineMarkup {
         "base_position" : to!int(obj_["lev_markup_number"]),
       ];
       the_table_of_contents_section["seg"] ~=
-        set_abstract_object.contents_para(
+        set_abstract_object.contents_toc(
           "toc",
           toc_txt_,
           "",                   // attrib
@@ -4182,11 +4182,7 @@ struct NotesSection {
           m.captures[2]); // sometimes need segment name (segmented html & epub)
       }
       // TODO NEXT you need anchor for segments at this point ->
-      object_notes["seg"] ~=
-        munge.url_links(
-          "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
-          m.captures[1]
-        ) ~ " " ~ m.captures[2] ~ "』";
+      object_notes["anchor"] ~= "#note_" ~ m.captures[1] ~ "』";
       object_notes["seg"] ~= (segment_object_belongs_to.empty)
       ? (munge.url_links(
           "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
@@ -4218,9 +4214,11 @@ struct NotesSection {
     if (object_notes.length > 1) {
       endnotes_["seg"] = (split(object_notes["seg"], rgx.break_string))[0..$-1];
       endnotes_["scroll"] = (split(object_notes["scroll"], rgx.break_string))[0..$-1];
+      endnotes_["anchor"] = (split(object_notes["anchor"], rgx.break_string))[0..$-1];
     } else {
       endnotes_["seg"] = [];
       endnotes_["scroll"] = [];
+      endnotes_["anchor"] = [];
     }
     return endnotes_;
   }
@@ -4316,15 +4314,15 @@ struct NotesSection {
           1
         );
     }
-    foreach (endnote; endnotes_["seg"]) {
+    foreach (i, endnote; endnotes_["seg"]) {
       attrib="";
       the_endnotes_section["seg"] ~=
-        set_abstract_object.contents_endnote(endnote);
+        set_abstract_object.contents_endnote(endnote, endnotes_["anchor"][i]);
     }
-    foreach (endnote; endnotes_["scroll"]) {
+    foreach (i, endnote; endnotes_["scroll"]) {
       attrib="";
       the_endnotes_section["scroll"] ~=
-        set_abstract_object.contents_endnote(endnote);
+        set_abstract_object.contents_endnote(endnote, endnotes_["anchor"][i]);
     }
     auto t = tuple(the_endnotes_section, obj_cite_number);
     return t;
@@ -5066,12 +5064,38 @@ auto contents_para(
 }
 #+END_SRC
 
+*** toc                                                               :para:
+
+#+name: ao_object_setter_para
+#+BEGIN_SRC d
+auto contents_toc(
+  in string is_a,
+  in string object,
+  in string attrib,
+  in int obj_cite_number,
+  in int[string] indent,
+  in bool bullet
+) {
+  ObjComposite object_set;
+  object_set.use                      = "content";
+  object_set.of                       = "para";
+  object_set.is_a                     = "toc";
+  object_set.object                   = object.strip;
+  object_set.obj_cite_number          = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
+  object_set.para_attrib.indent_start = to!int(indent["hang_position"]);
+  object_set.para_attrib.indent_rest  = to!int(indent["base_position"]);
+  object_set.para_attrib.bullet       = false; // bullet;
+  return object_set;
+}
+#+END_SRC
+
 *** para_endnote                                                       :para:
 
 #+name: ao_object_setter_endnote
 #+BEGIN_SRC d
 auto contents_endnote(
   in string object,
+  in string tag,
 ) {
   auto m = (matchFirst(object, rgx.note_ref));
   string notenumber = to!string(m.captures[1]);
@@ -5082,6 +5106,7 @@ auto contents_endnote(
   object_set.is_a                     = "endnote";
   object_set.object                   = object.strip;
   object_set.obj_cite_number          = "";
+  object_set.anchor_tags              ~= [ tag ];
   object_set.para_attrib.indent_start = 0;
   object_set.para_attrib.indent_rest  = 0;
   object_set.para_attrib.bullet       = false;
diff --git a/org/ao_defaults.org b/org/ao_defaults.org
index 8dde679..b5ed652 100644
--- a/org/ao_defaults.org
+++ b/org/ao_defaults.org
@@ -672,7 +672,7 @@ static inline_notes_delimiter_al_regular_number_note  = ctRegex!(`【(\d+)\s+(.+
 static inline_al_delimiter_open_asterisk              = ctRegex!(`【\*`, "m");
 static inline_al_delimiter_open_plus                  = ctRegex!(`【\+`, "m");
 static inline_text_and_note_al                        = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg");
-static inline_text_and_note_al_                       = ctRegex!(`(.+?(?:【[*+ ]*.+?】|$))`, "mg");
+static inline_text_and_note_al_                       = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg");
 #+END_SRC
 
 ** links/ urls                                             :inline:footnote:
diff --git a/org/output.org b/org/output.org
index d17020f..b77c2dd 100644
--- a/org/output.org
+++ b/org/output.org
@@ -31,7 +31,7 @@ auto html_heading(O)(
   o = format(q"¶<br><hr /><br>
   <div class="substance">
     <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
-    <h%s class="norm" id="%s"><a name="%s"></a>
+    <h%s class="%s" id="%s"><a name="%s"></a>
       %s
     </h%s>
   </div>
@@ -39,6 +39,7 @@ auto html_heading(O)(
   obj.obj_cite_number,
   obj.obj_cite_number,
   obj.heading_attrib.lev_markup_number,
+  obj.is_a,
   obj.obj_cite_number,
   obj.obj_cite_number,
   obj.object,
@@ -54,19 +55,111 @@ auto html_heading(O)(
 #+BEGIN_SRC d
 auto html_para(O)(
   auto ref const O         obj,
+) {
+  string o;
+  if (obj.obj_cite_number.empty) {
+    o = format(q"¶<div class="substance">
+    <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
+    <p class="%s" attrib="h%si%s">
+      %s
+    </p>
+  </div>
+  ¶",
+      obj.obj_cite_number,
+      obj.obj_cite_number,
+      obj.is_a,
+      obj.para_attrib.indent_start,
+      obj.para_attrib.indent_rest,
+      obj.object
+    );
+  } else {
+    o = format(q"¶<div class="substance">
+    <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
+    <p class="%s" attrib="h%si%s" id="%s">
+      %s
+    </p>
+  </div>
+  ¶",
+      obj.obj_cite_number,
+      obj.obj_cite_number,
+      obj.is_a,
+      obj.para_attrib.indent_start,
+      obj.para_attrib.indent_rest,
+      obj.obj_cite_number,
+      obj.object
+    );
+  }
+  return o;
+}
+#+END_SRC
+
+***** html endnote
+
+#+name: output_html
+#+BEGIN_SRC d
+auto html_endnote(O)(
+  auto ref const O         obj,
+) {
+  string o;
+  o = format(q"¶<div class="substance">
+    <label class="tag"><a name="%s" a href="%s" class="lnkocn"></a></label>
+    <p class="%s" attrib="h%si%s">
+      %s
+    </p>
+  </div>
+  ¶",
+    obj.anchor_tags[0],
+    obj.anchor_tags[0],
+    obj.is_a,
+    obj.para_attrib.indent_start,
+    obj.para_attrib.indent_rest,
+    obj.object
+  );
+  return o;
+}
+#+END_SRC
+
+***** html toc
+
+#+name: output_html
+#+BEGIN_SRC d
+auto html_toc(O)(
+  auto ref const O         obj,
+) {
+  string o;
+  o = format(q"¶<div class="substance">
+    <p class="%s" attrib="h%si%s">
+      %s
+    </p>
+  </div>
+  ¶",
+  obj.is_a,
+  obj.para_attrib.indent_start,
+  obj.para_attrib.indent_rest,
+  obj.object
+  );
+  return o;
+}
+#+END_SRC
+
+***** html nugget
+
+#+name: output_html
+#+BEGIN_SRC d
+auto html_nugget(O)(
+  auto ref const O         obj,
 ) {
   string o;
   o = format(q"¶<div class="substance">
     <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
-    <p class="h%si%s" id="%s">
+    <p class="%s" id="%s">
       %s
     </p>
   </div>
   ¶",
   obj.obj_cite_number,
   obj.obj_cite_number,
-  obj.para_attrib.indent_start,
-  obj.para_attrib.indent_rest,
+  obj.is_a,
   obj.obj_cite_number,
   obj.object
   );
@@ -146,29 +239,34 @@ void scroll(C)(
         case "heading":
           body_html ~= html_heading(obj);
           break;
+        case "toc":
+          body_html ~= html_toc(obj);
+          break;
         case "para":
           body_html ~= html_para(obj);
           break;
         case "verse":
-          body_html ~= html_para(obj);
+          body_html ~= html_nugget(obj);
           break;
         case "group":
-          body_html ~= html_para(obj);
+          body_html ~= html_nugget(obj);
           break;
         case "block":
-          body_html ~= html_para(obj);
+          body_html ~= html_nugget(obj);
           break;
         case "quote":
-          body_html ~= html_para(obj);
+          body_html ~= html_nugget(obj);
           break;
         case "table":
           body_html ~= html_para(obj);
           break;
         case "code":
-          body_html ~= html_para(obj);
+          body_html ~= html_nugget(obj);
+          break;
+        case "endnote":
+          body_html ~= html_endnote(obj);
           break;
         default:
-          body_html ~= html_para(obj);
           break;
         }
       }
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d
index 9bfa6cb..51089cd 100644
--- a/src/sdp/ao_abstract_doc_source.d
+++ b/src/sdp/ao_abstract_doc_source.d
@@ -651,7 +651,7 @@ template SiSUdocAbstraction() {
       } /+ ← closed: loop markup document/text line by line +/
       /+ ↓ post loop markup document/text +/
       debug(objectrelated2) { // check
-          writeln(line);
+        writeln(line);
       }
       /+
         Backmatter:
@@ -814,7 +814,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["seg"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -831,7 +831,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["scroll"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                  // attrib
@@ -848,7 +848,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["seg"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -863,7 +863,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["scroll"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -880,7 +880,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["seg"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -895,7 +895,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["scroll"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -912,7 +912,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["seg"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -929,7 +929,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["scroll"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -946,7 +946,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["seg"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -961,7 +961,7 @@ template SiSUdocAbstraction() {
         );
         toc_txt_= munge.url_links(toc_txt_);
         the_table_of_contents_section["scroll"] ~=
-          set_abstract_object.contents_para(
+          set_abstract_object.contents_toc(
             "toc",
             toc_txt_,
             "",                   // attrib
@@ -2677,7 +2677,7 @@ template SiSUdocAbstraction() {
           );
           toc_txt_= munge.url_links(toc_txt_);
           the_table_of_contents_section["scroll"] ~=
-            set_abstract_object.contents_para(
+            set_abstract_object.contents_toc(
               "toc",
               toc_txt_,
               "",                   // attrib
@@ -2691,7 +2691,7 @@ template SiSUdocAbstraction() {
             "base_position" : 0,
           ];
           the_table_of_contents_section["scroll"] ~=
-            set_abstract_object.contents_para(
+            set_abstract_object.contents_toc(
               "toc",
               "Table of Contents",
               "",                   // attrib
@@ -2709,7 +2709,7 @@ template SiSUdocAbstraction() {
           toc_txt_ = "{ Table of Contents }../toc.fn_suffix";
           toc_txt_= munge.url_links(toc_txt_);
           the_table_of_contents_section["seg"] ~=
-            set_abstract_object.contents_para(
+            set_abstract_object.contents_toc(
               "toc",
               toc_txt_,
               "",                   // attrib
@@ -2729,7 +2729,7 @@ template SiSUdocAbstraction() {
           );
           toc_txt_= munge.url_links(toc_txt_);
           the_table_of_contents_section["seg"] ~=
-            set_abstract_object.contents_para(
+            set_abstract_object.contents_toc(
               "toc",
               toc_txt_,
               "",                   // attrib
@@ -2750,7 +2750,7 @@ template SiSUdocAbstraction() {
             "base_position" : to!int(obj_["lev_markup_number"]),
           ];
           the_table_of_contents_section["seg"] ~=
-            set_abstract_object.contents_para(
+            set_abstract_object.contents_toc(
               "toc",
               toc_txt_,
               "",                   // attrib
@@ -2772,7 +2772,7 @@ template SiSUdocAbstraction() {
             "base_position" : to!int(obj_["lev_markup_number"]),
           ];
           the_table_of_contents_section["seg"] ~=
-            set_abstract_object.contents_para(
+            set_abstract_object.contents_toc(
               "toc",
               toc_txt_,
               "",                   // attrib
@@ -3487,11 +3487,7 @@ template SiSUdocAbstraction() {
               m.captures[2]); // sometimes need segment name (segmented html & epub)
           }
           // TODO NEXT you need anchor for segments at this point ->
-          object_notes["seg"] ~=
-            munge.url_links(
-              "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
-              m.captures[1]
-            ) ~ " " ~ m.captures[2] ~ "』";
+          object_notes["anchor"] ~= "#note_" ~ m.captures[1] ~ "』";
           object_notes["seg"] ~= (segment_object_belongs_to.empty)
           ? (munge.url_links(
               "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
@@ -3517,9 +3513,11 @@ template SiSUdocAbstraction() {
         if (object_notes.length > 1) {
           endnotes_["seg"] = (split(object_notes["seg"], rgx.break_string))[0..$-1];
           endnotes_["scroll"] = (split(object_notes["scroll"], rgx.break_string))[0..$-1];
+          endnotes_["anchor"] = (split(object_notes["anchor"], rgx.break_string))[0..$-1];
         } else {
           endnotes_["seg"] = [];
           endnotes_["scroll"] = [];
+          endnotes_["anchor"] = [];
         }
         return endnotes_;
       }
@@ -3609,15 +3607,15 @@ template SiSUdocAbstraction() {
               1
             );
         }
-        foreach (endnote; endnotes_["seg"]) {
+        foreach (i, endnote; endnotes_["seg"]) {
           attrib="";
           the_endnotes_section["seg"] ~=
-            set_abstract_object.contents_endnote(endnote);
+            set_abstract_object.contents_endnote(endnote, endnotes_["anchor"][i]);
         }
-        foreach (endnote; endnotes_["scroll"]) {
+        foreach (i, endnote; endnotes_["scroll"]) {
           attrib="";
           the_endnotes_section["scroll"] ~=
-            set_abstract_object.contents_endnote(endnote);
+            set_abstract_object.contents_endnote(endnote, endnotes_["anchor"][i]);
         }
         auto t = tuple(the_endnotes_section, obj_cite_number);
         return t;
diff --git a/src/sdp/ao_object_setter.d b/src/sdp/ao_object_setter.d
index c48ddc0..844af9b 100644
--- a/src/sdp/ao_object_setter.d
+++ b/src/sdp/ao_object_setter.d
@@ -95,8 +95,28 @@ template ObjectSetter() {
       // object_set.node_structure.node   = _node;
       return object_set;
     }
+    auto contents_toc(
+      in string is_a,
+      in string object,
+      in string attrib,
+      in int obj_cite_number,
+      in int[string] indent,
+      in bool bullet
+    ) {
+      ObjComposite object_set;
+      object_set.use                      = "content";
+      object_set.of                       = "para";
+      object_set.is_a                     = "toc";
+      object_set.object                   = object.strip;
+      object_set.obj_cite_number          = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
+      object_set.para_attrib.indent_start = to!int(indent["hang_position"]);
+      object_set.para_attrib.indent_rest  = to!int(indent["base_position"]);
+      object_set.para_attrib.bullet       = false; // bullet;
+      return object_set;
+    }
     auto contents_endnote(
       in string object,
+      in string tag,
     ) {
       auto m = (matchFirst(object, rgx.note_ref));
       string notenumber = to!string(m.captures[1]);
@@ -107,6 +127,7 @@ template ObjectSetter() {
       object_set.is_a                     = "endnote";
       object_set.object                   = object.strip;
       object_set.obj_cite_number          = "";
+      object_set.anchor_tags              ~= [ tag ];
       object_set.para_attrib.indent_start = 0;
       object_set.para_attrib.indent_rest  = 0;
       object_set.para_attrib.bullet       = false;
diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d
index 3d531dc..f320867 100644
--- a/src/sdp/ao_rgx.d
+++ b/src/sdp/ao_rgx.d
@@ -144,7 +144,7 @@ template RgxInit() {
     static inline_al_delimiter_open_asterisk              = ctRegex!(`【\*`, "m");
     static inline_al_delimiter_open_plus                  = ctRegex!(`【\+`, "m");
     static inline_text_and_note_al                        = ctRegex!(`(?P<text>.+?)【(?:[*+ ]*)(?P<note>.+?)】`, "mg");
-    static inline_text_and_note_al_                       = ctRegex!(`(.+?(?:【[*+ ]*.+?】|$))`, "mg");
+    static inline_text_and_note_al_                       = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg");
     static inline_url                                      = ctRegex!(`((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+)`, "mg");
     static inline_link_naked_url                           = ctRegex!(`(^|[ ])((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg");
     static inline_link_markup_regular                      = ctRegex!(`(^|[ ])\{\s*(.+?)\s*\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg");
diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d
index 5552fe2..c20d6ef 100644
--- a/src/sdp/output_html.d
+++ b/src/sdp/output_html.d
@@ -7,7 +7,7 @@ template SiSUoutputHTML() {
       o = format(q"¶<br><hr /><br>
       <div class="substance">
         <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
-        <h%s class="norm" id="%s"><a name="%s"></a>
+        <h%s class="%s" id="%s"><a name="%s"></a>
           %s
         </h%s>
       </div>
@@ -15,6 +15,7 @@ template SiSUoutputHTML() {
       obj.obj_cite_number,
       obj.obj_cite_number,
       obj.heading_attrib.lev_markup_number,
+      obj.is_a,
       obj.obj_cite_number,
       obj.obj_cite_number,
       obj.object,
@@ -24,19 +25,93 @@ template SiSUoutputHTML() {
     }
     auto html_para(O)(
       auto ref const O         obj,
+    ) {
+      string o;
+      if (obj.obj_cite_number.empty) {
+        o = format(q"¶<div class="substance">
+        <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
+        <p class="%s" attrib="h%si%s">
+          %s
+        </p>
+      </div>
+      ¶",
+          obj.obj_cite_number,
+          obj.obj_cite_number,
+          obj.is_a,
+          obj.para_attrib.indent_start,
+          obj.para_attrib.indent_rest,
+          obj.object
+        );
+      } else {
+        o = format(q"¶<div class="substance">
+        <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
+        <p class="%s" attrib="h%si%s" id="%s">
+          %s
+        </p>
+      </div>
+      ¶",
+          obj.obj_cite_number,
+          obj.obj_cite_number,
+          obj.is_a,
+          obj.para_attrib.indent_start,
+          obj.para_attrib.indent_rest,
+          obj.obj_cite_number,
+          obj.object
+        );
+      }
+      return o;
+    }
+    auto html_endnote(O)(
+      auto ref const O         obj,
+    ) {
+      string o;
+      o = format(q"¶<div class="substance">
+        <label class="tag"><a name="%s" a href="%s" class="lnkocn"></a></label>
+        <p class="%s" attrib="h%si%s">
+          %s
+        </p>
+      </div>
+      ¶",
+        obj.anchor_tags[0],
+        obj.anchor_tags[0],
+        obj.is_a,
+        obj.para_attrib.indent_start,
+        obj.para_attrib.indent_rest,
+        obj.object
+      );
+      return o;
+    }
+    auto html_toc(O)(
+      auto ref const O         obj,
+    ) {
+      string o;
+      o = format(q"¶<div class="substance">
+        <p class="%s" attrib="h%si%s">
+          %s
+        </p>
+      </div>
+      ¶",
+      obj.is_a,
+      obj.para_attrib.indent_start,
+      obj.para_attrib.indent_rest,
+      obj.object
+      );
+      return o;
+    }
+    auto html_nugget(O)(
+      auto ref const O         obj,
     ) {
       string o;
       o = format(q"¶<div class="substance">
         <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
-        <p class="h%si%s" id="%s">
+        <p class="%s" id="%s">
           %s
         </p>
       </div>
       ¶",
       obj.obj_cite_number,
       obj.obj_cite_number,
-      obj.para_attrib.indent_start,
-      obj.para_attrib.indent_rest,
+      obj.is_a,
       obj.obj_cite_number,
       obj.object
       );
@@ -104,29 +179,34 @@ template SiSUoutputHTML() {
             case "heading":
               body_html ~= html_heading(obj);
               break;
+            case "toc":
+              body_html ~= html_toc(obj);
+              break;
             case "para":
               body_html ~= html_para(obj);
               break;
             case "verse":
-              body_html ~= html_para(obj);
+              body_html ~= html_nugget(obj);
               break;
             case "group":
-              body_html ~= html_para(obj);
+              body_html ~= html_nugget(obj);
               break;
             case "block":
-              body_html ~= html_para(obj);
+              body_html ~= html_nugget(obj);
               break;
             case "quote":
-              body_html ~= html_para(obj);
+              body_html ~= html_nugget(obj);
               break;
             case "table":
               body_html ~= html_para(obj);
               break;
             case "code":
-              body_html ~= html_para(obj);
+              body_html ~= html_nugget(obj);
+              break;
+            case "endnote":
+              body_html ~= html_endnote(obj);
               break;
             default:
-              body_html ~= html_para(obj);
               break;
             }
           }
-- 
cgit v1.2.3