aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2018-09-28 21:07:50 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-04-10 15:14:15 -0400
commit69c9a85008a58e74846e6e22420f3ecb2e840d32 (patch)
treef909fbf472f62192de4a622effd3513e6b749eb1
parentoutput xmls & sqlite, make doc_matter available (diff)
output xmls, work on internal links
-rw-r--r--org/default_regex.org3
-rw-r--r--org/output_xmls.org18
-rw-r--r--src/doc_reform/meta/rgx.d3
-rw-r--r--src/doc_reform/output/rgx.d3
-rw-r--r--src/doc_reform/output/xmls.d18
5 files changed, 38 insertions, 7 deletions
diff --git a/org/default_regex.org b/org/default_regex.org
index 1fd728a..65d7cf6 100644
--- a/org/default_regex.org
+++ b/org/default_regex.org
@@ -493,7 +493,8 @@ static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]
/+ inline markup footnotes endnotes +/
static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg");
static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.+?├)`, "mg");
-static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg");
+static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>\S+?)├`, "mg");
+static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg");
static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg");
static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg");
static url = ctRegex!(`https?://`, "mg");
diff --git a/org/output_xmls.org b/org/output_xmls.org
index 7a4338e..441ed95 100644
--- a/org/output_xmls.org
+++ b/org/output_xmls.org
@@ -464,6 +464,18 @@ auto inline_links(M,O)(
rgx.inline_seg_link,
"$1");
}
+ if (_xml_type == "seg" || _xml_type == "epub") {
+ if (auto m = _txt.match(rgx.inline_link_hash)) {
+ foreach (segname; doc_matters.xml.segnames) {
+ if (auto n = segname.match(m.captures[3])) {
+ _txt = _txt.replaceFirst(
+ rgx.inline_link_hash,
+ "┥$1┝┤$3" ~ _suffix ~ "├");
+ break;
+ }
+ }
+ }
+ }
_txt = (_txt)
.replaceAll(
rgx.inline_link_fn_suffix,
@@ -752,7 +764,7 @@ auto heading(M,O)(
if (obj.metainfo.object_number.empty) {
o = format(q"¶%s
<div class="substance">
- <h%s class="%s">%s
+ <h%s class="%s">%s<a name="%s"></a>
%s
</h%s>
</div>¶",
@@ -760,6 +772,7 @@ auto heading(M,O)(
obj.metainfo.heading_lev_markup,
obj.metainfo.is_a,
tags,
+ obj.tags.segment_anchor_tag,
_txt,
obj.metainfo.heading_lev_markup,
);
@@ -767,7 +780,7 @@ auto heading(M,O)(
o = format(q"¶%s
<div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <h%s class="%s" id="%s"><a name="%s"></a>%s
+ <h%s class="%s" id="%s"><a name="%s"></a>%s<a name="%s"></a>
%s
</h%s>
</div>¶",
@@ -779,6 +792,7 @@ auto heading(M,O)(
obj.metainfo.object_number,
obj.metainfo.object_number,
tags,
+ obj.tags.segment_anchor_tag,
_txt,
obj.metainfo.heading_lev_markup,
);
diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d
index a9b1739..00221de 100644
--- a/src/doc_reform/meta/rgx.d
+++ b/src/doc_reform/meta/rgx.d
@@ -253,7 +253,8 @@ static template DocReformRgxInit() {
/+ inline markup footnotes endnotes +/
static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg");
static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.+?├)`, "mg");
- static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg");
+ static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>\S+?)├`, "mg");
+ static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg");
static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg");
static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg");
static url = ctRegex!(`https?://`, "mg");
diff --git a/src/doc_reform/output/rgx.d b/src/doc_reform/output/rgx.d
index 74ef48c..f352732 100644
--- a/src/doc_reform/output/rgx.d
+++ b/src/doc_reform/output/rgx.d
@@ -63,7 +63,8 @@ static template DocReformOutputRgxInit() {
/+ inline markup footnotes endnotes +/
static inline_image = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>\d+)h(?P<height>\d+))\s*(?P<post>.*?┝┤.+?├)`, "mg");
static inline_image_without_dimensions = ctRegex!(`(?P<pre>┥)☼(?P<imginf>(?P<img>\S+?\.(?:jpg|gif|png)),w(?P<width>0)h(?P<height>0))\s*(?P<post>.*?┝┤.+?├)`, "mg");
- static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>.+?)├`, "mg");
+ static inline_link = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>\S+?)├`, "mg");
+ static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg");
static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg");
static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg");
static url = ctRegex!(`https?://`, "mg");
diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d
index e68a22d..7a1a812 100644
--- a/src/doc_reform/output/xmls.d
+++ b/src/doc_reform/output/xmls.d
@@ -349,6 +349,18 @@ template outputXHTMLs() {
rgx.inline_seg_link,
"$1");
}
+ if (_xml_type == "seg" || _xml_type == "epub") {
+ if (auto m = _txt.match(rgx.inline_link_hash)) {
+ foreach (segname; doc_matters.xml.segnames) {
+ if (auto n = segname.match(m.captures[3])) {
+ _txt = _txt.replaceFirst(
+ rgx.inline_link_hash,
+ "┥$1┝┤$3" ~ _suffix ~ "├");
+ break;
+ }
+ }
+ }
+ }
_txt = (_txt)
.replaceAll(
rgx.inline_link_fn_suffix,
@@ -591,7 +603,7 @@ template outputXHTMLs() {
if (obj.metainfo.object_number.empty) {
o = format(q"¶%s
<div class="substance">
- <h%s class="%s">%s
+ <h%s class="%s">%s<a name="%s"></a>
%s
</h%s>
</div>¶",
@@ -599,6 +611,7 @@ template outputXHTMLs() {
obj.metainfo.heading_lev_markup,
obj.metainfo.is_a,
tags,
+ obj.tags.segment_anchor_tag,
_txt,
obj.metainfo.heading_lev_markup,
);
@@ -606,7 +619,7 @@ template outputXHTMLs() {
o = format(q"¶%s
<div class="substance">
<label class="ocn"><a href="#%s" class="lnkocn">%s</a></label>
- <h%s class="%s" id="%s"><a name="%s"></a>%s
+ <h%s class="%s" id="%s"><a name="%s"></a>%s<a name="%s"></a>
%s
</h%s>
</div>¶",
@@ -618,6 +631,7 @@ template outputXHTMLs() {
obj.metainfo.object_number,
obj.metainfo.object_number,
tags,
+ obj.tags.segment_anchor_tag,
_txt,
obj.metainfo.heading_lev_markup,
);