aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2022-04-02 10:37:34 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2022-04-03 18:13:53 -0400
commit4b0ae05439e2f5c33c452bd39baed3b8198ccc4a (patch)
tree85c4bc117bdfd3ff1aa967c8a1d4f337db647444 /src
parentlatex header, work on (& some code formatting) (diff)
latex head adjustments
Diffstat (limited to 'src')
-rw-r--r--src/doc_reform/io_out/latex.d60
-rw-r--r--src/doc_reform/io_out/rgx.d5
-rw-r--r--src/doc_reform/meta/rgx.d1
-rwxr-xr-xsrc/doc_reform/spine.d7
4 files changed, 38 insertions, 35 deletions
diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d
index 1f58c35..fb7e2d8 100644
--- a/src/doc_reform/io_out/latex.d
+++ b/src/doc_reform/io_out/latex.d
@@ -316,9 +316,8 @@ template outputLaTeX() {
}
return PaperType();
}
- @safe string sp_char_esc(O)(
+ @safe string sp_char_ops()(
string _txt,
- const O obj,
) {
string _unescape_sp_char_esc()(string _txt) {
_txt = _txt
@@ -333,34 +332,27 @@ template outputLaTeX() {
format(q"┃%s%s┃", "$1", "$2"));
return _txt;
}
+ _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx.latex_special_char_for_escape);
+ _txt = replaceAll!(m => "{\\" ~ m[1] ~ "}")(_txt, rgx.latex_special_char_for_escape_and_braces);
+ _txt = replaceAll!(m => "''")(_txt, rgx.quotes_open_and_close);
+ _txt = replaceAll!(m => "$\\cdot$")(_txt, rgx.middle_dot);
+ _txt = replaceAll!(m => _unescape_sp_char_esc(m[0]))(_txt, rgx.latex_identify_inline_link);
+ _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx.latex_identify_inline_fontface);
+ return _txt;
+ }
+ @safe string sp_char_esc(O)(
+ string _txt,
+ const O obj,
+ ) {
if (obj.metainfo.is_a != "code") {
- _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx.latex_special_char_for_escape);
- _txt = replaceAll!(m => "{\\" ~ m[1] ~ "}")(_txt, rgx.latex_special_char_for_escape_and_braces);
- _txt = replaceAll!(m => _unescape_sp_char_esc(m[0]))(_txt, rgx.latex_identify_inline_link);
- _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx.latex_identify_inline_fontface);
+ _txt = _txt.sp_char_ops;
}
return _txt;
}
@safe string sp_char_esc_txt()(
string _txt,
) {
- string _unescape_sp_char_esc()(string _txt) {
- _txt = _txt
- .replaceAll(rgx.latex_special_char_escaped,
- format(q"┃%s┃", "$1"))
- .replaceAll(rgx.latex_special_char_escaped_braced,
- format(q"┃%s┃", "$1"));
- return _txt;
- }
- string _unescape_fontface_esc()(string _txt) {
- _txt = _txt.replaceAll(rgx.latex_identify_inline_fontface,
- format(q"┃%s%s┃", "$1", "$2"));
- return _txt;
- }
- _txt = replaceAll!(m => "\\" ~ m[1])(_txt, rgx.latex_special_char_for_escape);
- _txt = replaceAll!(m => "{\\" ~ m[1] ~ "}")(_txt, rgx.latex_special_char_for_escape_and_braces);
- _txt = replaceAll!(m => _unescape_sp_char_esc(m[0]))(_txt, rgx.latex_identify_inline_link);
- _txt = replaceAll!(m => _unescape_fontface_esc(m[0]))(_txt, rgx.latex_identify_inline_fontface);
+ _txt = _txt.sp_char_ops;
return _txt;
}
@safe string fontface()(
@@ -371,8 +363,8 @@ template outputLaTeX() {
.replaceAll(rgx.inline_bold, format(q"┃\begin{bfseries}%s\end{bfseries}┃", "$1"))
.replaceAll(rgx.inline_italics, format(q"┃\emph{%s}┃", "$1"))
.replaceAll(rgx.inline_italics, format(q"┃\uline{%s}┃", "$1"))
- .replaceAll(rgx.inline_superscript, format(q"┃$$^{\textrm{%s}}$$┃", "$1"))
- .replaceAll(rgx.inline_subscript, format(q"┃$$_{\textrm{%s}}$$┃", "$1"))
+ .replaceAll(rgx.inline_superscript, format(q"┃$$^{%s}$$┃", "$1"))
+ .replaceAll(rgx.inline_subscript, format(q"┃$$_{%s}$$┃", "$1"))
.replaceAll(rgx.inline_strike, format(q"┃\sout{%s}┃", "$1"))
.replaceAll(rgx.inline_insert, format(q"┃\uline{%s}┃", "$1"))
.replaceAll(rgx.inline_mono, format(q"┃\begin{monosp}%s\end{monosp}┃", "$1"))
@@ -1107,16 +1099,16 @@ template outputLaTeX() {
){
links_mono_or_color_set = links.mono.strip;
}
- string _latex_head = format(q"┃%%%% spine LaTeX output
-%%%% Generated by: %s
-%%%% D version: %s
-%s
+ string _latex_head = format(q"┃%%%% spine LaTeX output%s%s%s
%%%% %s %s
%s
%s
%s
\setlength{\marginparsep}{4mm}
\setlength{\marginparwidth}{8mm}
+\usepackage[scaled]{dejavu}
+\renewcommand*\familydefault{\sfdefault}
+\usepackage{inconsolata}
\usepackage[T1]{fontenc}
%% \usepackage[utf8]{inputenc}
\usepackage[english]{babel}
@@ -1124,8 +1116,6 @@ template outputLaTeX() {
\usepackage{polyglossia}
\setmainlanguage{%s}
\setotherlanguage{%s}
-\setmainfont{Liberation Sans}
-\setmonofont[Scale=0.85]{Liberation Mono}
\usepackage{alltt}
\usepackage{hyperref}
\hypersetup{
@@ -1170,6 +1160,8 @@ template outputLaTeX() {
\usepackage{graphicx}
\usepackage[tc]{titlepic}
\usepackage{amssymb}
+\usepackage{amsmath}
+\usepackage[cm]{sfmath}
\usepackage{listings}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{4}
@@ -1351,9 +1343,9 @@ template outputLaTeX() {
%% \usepackage{atbegshi} %% http://ctan.org/pkg/atbegshi %% (BUG tmp FIX deal with problem, remove first page which is blank)
%% \AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}} %% (BUG tmp FIX deal with problem, remove first page which is blank)
┃",
- doc_matters.opt.action.debug_do_latex ? "" : doc_matters.generator_program.name_and_version.strip,
- doc_matters.opt.action.debug_do_latex ? "" : doc_matters.generator_program.compiler.strip,
- doc_matters.opt.action.debug_do_latex ? "" : "", // "%%%% LaTeX output last Generated on: " ~ doc_matters.generator_program.stime.strip,
+ doc_matters.opt.action.generated_by ? " " ~ doc_matters.generator_program.name_and_version.strip : "",
+ doc_matters.opt.action.generated_by ? " (" ~ doc_matters.generator_program.compiler.strip ~ ")" : "",
+ doc_matters.opt.action.generated_by ? " (LaTeX output last Generated on: " ~ doc_matters.generator_program.stime.strip ~ ")" : "",
doc_matters.generator_program.project_name.strip,
doc_matters.generator_program.url_home.strip,
paper_size_orientation_latex.strip,
diff --git a/src/doc_reform/io_out/rgx.d b/src/doc_reform/io_out/rgx.d
index 07133e7..590e56a 100644
--- a/src/doc_reform/io_out/rgx.d
+++ b/src/doc_reform/io_out/rgx.d
@@ -62,6 +62,7 @@ static template spineRgxOut() {
static spaces_line_start = ctRegex!(`^(?P<opening_spaces>[ ]+)`, "mg");
static nbsp_char = ctRegex!(`░`, "mg");
static nbsp_chars = ctRegex!(`[░]+`, "mg");
+ static middle_dot = ctRegex!(`·`, "mg");
static src_pth_sst_or_ssm = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.](?P<extension>ss[tm]))$`);
static src_pth_pod_sst_or_ssm = ctRegex!(`^(?P<podpath>[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`);
static src_pth_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`);
@@ -83,6 +84,10 @@ static template spineRgxOut() {
static br_line_inline = ctRegex!(`┙`, "mg");
static br_line_spaced = ctRegex!(`┚`, "mg");
static brln = ctRegex!(`(?:\\\\)+`, "mg");
+ /+ quotation marks +/
+ static quotes_open_and_close = ctRegex!(`[“”]`, "mg");
+ static quote_open = ctRegex!(`[“]`, "mg");
+ static quote_close = ctRegex!(`[”]`, "mg");
/+ inline markup footnotes endnotes +/
static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg");
static inline_notes_al_special = ctRegex!(`【(?:[*+]\s+)(.+?)】`, "mg"); // TODO remove match when special footnotes are implemented
diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d
index 7f4815d..eb6d959 100644
--- a/src/doc_reform/meta/rgx.d
+++ b/src/doc_reform/meta/rgx.d
@@ -230,6 +230,7 @@ static template spineRgxIn() {
static spaces_line_start = ctRegex!(`^(?P<opening_spaces>[ ]+)`, "mg");
static nbsp_char = ctRegex!(`░`, "mg");
static nbsp_chars = ctRegex!(`[░]+`, "mg");
+ static middle_dot = ctRegex!(`·`, "mg");
static src_pth_sst_or_ssm = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.](?P<extension>ss[tm]))$`);
static src_pth_pod_sst_or_ssm = ctRegex!(`^(?P<podpath>[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*?[.]ss[tm])$`);
static src_pth_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9][a-zA-Z0-9._-]*)/pod[.]manifest$`);
diff --git a/src/doc_reform/spine.d b/src/doc_reform/spine.d
index 6f6f168..de069c9 100755
--- a/src/doc_reform/spine.d
+++ b/src/doc_reform/spine.d
@@ -130,6 +130,7 @@ string program_name = "spine";
"debug-stages" : false,
"digest" : false,
"epub" : false,
+ "generated-by" : false,
"curate" : false,
"curate-authors" : false,
"curate-topics" : false,
@@ -229,6 +230,7 @@ string program_name = "spine";
"dark", "alternative dark theme", &opts["dark"],
"digest", "hash digest for each object", &opts["digest"],
"epub", "process epub output", &opts["epub"],
+ "generated-by", "generated by headers (software version & time)", &opts["generated-by"],
"hide-ocn", "object cite numbers", &opts["hide-ocn"],
"html", "process html output", &opts["html"],
"html-link-curate", "place links back to curate in segmented html", &opts["html-link-curate"],
@@ -236,7 +238,7 @@ string program_name = "spine";
"html-seg", "process html output", &opts["html-seg"],
"html-scroll", "process html output", &opts["html-scroll"],
"lang", "=[lang code e.g. =en or =en,es]", &settings["lang"],
- "latex", "output for pdfs", &opts["latex"],
+ "latex", "latex output (for pdfs)", &opts["latex"],
"latex-color-links", "mono or color links for pdfs", &opts["latex-color-links"],
"light", "default light theme", &opts["light"],
"manifest", "process manifest output", &opts["manifest"],
@@ -394,6 +396,9 @@ string program_name = "spine";
@trusted bool epub() {
return opts["epub"];
}
+ @trusted bool generated_by() {
+ return opts["generated-by"];
+ }
@trusted bool html_curate_link() {
return (opts["html-link-curate"]) ? true : false;
}