diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2022-03-30 11:02:09 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2022-04-03 18:13:53 -0400 | 
| commit | 15d1dc27d81909b129a448ab343447180db8df38 (patch) | |
| tree | 03ae7fc7ca0ff5864e6836615b8f5b0860145a3f /src | |
| parent | latex head adjustments (diff) | |
latex doc headers moved to .sty files in ./sty dir
- some changes made, font selection included
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc_reform/io_out/hub.d | 25 | ||||
| -rw-r--r-- | src/doc_reform/io_out/latex.d | 708 | ||||
| -rw-r--r-- | src/doc_reform/io_out/paths_output.d | 44 | ||||
| -rwxr-xr-x | src/doc_reform/spine.d | 13 | 
4 files changed, 490 insertions, 300 deletions
| diff --git a/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d index 55dce8e..d0f5d3c 100644 --- a/src/doc_reform/io_out/hub.d +++ b/src/doc_reform/io_out/hub.d @@ -115,6 +115,12 @@ template outputHub() {        if (sched == outTask.latex) {          msg.v("latex processing... (available for downstream processing & pdf output");          import doc_reform.io_out.latex; +        import std.file; +        if ((isValidPath(doc_matters.output_path ~ "/latex/sty")) +          && (!(exists(doc_matters.output_path ~ "/latex/sty"))) +        ) { +          outputLaTeXstyInit!()(doc_matters.output_path); +        }          outputLaTeX!()(doc_abstraction, doc_matters);          msg.vv("latex done");        } @@ -157,6 +163,24 @@ template outputHub() {      }    }  } +template outputHubInitialize() { +  import doc_reform.io_out, +    doc_reform.io_out.metadata, +    doc_reform.io_out.paths_output; +  @system void outputHubInitialize(O)(O opt_action) { +    if ( +      opt_action.latex_document_header_sty +      || ( +        opt_action.latex +        && opt_action.output_dir_set.length > 0 +        && !(isValidPath(opt_action.output_dir_set ~ "/latex/sty"))) +    ) { // .sty need to be produced only once (if unchanged per output-dir of which there usually will be one) +      import doc_reform.io_out.latex; +      outputLaTeXstyInit!()(opt_action.output_dir_set); +    } +    writeln(opt_action.latex); +  } +}  template outputHubOp() {    import doc_reform.io_out,      doc_reform.io_out.metadata, @@ -187,6 +211,5 @@ template outputHubOp() {          writeln("sqlite create table done");        }      } -        }  } diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d index fb7e2d8..f54bb1a 100644 --- a/src/doc_reform/io_out/latex.d +++ b/src/doc_reform/io_out/latex.d @@ -49,20 +49,11 @@  +/  module doc_reform.io_out.latex; -template outputLaTeX() { +template paperLaTeX() {    import -    std.digest.sha, -    std.file, -    std.outbuffer, -    std.uri, +    std.format,      std.conv : to; -  import doc_reform.io_out; -  mixin InternalMarkup; // watch -  mixin spineRgxOut; -  static auto rgx = RgxO(); -  mixin spineLanguageCodes; -  auto lang = Lang(); -  auto paper() { +  auto paperLaTeX() {      string mm(uint mmi) {        string _mm = format(q"┃%smm┃", mmi.to!string);        return _mm; @@ -72,6 +63,7 @@ template outputLaTeX() {          struct A4 {            auto portrait() {              struct V { +              string       stylesheet    = "spineA4portrait";                string       papersize     = "a4paper";                string       orient        = "portrait";                string       fontsize      = "11pt"; @@ -94,6 +86,7 @@ template outputLaTeX() {            }            auto landscape() {              struct H { +              string       stylesheet    = "spineA4landscape";                string       papersize     = "a4paper";                string       orient        = "landscape";                string       fontsize      = "11pt"; @@ -121,6 +114,7 @@ template outputLaTeX() {          struct A5 {            auto portrait() {              struct V { +              string       stylesheet    = "spineA5portrait";                string       papersize     = "a5paper";                string       orient        = "portrait";                string       fontsize      = "11pt"; @@ -143,6 +137,7 @@ template outputLaTeX() {            }            auto landscape() {              struct H { +              string       stylesheet    = "spineA5landscape";                string       papersize     = "a5paper";                string       orient        = "landscape";                string       fontsize      = "11pt"; @@ -170,6 +165,7 @@ template outputLaTeX() {          struct B4 {            auto portrait() {              struct V { +              string       stylesheet    = "spineB4portrait";                string       papersize     = "b4paper";                string       orient        = "portrait";                string       fontsize      = "11pt"; @@ -192,6 +188,7 @@ template outputLaTeX() {            }            auto landscape() {              struct H { +              string       stylesheet    = "spineB4landsape";                string       papersize     = "b4paper";                string       orient        = "landscape";                string       fontsize      = "11pt"; @@ -219,6 +216,7 @@ template outputLaTeX() {          struct Letter {            auto portrait() {              struct V { +              string       stylesheet    = "spineLetterPortrait";                string       papersize     = "letterpaper";                string       orient        = "portrait";                string       fontsize      = "11pt"; @@ -241,6 +239,7 @@ template outputLaTeX() {            }            auto landscape() {              struct H { +              string       stylesheet    = "spineLetterLandscape";                string       papersize     = "letterpaper";                string       orient        = "landscape";                string       fontsize      = "11pt"; @@ -268,6 +267,7 @@ template outputLaTeX() {          struct Legal {            auto portrait() {              struct V { +              string       stylesheet    = "spineLegalPortrait";                string       papersize     = "legalpaper";                string       orient        = "portrait";                string       fontsize      = "11pt"; @@ -290,6 +290,7 @@ template outputLaTeX() {            }            auto landscape() {              struct H { +              string       stylesheet    = "spineLegalLandscape";                string       papersize     = "legalpaper";                string       orient        = "landscape";                string       fontsize      = "11pt"; @@ -316,6 +317,21 @@ template outputLaTeX() {      }      return PaperType();    } +} +template outputLaTeX() { +  import +    std.digest.sha, +    std.file, +    std.outbuffer, +    std.uri, +    std.conv : to; +  import doc_reform.io_out; +  mixin InternalMarkup; // watch +  mixin spineRgxOut; +  static auto rgx = RgxO(); +  mixin spineLanguageCodes; +  auto lang = Lang(); +  auto paper = paperLaTeX;    @safe string sp_char_ops()(      string      _txt,    ) { @@ -355,6 +371,13 @@ template outputLaTeX() {      _txt = _txt.sp_char_ops;      return _txt;    } +  @safe string marked_linebreaks_newlines()( +    string      _txt, +  ) { +    _txt = _txt.split(rgx.br_linebreaks_newlines).join("\\br\n").strip; +    // _txt = replaceAll!(m => "\\br " ~ m[1])(_txt, rgx.br_linebreaks_newlines); +    return _txt; +  }    @safe string fontface()(      string      _txt,    ) { @@ -668,8 +691,8 @@ template outputLaTeX() {              (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt,              (doc_matters.conf_make_meta.meta.title_main).sp_char_esc_txt,              (doc_matters.conf_make_meta.meta.title_full).sp_char_esc_txt, -            (doc_matters.conf_make_meta.meta.rights_copyright).sp_char_esc_txt, -            (doc_matters.conf_make_meta.meta.rights_license).sp_char_esc_txt, +            (doc_matters.conf_make_meta.meta.rights_copyright).sp_char_esc_txt.marked_linebreaks_newlines, +            (doc_matters.conf_make_meta.meta.rights_license).sp_char_esc_txt.marked_linebreaks_newlines,            );          } else if (obj.metainfo.heading_lev_markup < 4) {            if (!(_txt.footnotes.strip == "Endnotes")) { @@ -1000,10 +1023,6 @@ template outputLaTeX() {        string landscape;      }      auto multicol           = columnsMulti(); -    multicol.portrait    = format(q"┃ -\usepackage{multicol} -┃", -    );      multicol.landscape    = "";      struct colorLinks {        string mono; @@ -1031,44 +1050,65 @@ template outputLaTeX() {        if (paper_set.is_portrait) {          paper_type_description = format(q"┃  \documentclass[%s,%s,titlepage,makeidx]{scrartcl} -\usepackage{geometry} -\geometry{ -  %s, -  %s, -  left=%s, -  right=%s, -  top=%s, -  bottom=%s, -}┃", +\usepackage{%s} +\usepackage[%s,%s]{babel} +\usepackage[autostyle, english = american]{csquotes} +%% \MakeOuterQuote{"} %% not required, using '' as quote delimiter +\selectlanguage{%s} +\hypersetup{ +  pdftitle={%s}, +  pdfauthor={%s}, +  pdfsubject={%s}, +} +\usepackage{fancyhdr} +\lhead[ ]{ } +\chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark } +\rhead[ ]{ } +%s +\rfoot[\tiny \href{}{}]{\textrm{\thepage}} +        ┃",            paper_set.fontsize,            paper_set.papersize, -          paper_set.papersize, -          paper_set.orient, -          paper_set.margin_left, -          paper_set.margin_right, -          paper_set.margin_top, -          paper_set.margin_bottom, +          "./sty/" ~ paper_set.stylesheet, +          lang.codes[doc_matters.src.language]["xlp"], +          "english", +          lang.codes[doc_matters.src.language]["xlp"], +          doc_matters.conf_make_meta.meta.title_full.strip, +          doc_matters.conf_make_meta.meta.creator_author.strip, +          doc_matters.conf_make_meta.meta.classify_subject.strip, +          _footer(doc_matters),          );        } else {          paper_type_description = format(q"┃  \documentclass[%s,%s,landscape,titlepage,twocolumn,makeidx]{scrartcl} -\usepackage{geometry} -\geometry{ -  %s, -  %s, -  left=%s, -  right=%s, -  top=%s, -  bottom=%s, -}┃", +\usepackage{%s} +\usepackage[english]{babel} +%% \usepackage{polyglossia} +\setmainlanguage{%s} +\setotherlanguage{%s} +\selectlanguage{%s} +\hypersetup{ +  pdftitle={%s}, +  pdfauthor={%s}, +  pdfsubject={%s}, +} +\usepackage{fancyhdr} +\lhead[ ]{ } +\chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark } +\rhead[ ]{ } +%s +\rfoot[\tiny \href{}{}]{\textrm{\thepage}} +        ┃",            paper_set.fontsize,            paper_set.papersize, -          paper_set.papersize, -          paper_set.orient, -          paper_set.margin_left, -          paper_set.margin_right, -          paper_set.margin_top, -          paper_set.margin_bottom, +          "./sty/" ~ paper_set.stylesheet, +          lang.codes[doc_matters.src.language]["xlp"], +          "english", +          lang.codes[doc_matters.src.language]["xlp"], +          doc_matters.conf_make_meta.meta.title_full.strip, +          doc_matters.conf_make_meta.meta.creator_author.strip, +          doc_matters.conf_make_meta.meta.classify_subject.strip, +          _footer(doc_matters),          );        }        return paper_type_description; @@ -1103,245 +1143,6 @@ template outputLaTeX() {  %%%% %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} -\usepackage{newunicodechar} -\usepackage{polyglossia} -\setmainlanguage{%s} -\setotherlanguage{%s} -\usepackage{alltt} -\usepackage{hyperref} -\hypersetup{ -  unicode=true, -	pdfusetitle, -  pdftitle={%s}, -  pdfauthor={%s}, -  pdfsubject={%s}, -  pdfkeywords={},         %% keywords list {} {} {}, -  pdftoolbar=true, -  pdfmenubar=true, -  pdfwindowui=true, -  pdffitwindow=false,     %% window fit to page when opened -  pdfstartview={FitH},    %% fits the width of the page to the window -  pdfnewwindow=true,      %% links in new window -  pdfborder={0 0 1}, -  plainpages=false,       %% was true -  bookmarks=true, -  bookmarksopen=false, -  bookmarksnumbered=false, -  backref=false, -  breaklinks=false, -  %% colorlinks=true, -  %% urlcolor=black, -  %% filecolor=black, -  %% linkcolor=black, -  %% citecolor=black, -%s                        %% links_mono_or_color_set -} -\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref} -\usepackage[usenames]{color} -\definecolor{myblack}{rgb}{0,0,0} -\definecolor{myred}{rgb}{0.75,0,0} -\definecolor{mygreen}{rgb}{0,0.5,0} -\definecolor{myblue}{rgb}{0,0,0.5} -\definecolor{mywhite}{rgb}{1,1,1} -\usepackage{textcomp} -\usepackage[parfill]{parskip} -\usepackage[normalem]{ulem} -\usepackage{soul} -\usepackage{longtable} -\usepackage{graphicx} -\usepackage[tc]{titlepic} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage[cm]{sfmath} -\usepackage{listings} -\setcounter{secnumdepth}{2} -\setcounter{tocdepth}{4} -\usepackage{bookmark} -\usepackage{microtype} -\makeatletter -\usepackage[multiple,ragged]{footmisc} -\setlength\footnotemargin{12pt} -\usepackage[para]{manyfoot} -\DeclareNewFootnote{A} -\usepackage{fancyhdr} -\selectlanguage{%s} -\lhead[ ]{ } -\chead[ \fancyplain{} \bfseries \footnotesize \leftmark ]{ \fancyplain{} \bfseries \footnotesize \rightmark } -\rhead[ ]{ } -%s -\rfoot[\tiny \href{}{}]{\textrm{\thepage}} -%% \tolerance=300 -%% \clubpenalty=300 -%% \widowpenalty=300 -\makeatother -\chardef\txtbullet="2022 -\chardef\tilde="7E -\def\asterisk{{\rm \char42} } -\definecolor{Light}{gray}{.92} -\definecolor{listinggray}{gray}{0.9} -\definecolor{lbcolor}{rgb}{0.9,0.9,0.9} -\lstset{ -  backgroundcolor=\color{lbcolor}, -  tabsize=4, -  rulecolor=, -  language=, -  basicstyle={\ttfamily\scriptsize}, -  upquote=true, -  columns=fixed, -  showstringspaces=false, -  extendedchars=true, -  breaklines=true, -  prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}}, -  frame=single, -  showtabs=false, -  showspaces=false, -  showstringspaces=false, -  identifierstyle=\ttfamily, -  keywordstyle=\color[rgb]{0,0,1}, -  commentstyle=\color[rgb]{0.133,0.545,0.133}, -  stringstyle=\color[rgb]{0.627,0.126,0.941}, -} -\DeclareTOCStyleEntry[numwidth+=8pt]{part}{part} -\DeclareTOCStyleEntry[numwidth+=4pt]{section}{section} -\DeclareTOCStyleEntry[numwidth+=3pt]{section}{paragraph} -\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subparagraph} -\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subsection} -\DeclareTOCStyleEntries[indent+=4pt]{section}{section,subsection,subsubsection} -\DeclareTOCStyleEntries[numwidth+=3pt]{section}{paragraph,subparagraph} -\newenvironment{ParagraphIndent}[1]{%% -  \begin{list}{}{%% -    \setlength\topsep{0pt}%% -    \addtolength{\leftmargin}{#1} -    \setlength\parsep{0pt plus 1pt}%% -  } -  \item[] -} {\end{list}} -\newenvironment{ParagraphHang}[2]{%% -  \begin{list}{}{%% -    \setlength\topsep{0pt}%% -    \addtolength{\leftmargin}{#1} -    \itemindent=#2 -    \setlength\parsep{0pt plus 1pt}%% -  } -  \item[] -} {\end{list}} -\newenvironment{Bullet}[1]{%% -  \begin{list}{}{%% -    \setlength\topsep{0pt}%% -    \addtolength{\leftmargin}{#1} -    \itemindent=-1em -    \setlength\parsep{0pt plus 1pt}%% -  } -  \item[] -  $\txtbullet$\hspace{\enspace} -} {\end{list}} -\newcommand{\monosp}[1]{\normaltext\ttfamily\texbackslash#1} -\newcommand{\br}{\hfill\break} -\newcommand{\brl}[1]{%% -  \ifx&%% -    \hfill\break -  \else -    \vspace{#1ex} -  \fi -} -\newcommand{\brln}{\hspace*{\fill}\linebreak} -\newcommand{\objBlockOpen}{ -  \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}\raggedright -  \begin{footnotesize} -} -\newcommand{\objBlockClose}{%% -  \end{footnotesize} -  \setlength{\parskip}{1ex plus0.5ex minus0.2ex} -} -\newcommand{\objGroupOpen}{%% -  \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex} -  \begin{footnotesize} -} -\newcommand{\objGroupClose}{%% -  \end{footnotesize} -} -\newcommand{\objPoemVerseOpen}{%% -  \setlength{\parskip}{0.1ex plus0.1ex minus0.1ex} -  \begin{footnotesize} - -} -\newcommand{\objPoemVerseClose}{%% - -  \end{footnotesize} -  \setlength{\parskip}{1ex plus0.5ex minus0.2ex} -  \linebreak -} -\newcommand{\parasep}{%% -  \smallskip \begin{center}*\hspace{2em}*\hspace{2em}*\end{center} \br -} -\newcommand{\spaces}[1]{{\hspace*{#1ex}}} -\newcommand{\s}{\hspace*{1ex}} -\newcommand{\hardspace}{\hspace*{1ex}} -\newcommand{\-}{\hspace*{1ex}} -\newcommand{\caret}{{\^{~}}} -\newcommand{\pipe}{{\textbar}} -\newcommand{\curlyOpen}{{} -\newcommand{\curlyClose}{}} -\newcommand{\lt}{{UseTextSymbol{OML}{<}}} -\newcommand{\gt}{{UseTextSymbol{OML}{>}}} -\newcommand{\slash}{{/}} -\newcommand{\underscore}{\_} -\newcommand{\exclaim}{\Verbatim{!}} -\newcommand{\linktext}[2]{%% -  {\href{#1} -  {\;\ulcorner\,\textup{{#2}}\,\lrcorner}} -} -\newcommand{\linkurl}[2]{%% -  \;{\href{#1} -  {\;\scriptsize\ttfamily\ulcorner\,\textup{{#2}}\,\lrcorner}} -} -\newcommand{\link}[2]{%% -  {\begin{scriptsize}\color{black}\urlstyle{tt}\href{#1} -  {\;\ulcorner\,{#2}\,\lrcorner}\end{scriptsize}} -} -\newcommand{\objCodeBlock}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} -\newcommand{\objCodeOpen}{%% -  \normaltext\raggedright\small\ttfamily\texbackslash -  \begin{lstlisting} -} -\newcommand{\objCodeClose}{%% -  \end{lstlisting} -} -\newcommand{\ocn}[1]{%% -  \setlength{\parindent}{0em} -  \ifx&%% -    %% #1 is empty -    \hspace{-0.5ex}{\marginpar{\begin{tiny}\end{tiny}}} -  \else -    %% #1 is nonempty -    \hspace{-0.5ex}{\marginpar{\begin{tiny}\hspace{0em}\hypertarget{#1}{#1}\end{tiny}}} -  \fi -} -\newcommand{\ocnhold}[1]{%% -  \begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}} -} -\newcommand{\objCodeBlockHold}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} -\newcommand{\objTableOpen}[1]{%% -  \setlength{\LTleft}{0pt} -  \setlength{\LTright}{\fill} -  \begin{tiny} -  \begin{longtable}{#1} -} -\newcommand{\objTableClose}{%% -  \end{longtable} -  \end{tiny} -} -%% \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.generated_by ? " " ~ doc_matters.generator_program.name_and_version.strip : "",        doc_matters.opt.action.generated_by ? " (" ~ doc_matters.generator_program.compiler.strip ~ ")" : "", @@ -1350,15 +1151,6 @@ template outputLaTeX() {        doc_matters.generator_program.url_home.strip,        paper_size_orientation_latex.strip,        margins.portrait.strip, -      multicol.portrait.strip, -      lang.codes[doc_matters.src.language]["xlp"], -      "english", -      doc_matters.conf_make_meta.meta.title_full.strip, -      doc_matters.conf_make_meta.meta.creator_author.strip, -      doc_matters.conf_make_meta.meta.classify_subject.strip, -      links_mono_or_color_set, -      lang.codes[doc_matters.src.language]["xlp"], -      _footer(doc_matters),      );      return _latex_head.strip;    } @@ -1588,3 +1380,327 @@ template outputLaTeX() {      }    }  } +template outputLaTeXstyInit() { +  import doc_reform.io_out; +  mixin spineRgxOut; +  auto paper = paperLaTeX; +  void writeOutputLaTeXstyStatic( +    string latex_sty, +    string output_dir, +    string filename, +  ) { +    if ((output_dir.length > 0) +      && isValidPath(output_dir) +    ) { +      auto pth_latex = spinePathsLaTeXsty(output_dir); +      try { +        import std.file; +        if (!exists(pth_latex.base_sty)) { +          (pth_latex.base_sty).mkdirRecurse; +        } +        auto f = File(pth_latex.latex_document_header_sty(filename), "w"); +        f.writeln(latex_sty); +      } catch (ErrnoException ex) { +        // handle error +      } +    } +  } +  void outputLaTeXstyInit()(string output_dir,) { +    string latex_sty = outputLaTeXstyStatic!(); +    latex_sty.writeOutputLaTeXstyStatic(output_dir, "spineShared.sty"); +    auto sty_a4p      = paper.a4.portrait; +    auto latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a4p); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a4p.stylesheet ~ ".sty"); +    auto sty_a4l      = paper.a4.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a4l); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a4l.stylesheet ~ ".sty"); +    auto sty_b4p      = paper.b4.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_b4p); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_b4p.stylesheet ~ ".sty"); +    auto sty_b4l      = paper.b4.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_b4l); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_b4l.stylesheet ~ ".sty"); +    auto sty_a5p      = paper.a5.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a5p); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a5p.stylesheet ~ ".sty"); +    auto sty_a5l      = paper.a5.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_a5l); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_a5l.stylesheet ~ ".sty"); +    auto sty_letter_p  = paper.letter.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_letter_p); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_letter_p.stylesheet ~ ".sty"); +    auto sty_letter_l  = paper.letter.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_letter_l); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_letter_l.stylesheet ~ ".sty"); +    auto sty_legal_p   = paper.legal.portrait; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_legal_p); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_legal_p.stylesheet ~ ".sty"); +    auto sty_legal_l   = paper.legal.landscape; +    latex_papersize_and_orientation = outputLaTeXstyPaperSizeAndOrientation!()(sty_legal_l); +    latex_papersize_and_orientation.writeOutputLaTeXstyStatic(output_dir, sty_legal_l.stylesheet ~ ".sty"); +  } +} +template outputLaTeXstyStatic() { +  import +    std.format, +    std.conv : to; +  string outputLaTeXstyStatic() { +    string latex_sty = format(q"┃%% - called by the .sty containing the paper dimensions (size and orientation) to be used +%% - spineShared.sty used by all spine documents (called indirectly) +\ProvidesPackage{./sty/spineShared} +\usepackage{multicol} +\setlength{\marginparsep}{4mm} +\setlength{\marginparwidth}{8mm} +\usepackage[scaled]{dejavu} +\renewcommand*\familydefault{\sfdefault} +\usepackage{inconsolata} +\usepackage[T1]{fontenc} +\usepackage{newunicodechar} +%% \usepackage[utf8]{inputenc} +\usepackage{alltt} +\usepackage[ +  unicode=true, +	pdfusetitle, +  pdfsubject={}, +  pdfkeywords={},         %% keywords list {} {} {}, +  pdftoolbar=true, +  pdfmenubar=true, +  pdfwindowui=true, +  pdffitwindow=false,     %% window fit to page when opened +  pdfstartview={FitH},    %% fits the width of the page to the window +  pdfnewwindow=true,      %% links in new window +  pdfborder={0 0 1}, +  plainpages=false,       %% was true +  bookmarks=true, +  bookmarksopen=false, +  bookmarksnumbered=false, +  backref=false, +  breaklinks=false, +  colorlinks=true, +  urlcolor=black, +  filecolor=black, +  linkcolor=black, +  citecolor=black,        %% links_mono_or_color_set +]{hyperref} +\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref} +\usepackage[usenames]{color} +\definecolor{myblack}{rgb}{0,0,0} +\definecolor{myred}{rgb}{0.75,0,0} +\definecolor{mygreen}{rgb}{0,0.5,0} +\definecolor{myblue}{rgb}{0,0,0.5} +\definecolor{mywhite}{rgb}{1,1,1} +\usepackage{textcomp} +\usepackage[parfill]{parskip} +\usepackage[normalem]{ulem} +\usepackage{soul} +\usepackage{longtable} +\usepackage{graphicx} +\usepackage[tc]{titlepic} +\usepackage{amssymb} +\usepackage{amsmath} +\usepackage[cm]{sfmath} +\usepackage{underscore} +\usepackage{listings} +\setcounter{secnumdepth}{2} +\setcounter{tocdepth}{4} +\usepackage{bookmark} +\usepackage{microtype} +\makeatletter +\usepackage[multiple,ragged]{footmisc} +\setlength\footnotemargin{12pt} +\usepackage[para]{manyfoot} +\DeclareNewFootnote{A} +\makeatother +\chardef\txtbullet="2022 +\chardef\tilde="7E +\def\asterisk{{\rm \char42} } +\definecolor{Light}{gray}{.92} +\definecolor{listinggray}{gray}{0.9} +\definecolor{lbcolor}{rgb}{0.9,0.9,0.9} +\lstset{ +  backgroundcolor=\color{lbcolor}, +  tabsize=4, +  rulecolor=, +  language=, +  basicstyle={\ttfamily\scriptsize}, +  upquote=true, +  columns=fixed, +  showstringspaces=false, +  extendedchars=true, +  breaklines=true, +  prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}}, +  frame=single, +  showtabs=false, +  showspaces=false, +  showstringspaces=false, +  identifierstyle=\ttfamily, +  keywordstyle=\color[rgb]{0,0,1}, +  commentstyle=\color[rgb]{0.133,0.545,0.133}, +  stringstyle=\color[rgb]{0.627,0.126,0.941}, +} +\DeclareTOCStyleEntry[numwidth+=8pt]{part}{part} +\DeclareTOCStyleEntry[numwidth+=4pt]{section}{section} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{paragraph} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subparagraph} +\DeclareTOCStyleEntry[numwidth+=3pt]{section}{subsection} +\DeclareTOCStyleEntries[indent+=4pt]{section}{section,subsection,subsubsection} +\DeclareTOCStyleEntries[numwidth+=3pt]{section}{paragraph,subparagraph} +\newenvironment{ParagraphIndent}[1]{%% +  \begin{list}{}{%% +    \setlength\topsep{0pt}%% +    \addtolength{\leftmargin}{#1} +    \setlength\parsep{0pt plus 1pt}%% +  } +  \item[] +} {\end{list}} +\newenvironment{ParagraphHang}[2]{%% +  \begin{list}{}{%% +    \setlength\topsep{0pt}%% +    \addtolength{\leftmargin}{#1} +    \itemindent=#2 +    \setlength\parsep{0pt plus 1pt}%% +  } +  \item[] +} {\end{list}} +\newenvironment{Bullet}[1]{%% +  \begin{list}{}{%% +    \setlength\topsep{0pt}%% +    \addtolength{\leftmargin}{#1} +    \itemindent=-1em +    \setlength\parsep{0pt plus 1pt}%% +  } +  \item[] +  $\txtbullet$\hspace{\enspace} +} {\end{list}} +\newcommand{\monosp}[1]{\normaltext\ttfamily\texbackslash#1} +\newcommand{\br}{\hfill\break} +\newcommand{\brl}[1]{%% +  \ifx&%% +    \hfill\break +  \else +    \vspace{#1ex} +  \fi +} +\newcommand{\brln}{\hspace*{\fill}\linebreak} +\newcommand{\objBlockOpen}{%% +  \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}\raggedright +  \begin{footnotesize} +} +\newcommand{\objBlockClose}{%% +  \end{footnotesize} +  \setlength{\parskip}{1ex plus0.5ex minus0.2ex} +} +\newcommand{\objGroupOpen}{%% +  \setlength{\parskip}{0.5ex plus0.2ex minus0.1ex} +  \begin{footnotesize} +} +\newcommand{\objGroupClose}{%% +  \end{footnotesize} +} +\newcommand{\objPoemVerseOpen}{%% +  \setlength{\parskip}{0.1ex plus0.1ex minus0.1ex} +  \begin{footnotesize} + +} +\newcommand{\objPoemVerseClose}{%% + +  \end{footnotesize} +  \setlength{\parskip}{1ex plus0.5ex minus0.2ex} +  \linebreak +} +\newcommand{\parasep}{%% +  \smallskip \begin{center}*\hspace{2em}*\hspace{2em}*\end{center} \br +} +\newcommand{\spaces}[1]{{\hspace*{#1ex}}} +\newcommand{\s}{\hspace*{1ex}} +\newcommand{\hardspace}{\hspace*{1ex}} +\newcommand{\-}{\hspace*{1ex}} +\newcommand{\caret}{{\^{~}}} +\newcommand{\pipe}{{\textbar}} +\newcommand{\curlyOpen}{{} +\newcommand{\curlyClose}{}} +\newcommand{\lt}{{UseTextSymbol{OML}{<}}} +\newcommand{\gt}{{UseTextSymbol{OML}{>}}} +\newcommand{\slash}{{/}} +\newcommand{\underscore}{\_} +\newcommand{\exclaim}{\Verbatim{!}} +\newcommand{\linktext}[2]{%% +  {\href{#1} +  {\;\ulcorner\,\textup{{#2}}\,\lrcorner}} +} +\newcommand{\linkurl}[2]{%% +  \;{\href{#1} +  {\;\scriptsize\ttfamily\ulcorner\,\textup{{#2}}\,\lrcorner}} +} +\newcommand{\link}[2]{%% +  {\begin{scriptsize}\color{black}\urlstyle{tt}\href{#1} +  {\;\ulcorner\,{#2}\,\lrcorner}\end{scriptsize}} +} +\newcommand{\objCodeBlock}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} +\newcommand{\objCodeOpen}{%% +  \normaltext\raggedright\small\ttfamily\texbackslash +  \begin{lstlisting} +} +\newcommand{\objCodeClose}{%% +  \end{lstlisting} +} +\newcommand{\ocn}[1]{%% +  \setlength{\parindent}{0em} +  \ifx&%% #1 is empty +    \hspace{-0.5ex}{\marginpar{\begin{tiny}\end{tiny}}} +  \else%% #1 is nonempty +    \hspace{-0.5ex}{\marginpar{\begin{tiny}\hspace{0em}\hypertarget{#1}{#1}\end{tiny}}} +  \fi +} +\newcommand{\ocnhold}[1]{%% +  \begin{tiny}\hspace{0mm}\end{tiny}{\marginpar{\begin{tiny}\hspace{0mm}\hypertarget{#1}{#1}\end{tiny}}} +} +\newcommand{\objCodeBlockHold}[1]{\normaltext\raggedright\small\ttfamily\texbackslash#1} +\newcommand{\objTableOpen}[1]{%% +  \setlength{\LTleft}{0pt} +  \setlength{\LTright}{\fill} +  \begin{tiny} +  \begin{longtable}{#1} +} +\newcommand{\objTableClose}{%% +  \end{longtable} +  \end{tiny} +} +%% \tolerance=300 +%% \clubpenalty=300 +%% \widowpenalty=300 +%% \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) +┃"); +    return latex_sty; +  } +} +template outputLaTeXstyPaperSizeAndOrientation() { +  import +    std.format, +    std.conv : to; +  auto outputLaTeXstyPaperSizeAndOrientation(P)(P doc_sty_info) { +    string latex_sty = format(q"┃%% - called by .tex document to set paper dimensions (size and orientation) +%% - calls spineShared.sty used/shared by all spine documents +\ProvidesPackage{./sty/%s} +\usepackage{geometry} +\geometry{ +  %s, +  %s, +  left=%s, +  right=%s, +  top=%s, +  bottom=%s, +} +\usepackage{./sty/spineShared}┃", +  doc_sty_info.stylesheet, +  doc_sty_info.papersize, +  doc_sty_info.orient, +  doc_sty_info.margin_left, +  doc_sty_info.margin_right, +  doc_sty_info.margin_top, +  doc_sty_info.margin_bottom, +); +    return latex_sty; +  } +} diff --git a/src/doc_reform/io_out/paths_output.d b/src/doc_reform/io_out/paths_output.d index 9398240..a6a1a9b 100644 --- a/src/doc_reform/io_out/paths_output.d +++ b/src/doc_reform/io_out/paths_output.d @@ -550,10 +550,14 @@ template spinePathsLaTeX() {        string base_filename(string fn_src) {          return fn_src.baseName.stripExtension;        } +      auto out_pth() { +        return spineOutPaths!()(doc_matters.output_path, doc_matters.src.language); +      }        string base() { -        auto out_pth = spineOutPaths!()(doc_matters.output_path, doc_matters.src.language); -        string base_dir = "latex"; -        return (((out_pth.output_root).chainPath(base_dir)).asNormalizedPath).array; +        return (((out_pth.output_root).chainPath("latex")).asNormalizedPath).array; +      } +      string base_sty() { +        return (((out_pth.output_root).chainPath("latex").chainPath("sty")).asNormalizedPath).array;        }        string latex_path_stuff() {          return ((base.chainPath(base_filename(doc_matters.src.filename))).asNormalizedPath).array; @@ -565,6 +569,15 @@ template spinePathsLaTeX() {               ~ ".tex")            ).asNormalizedPath).array;        } +      string latex_sty_with_path(string paper_size_orientation) { // spineA4portrait.sty +        return ((base_sty.chainPath("spine" +             ~ paper_size_orientation +             ~ ".sty") +          ).asNormalizedPath).array; +      } +      string latex_sty_with_path_static() { // spineShared.sty +        return ((base_sty.chainPath("spineShared.sty")).asNormalizedPath).array; +      }        string images() {          string image_dir = "image";          return (((base).chainPath(image_dir)).asNormalizedPath).array; @@ -573,6 +586,31 @@ template spinePathsLaTeX() {      return _PathsStruct();    }  } +template spinePathsLaTeXsty() { +  auto spinePathsLaTeXsty(string output_dir) { +    struct _PathsStruct { +      auto out_pth() { +        return spineOutPaths!()(output_dir); +      } +      string base_sty() { +        return (((out_pth.output_root).chainPath("latex").chainPath("sty")).asNormalizedPath).array; +      } +      string latex_sty_with_path(string paper_size_orientation) { // spineA4portrait.sty +        return ((base_sty.chainPath("spine" +             ~ paper_size_orientation +             ~ ".sty") +          ).asNormalizedPath).array; +      } +      string latex_sty_with_path_static() { // spineShared.sty +        return ((base_sty.chainPath("spineShared.sty")).asNormalizedPath).array; +      } +      string latex_document_header_sty(string filename) { // spineShared.sty +        return ((base_sty.chainPath(filename)).asNormalizedPath).array; +      } +    } +    return _PathsStruct(); +  } +}  template spinePathsSQLiteDiscrete() {    mixin spineRgxIn;    static auto rgx = RgxI(); diff --git a/src/doc_reform/spine.d b/src/doc_reform/spine.d index de069c9..563de48 100755 --- a/src/doc_reform/spine.d +++ b/src/doc_reform/spine.d @@ -141,6 +141,8 @@ string program_name = "spine";      "html-scroll"                 : false,      "latex"                       : false,      "latex-color-links"           : false, +    "latex-init"                  : false, +    "latex-header-sty"            : false,      "light"                       : false,      "manifest"                    : false,      "hide-ocn"                    : false, @@ -151,6 +153,7 @@ string program_name = "spine";      "parallel-subprocesses"       : false,      "pdf"                         : false,      "pdf-color-links"             : false, +    "pdf-init"                    : false,      "pod"                         : false,      "serial"                      : false,      "show-config"                 : false, @@ -240,6 +243,8 @@ string program_name = "spine";      "lang",                       "=[lang code e.g. =en or =en,es]",                                &settings["lang"],      "latex",                      "latex output (for pdfs)",                                        &opts["latex"],      "latex-color-links",          "mono or color links for pdfs",                                   &opts["latex-color-links"], +    "latex-init",                 "initialise latex shared files (see latex-header-sty)",           &opts["latex-init"], +    "latex-header-sty",           "latex document header sty files",                                &opts["latex-header-sty"],      "light",                      "default light theme",                                            &opts["light"],      "manifest",                   "process manifest output",                                        &opts["manifest"],      "ocn-off",                    "object cite numbers",                                            &opts["ocn-off"], @@ -250,6 +255,7 @@ string program_name = "spine";      "parallel-subprocesses",      "nested parallelisation",                                         &opts["parallel-subprocesses"],      "pdf",                        "latex output for pdfs",                                          &opts["pdf"],      "pdf-color-links",            "mono or color links for pdfs",                                   &opts["pdf-color-links"], +    "pdf-init",                   "initialise latex shared files (see latex-header-sty)",           &opts["pdf-init"],      "pod",                        "spine (doc reform) pod source content bundled",                  &opts["pod"],      "quiet|q",                    "output to terminal",                                             &opts["vox_is0"],      "section-backmatter",         "document backmatter (default)" ,                                 &opts["backmatter"], @@ -432,6 +438,9 @@ string program_name = "spine";      @trusted bool latex_color_links() {        return (opts["latex-color-links"] || opts["pdf-color-links"]) ? true : false;      } +    @trusted bool latex_document_header_sty() { +      return (opts["latex-init"] || opts["latex-header-sty"] || opts["pdf-init"]) ? true : false; +    }      @trusted bool odt() {        return (opts["odf"] || opts["odt"]) ? true : false;      } @@ -967,6 +976,10 @@ string program_name = "spine";    }    if (_manifests.length > 1                            // _manifests[0] initialized dummy element    && _opt_action.abstraction) { +    /+ ↓ output hub +/ +    if (!(_opt_action.skip_output)) { +      outputHubInitialize!()(_opt_action); +    }      if (_opt_action.parallelise) {                     // see else        import std.parallelism;        foreach(manifest; parallel(_manifests[1..$])) { | 
