diff options
Diffstat (limited to 'src/doc_reform/io_out')
-rw-r--r-- | src/doc_reform/io_out/latex.d | 60 | ||||
-rw-r--r-- | src/doc_reform/io_out/rgx.d | 5 |
2 files changed, 31 insertions, 34 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 |