aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--org/default_regex.org2
-rw-r--r--org/meta_abstraction.org3
-rw-r--r--org/output_xmls.org34
-rw-r--r--org/output_xmls_css.org77
-rw-r--r--src/doc_reform/meta/metadoc_from_src.d2
-rw-r--r--src/doc_reform/meta/object_setter.d1
-rw-r--r--src/doc_reform/meta/rgx.d2
-rw-r--r--src/doc_reform/output/xmls.d34
-rw-r--r--src/doc_reform/output/xmls_css.d231
9 files changed, 368 insertions, 18 deletions
diff --git a/org/default_regex.org b/org/default_regex.org
index e0ec4d3..575db42 100644
--- a/org/default_regex.org
+++ b/org/default_regex.org
@@ -196,7 +196,7 @@ static block_curly_table_special_markup = ctRegex!(`^[{]table[(](?
#+name: meta_rgx
#+BEGIN_SRC d
-static code_numbering = ctRegex!(`(?P<number>\bnumber\b)`);
+static code_numbering = ctRegex!(`(?P<number>\blinenumber\b|\bnumber\b|\blnr\b)`);
#+END_SRC
**** table
diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org
index 9257725..6408866 100644
--- a/org/meta_abstraction.org
+++ b/org/meta_abstraction.org
@@ -4297,6 +4297,7 @@ string[string] flow_block_flag_line_empty_(B,N,CMM,Ts)(
"code block status: closed"
);
assertions_flag_types_block_status_none_or_closed(obj_type_status);
+ static auto rgx = Rgx();
#+END_SRC
****** make: quote block
@@ -4554,6 +4555,7 @@ string[string] flow_block_flag_line_empty_(B,N,CMM,Ts)(
comp_obj_code.metainfo.object_number_type = obj_cite_digits.type;
comp_obj_code.metainfo.syntax = an_object["syntax"];
comp_obj_code.metainfo.attrib = an_object["attrib"];
+ comp_obj_code.code_block.linenumbers = (an_object["attrib"].match(rgx.code_numbering)) ? true : false;
comp_obj_code.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
comp_obj_code.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"];
comp_obj_code.text = an_object["substantive"];
@@ -7747,6 +7749,7 @@ struct DocObj_Table_ {
#+BEGIN_SRC d
struct DocObj_CodeBlock_ {
string syntax = "";
+ bool linenumbers = false;
}
#+END_SRC
diff --git a/org/output_xmls.org b/org/output_xmls.org
index 942897e..0a57127 100644
--- a/org/output_xmls.org
+++ b/org/output_xmls.org
@@ -1374,23 +1374,49 @@ string code(O,M)(
assert(obj.metainfo.is_of_type == "block");
assert(obj.metainfo.is_a == "code");
string o;
+ string codelines(string _txt) {
+ string _codelines;
+ if (obj.code_block.linenumbers) {
+ string[] _block_lines = (_txt).split(rgx.br_newlines_linebreaks);
+ _codelines = " <pre class=\"codeline\">\n";
+ foreach (k, _line; _block_lines) {
+ if (k == 1) {
+ _codelines ~= format(q"┃ <span class="tr first-row"><span class="th"></span><codeline>%s</codeline></span>
+┃",
+ _line,
+ );
+ } else {
+ _codelines ~= format(q"┃ <span class="tr"><span class="th"></span><codeline>%s</codeline></span>
+┃",
+ _line,
+ );
+ }
+ }
+ _codelines ~= " </pre>";
+ } else {
+ _codelines = " <pre class=\"codeline\">\n";
+ _codelines ~= _txt;
+ _codelines ~= " </pre>";
+ }
+ return _codelines;
+ }
if (!(obj.metainfo.identifier.empty)) {
o = format(q"┃ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <pre><p class="%s" id="%s">%s</p></pre>
+ <p class="%s" id="%s">%s</p>
</div>┃",
obj.metainfo.identifier,
(doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier),
obj.metainfo.is_a,
obj.metainfo.identifier,
- _txt
+ codelines(_txt)
);
} else {
o = format(q"┃ <div class="substance">
- <pre><p class="%s">%s</p></pre>
+ <p class="%s">%s</p>
</div>┃",
obj.metainfo.is_a,
- _txt
+ codelines(_txt)
);
}
return o;
diff --git a/org/output_xmls_css.org b/org/output_xmls_css.org
index 18eaa86..da374cf 100644
--- a/org/output_xmls_css.org
+++ b/org/output_xmls_css.org
@@ -324,7 +324,14 @@ template DocReformCss() {
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -342,6 +349,36 @@ template DocReformCss() {
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ /* background-color : #666666; */
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
#+END_SRC
***** paragraph general
@@ -1197,7 +1234,14 @@ Consider what if anything should be used here
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -1215,6 +1259,35 @@ Consider what if anything should be used here
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
#+END_SRC
***** paragraph general
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d
index 944189e..ec1e01a 100644
--- a/src/doc_reform/meta/metadoc_from_src.d
+++ b/src/doc_reform/meta/metadoc_from_src.d
@@ -3357,6 +3357,7 @@ template DocReformDocAbstraction() {
"code block status: closed"
);
assertions_flag_types_block_status_none_or_closed(obj_type_status);
+ static auto rgx = Rgx();
if (obj_type_status["quote"] == TriState.closing) {
obj_cite_digits = ocn_emit(obj_type_status["ocn_status"]);
an_object["bookindex_nugget"]
@@ -3584,6 +3585,7 @@ template DocReformDocAbstraction() {
comp_obj_code.metainfo.object_number_type = obj_cite_digits.type;
comp_obj_code.metainfo.syntax = an_object["syntax"];
comp_obj_code.metainfo.attrib = an_object["attrib"];
+ comp_obj_code.code_block.linenumbers = (an_object["attrib"].match(rgx.code_numbering)) ? true : false;
comp_obj_code.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
comp_obj_code.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"];
comp_obj_code.text = an_object["substantive"];
diff --git a/src/doc_reform/meta/object_setter.d b/src/doc_reform/meta/object_setter.d
index 6a95bcf..0ce74fd 100644
--- a/src/doc_reform/meta/object_setter.d
+++ b/src/doc_reform/meta/object_setter.d
@@ -101,6 +101,7 @@ template ObjectSetter() {
}
struct DocObj_CodeBlock_ {
string syntax = "";
+ bool linenumbers = false;
}
struct DocObj_Stow_ {
string[] link = [];
diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d
index 50665e1..926f2c6 100644
--- a/src/doc_reform/meta/rgx.d
+++ b/src/doc_reform/meta/rgx.d
@@ -100,7 +100,7 @@ static template DocReformRgxInit() {
static block_curly_table_open = ctRegex!(`^table(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$`);
static block_curly_table_close = ctRegex!(`^([}]table)`);
static block_curly_table_special_markup = ctRegex!(`^[{]table[(](?P<attrib>(?:(h);)?(?P<columns>(?:[, ]+[0-9]+)+))[)][}]`, "mg");
- static code_numbering = ctRegex!(`(?P<number>\bnumber\b)`);
+ static code_numbering = ctRegex!(`(?P<number>\blinenumber\b|\bnumber\b|\blnr\b)`);
static table_head_instructions = ctRegex!(`(?:(?P<c_heading>h);)?(?:[ ]+c(?P<c_num>[0-9]):)?(?P<c_widths>(?:[, ]+[0-9]+[lr]?)+)`);
static table_col_widths_and_alignment = ctRegex!(`(?P<width>[0-9]+)(?P<align>[lr]?)`);
static table_col_widths = ctRegex!(`(?P<widths>[0-9]+)`);
diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d
index 164613b..84028df 100644
--- a/src/doc_reform/output/xmls.d
+++ b/src/doc_reform/output/xmls.d
@@ -1164,23 +1164,49 @@ template outputXHTMLs() {
assert(obj.metainfo.is_of_type == "block");
assert(obj.metainfo.is_a == "code");
string o;
+ string codelines(string _txt) {
+ string _codelines;
+ if (obj.code_block.linenumbers) {
+ string[] _block_lines = (_txt).split(rgx.br_newlines_linebreaks);
+ _codelines = " <pre class=\"codeline\">\n";
+ foreach (k, _line; _block_lines) {
+ if (k == 1) {
+ _codelines ~= format(q"┃ <span class="tr first-row"><span class="th"></span><codeline>%s</codeline></span>
+ ┃",
+ _line,
+ );
+ } else {
+ _codelines ~= format(q"┃ <span class="tr"><span class="th"></span><codeline>%s</codeline></span>
+ ┃",
+ _line,
+ );
+ }
+ }
+ _codelines ~= " </pre>";
+ } else {
+ _codelines = " <pre class=\"codeline\">\n";
+ _codelines ~= _txt;
+ _codelines ~= " </pre>";
+ }
+ return _codelines;
+ }
if (!(obj.metainfo.identifier.empty)) {
o = format(q"┃ <div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <pre><p class="%s" id="%s">%s</p></pre>
+ <p class="%s" id="%s">%s</p>
</div>┃",
obj.metainfo.identifier,
(doc_matters.opt.action.ocn_off) ? "" : ((obj.metainfo.object_number.empty) ? "" : obj.metainfo.identifier),
obj.metainfo.is_a,
obj.metainfo.identifier,
- _txt
+ codelines(_txt)
);
} else {
o = format(q"┃ <div class="substance">
- <pre><p class="%s">%s</p></pre>
+ <p class="%s">%s</p>
</div>┃",
obj.metainfo.is_a,
- _txt
+ codelines(_txt)
);
}
return o;
diff --git a/src/doc_reform/output/xmls_css.d b/src/doc_reform/output/xmls_css.d
index 2c5697f..2ced969 100644
--- a/src/doc_reform/output/xmls_css.d
+++ b/src/doc_reform/output/xmls_css.d
@@ -609,7 +609,14 @@ template DocReformCss() {
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -627,6 +634,36 @@ template DocReformCss() {
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ /* background-color : #666666; */
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
p.spaced { white-space: pre; }
p.block {
white-space : pre;
@@ -1276,7 +1313,14 @@ template DocReformCss() {
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -1294,6 +1338,35 @@ template DocReformCss() {
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
p.spaced { white-space: pre; }
p.block {
white-space : pre;
@@ -1947,7 +2020,14 @@ template DocReformCss() {
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -1965,6 +2045,36 @@ template DocReformCss() {
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ /* background-color : #666666; */
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
p.spaced { white-space: pre; }
p.block {
white-space : pre;
@@ -2542,7 +2652,14 @@ template DocReformCss() {
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -2560,6 +2677,35 @@ template DocReformCss() {
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
p.spaced { white-space: pre; }
p.block {
white-space : pre;
@@ -3139,7 +3285,14 @@ template DocReformCss() {
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -3157,6 +3310,36 @@ template DocReformCss() {
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ /* background-color : #666666; */
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
p.spaced { white-space: pre; }
p.block {
white-space : pre;
@@ -3624,7 +3807,14 @@ template DocReformCss() {
clear : both;
color : #555555;
}
- p.code {
+ pre.codeline {
+ display : table;
+ clear : both;
+ table-layout : fixed;
+ margin-left : 5%%;
+ margin-right : 5%%;
+ width : 90%%;
+ white-space : pre-wrap;
border-style : none;
border-radius : 5px 5px 5px 5px;
box-shadow : 0 2px 5px #AAAAAA inset;
@@ -3642,6 +3832,35 @@ template DocReformCss() {
font-size : 95%%;
line-height : 100%%;
}
+ pre.codeline::before {
+ counter-reset : linenum;
+ }
+ pre.codeline span.tr {
+ display : table-row;
+ counter-increment : linenum;
+ }
+ pre.codeline span.th {
+ display : table-cell;
+ user-select : none;
+ -moz-user-select : none;
+ -webkit-user-select : none;
+ padding : 0.5em 0.5em;
+ }
+ pre.codeline span.th::before {
+ content : counter(linenum) ".";
+ color : #999999;
+ text-align : right;
+ display : block;
+ }
+ pre.codeline span.th {
+ width : 4em;
+ }
+ pre.codeline code {
+ display : table-cell;
+ }
+ p.code {
+ border-style : none;
+ }
p.spaced { white-space: pre; }
p.block {
white-space : pre;