diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2022-04-02 10:37:34 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2022-04-03 18:13:53 -0400 |
commit | 4b0ae05439e2f5c33c452bd39baed3b8198ccc4a (patch) | |
tree | 85c4bc117bdfd3ff1aa967c8a1d4f337db647444 | |
parent | latex header, work on (& some code formatting) (diff) |
latex head adjustments
-rw-r--r-- | org/default_regex.org | 12 | ||||
-rw-r--r-- | org/out_latex.org | 72 | ||||
-rw-r--r-- | org/spine.org | 7 | ||||
-rw-r--r-- | src/doc_reform/io_out/latex.d | 60 | ||||
-rw-r--r-- | src/doc_reform/io_out/rgx.d | 5 | ||||
-rw-r--r-- | src/doc_reform/meta/rgx.d | 1 | ||||
-rwxr-xr-x | src/doc_reform/spine.d | 7 |
7 files changed, 92 insertions, 72 deletions
diff --git a/org/default_regex.org b/org/default_regex.org index 8d7a26f..184a13d 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -446,6 +446,7 @@ static template spineRgxOut() { <<prgmkup_rgx_spaces>> <<prgmkup_rgx_filename_and_path>> <<prgmkup_rgx_inline_breaks>> + <<prgmkup_rgx_inline_quotes>> <<prgmkup_rgx_internal_footnotes_and_endnotes>> <<prgmkup_rgx_inline_links>> <<prgmkup_rgx_font_face>> @@ -507,6 +508,7 @@ static spaces_keep = ctRegex!(`(?P<keep_space static spaces_line_start = ctRegex!(`^(?P<opening_spaces>[ ]+)`, "mg"); static nbsp_char = ctRegex!(`░`, "mg"); static nbsp_chars = ctRegex!(`[░]+`, "mg"); +static middle_dot = ctRegex!(`·`, "mg"); #+END_SRC ** filename (& path) (including insert file) :insert:file:path:filename: @@ -544,6 +546,16 @@ static br_line_spaced = ctRegex!(`┚`, "mg"); static brln = ctRegex!(`(?:\\\\)+`, "mg"); #+END_SRC +*** quote marks + +#+NAME: prgmkup_rgx_inline_quotes +#+BEGIN_SRC d +/+ quotation marks +/ +static quotes_open_and_close = ctRegex!(`[“”]`, "mg"); +static quote_open = ctRegex!(`[“]`, "mg"); +static quote_close = ctRegex!(`[”]`, "mg"); +#+END_SRC + *** inline (internal program) markup footnotes endnotes :inline:footnote: #+NAME: prgmkup_rgx_internal_footnotes_and_endnotes diff --git a/org/out_latex.org b/org/out_latex.org index 817bbc8..a03c588 100644 --- a/org/out_latex.org +++ b/org/out_latex.org @@ -29,6 +29,7 @@ module doc_reform.io_out.latex; template outputLaTeX() { <<ImportsAndMixins_imports>> <<Function_shared_geometry_paper_dimensions>> + <<Function_shared_special_characters_to_escape_operations>> <<Function_shared_special_characters_to_escape_object>> <<Function_shared_special_characters_to_escape_text>> <<Function_shared_fontface>> @@ -112,6 +113,7 @@ template outputLaTeX() { #+END_SRC ** write latex output :latex:out: +*** write latex output :latex:out: #+NAME: Function_output_write #+BEGIN_SRC d @@ -153,7 +155,7 @@ void writeOutputLaTeX(T,M)( } #+END_SRC -** latex output hub [#A] :latex:pdf:out: +*** latex output hub [#A] :latex:pdf:out: #+NAME: Function_output_set #+BEGIN_SRC d @@ -459,11 +461,10 @@ auto paper() { *** latex \escape special characters **** general -#+NAME: Function_shared_special_characters_to_escape_object +#+NAME: Function_shared_special_characters_to_escape_operations #+BEGIN_SRC d -@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 @@ -478,38 +479,37 @@ auto paper() { 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; +} +#+END_SRC + +#+NAME: Function_shared_special_characters_to_escape_object +#+BEGIN_SRC d +@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; } #+END_SRC +**** string text + #+NAME: Function_shared_special_characters_to_escape_text #+BEGIN_SRC d @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; } #+END_SRC @@ -540,8 +540,8 @@ _txt = _txt .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")) @@ -1556,16 +1556,13 @@ if ( #+NAME: FmtTxtOpen_head_format_tex_set_start_latex_head #+BEGIN_SRC d -string _latex_head = format(q"┃%%%% spine LaTeX output +string _latex_head = format(q"┃%%%% spine LaTeX output%s%s%s #+END_SRC ***** description comment #+NAME: FmtTxtSet_head_tex_set_generated_by #+BEGIN_SRC latex -%%%% Generated by: %s -%%%% D version: %s -%s %%%% %s %s #+END_SRC @@ -1610,6 +1607,9 @@ string _latex_head = format(q"┃%%%% spine LaTeX output #+NAME: FmtTxtSet_head_tex_set_usepackages_languages_and_font #+BEGIN_SRC latex +\usepackage[scaled]{dejavu} +\renewcommand*\familydefault{\sfdefault} +\usepackage{inconsolata} \usepackage[T1]{fontenc} %% \usepackage[utf8]{inputenc} \usepackage[english]{babel} @@ -1617,8 +1617,6 @@ string _latex_head = format(q"┃%%%% spine LaTeX output \usepackage{polyglossia} \setmainlanguage{%s} \setotherlanguage{%s} -\setmainfont{Liberation Sans} -\setmonofont[Scale=0.85]{Liberation Mono} #+END_SRC %% \setsansfont{Liberation Sans} @@ -1704,6 +1702,8 @@ string _latex_head = format(q"┃%%%% spine LaTeX output \usepackage{graphicx} \usepackage[tc]{titlepic} \usepackage{amssymb} +\usepackage{amsmath} +\usepackage[cm]{sfmath} \usepackage{listings} \setcounter{secnumdepth}{2} \setcounter{tocdepth}{4} @@ -1932,9 +1932,9 @@ string _latex_head = format(q"┃%%%% spine LaTeX output #+NAME: FmtTxtClose_head_a_format_string_variables #+BEGIN_SRC d ┃", - 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/org/spine.org b/org/spine.org index ea133cc..4423f97 100644 --- a/org/spine.org +++ b/org/spine.org @@ -348,6 +348,7 @@ bool[string] opts = [ "debug-stages" : false, "digest" : false, "epub" : false, + "generated-by" : false, "curate" : false, "curate-authors" : false, "curate-topics" : false, @@ -461,6 +462,7 @@ auto helpInfo = getopt(args, "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"], @@ -468,7 +470,7 @@ auto helpInfo = getopt(args, "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"], @@ -633,6 +635,9 @@ struct OptActions { @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; } 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; } |