Skip to content

Commit

Permalink
Merge pull request #1121 from kmuto/erbnames
Browse files Browse the repository at this point in the history
TeXにerb経由で渡すconfig.ymlパラメータ追加
  • Loading branch information
kmuto authored Oct 6, 2018
2 parents 634bb31 + e711b0c commit 09d03e8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
34 changes: 23 additions & 11 deletions templates/latex/config.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
\makeatletter
\def\review@texcompiler{<%= @texcompiler %>}
\def\review@documentclass{<%= @documentclass %>}
\def\review@booktitlename{<%= escape_latex(@config.name_of('booktitle')) %>}
<%- if @config['subtitle'] -%>
\def\review@subtitlename{<%= escape_latex(@config.name_of('subtitle')) %>}

<%- %w(booktitle subtitle).each do |item| -%>
<%- if @config[item] -%>\def\review@<%= item %>name{<%= escape_latex(@config.name_of(item)) %>}
<%- end -%>
<%- end -%>

<%- %w(aut adp ann arr art asn aqt aft aui ant bkp clb cmm csl dsr edt ill lyr mdc mus nrt oth pht pbl prt red rev spn ths trc trl).each do |item| %><%- if @config[item] -%>\def\review@<%= item %>names{<%= escape_latex(@config.names_of(item).join(I18n.t('names_splitter'))) %>}
<%- end -%>
<%- end -%>
\def\review@autnames{<%= escape_latex(@config.names_of('aut').join(I18n.t('names_splitter'))) %>}

\def\review@titlepageauthors{<%= @authors %>}
\def\review@date{<%= escape_latex(@config['date'].to_s) %>}
<%- if @config['highlight'] && @config['highlight']['latex'] -%>
\def\review@highlightlatex{<%= @config['highlight']['latex'] %>}

<%- %w(bookname language urnid isbn).each do |item| -%><%- if @config[item] -%>\def\review@<%= item %>{<%= escape_latex(@config[item]) %>}
<%- end -%>
<%- end -%>
\def\review@language{<%= @config['language'] %>}
<%- %w(rights description subject type format source relation coverage).each do |item| -%>
<%- if @config[item] -%>
<%- a = [@config[item]].flatten -%>\def\review@<%= item %>{<%= a.map{|s| escape_latex(s)}.join('\\' + '\\') %>}
<%- end -%>
<%- end -%>

<%- if @config['highlight'] && @config['highlight']['latex'] -%>\def\review@highlightlatex{<%= @config['highlight']['latex'] %>}
<%- end -%>

\def\review@intn@list{<%= escape_latex(I18n.t('list')) %>}
\def\review@intn@columnhead{<%= escape_latex(I18n.t('column_head')) %>}
\def\review@intn@image{<%= escape_latex(I18n.t('image')) %>}
Expand All @@ -29,6 +43,7 @@
\def\review@figurename{<%= escape_latex(I18n.t('image')) %>}
\def\review@tablename{<%= escape_latex(I18n.t('table')) %>}
\def\review@appendixname{<%= escape_latex(@locale_latex['preappendixname']) %>}

<%- if @config['toc'] -%>
\def\review@toc{true}
\def\review@tocdepth{<%= @config['toclevel'] - 1 %>}
Expand Down Expand Up @@ -64,17 +79,14 @@
\def\reviewbackcovercont{<%= @custom_backcoverpage %>}
<%- end -%>

<%- if @config['colophon'] && @config['colophon'] -%>
<%- if @config['colophon'] -%>
\def\review@colophon{true}
<%- if @custom_colophonpage -%>
\def\review@colophonfile{<%= @custom_colophonpage %>}
<%- end -%>
<%- end -%>
\def\review@pubhistories{<%= @config['pubhistory'].to_s.gsub(/\n/){"\n\n\\noindent\n"} %>}
\def\review@colophonnames{<%= @okuduke %>}
<%- if @config['rights'] -%>
\def\review@rights{<%= @config.names_of('rights').map{|s| escape_latex(s)}.join('\\' + '\\') %>}
<%- end -%>

\def\reviewprefacefiles{<%= @input_files['PREDEF'] %>}
\def\reviewchapterfiles{<%= @input_files['CHAPS'] %>}
Expand Down
10 changes: 9 additions & 1 deletion test/assets/test_template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
\makeatletter
\def\review@texcompiler{uplatex}
\def\review@documentclass{jsbook}

\def\review@booktitlename{Re:VIEW Sample Book}
\def\review@autnames{}


\def\review@titlepageauthors{}
\def\review@date{2011{-}01{-}01}

\def\review@bookname{sample}
\def\review@language{ja}
\def\review@urnid{http://example.jp/}


\def\review@intn@list{リスト}
\def\review@intn@columnhead{■コラム}
\def\review@intn@image{図}
Expand All @@ -24,6 +31,7 @@
\def\review@figurename{図}
\def\review@tablename{表}
\def\review@appendixname{付録}

\def\review@titlepage{true}

\def\review@pubhistories{2011年1月1日 発行}
Expand Down
10 changes: 9 additions & 1 deletion test/assets/test_template_backmatter.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
\makeatletter
\def\review@texcompiler{uplatex}
\def\review@documentclass{jsbook}

\def\review@booktitlename{Re:VIEW Sample Book}
\def\review@autnames{}


\def\review@titlepageauthors{}
\def\review@date{2011{-}01{-}01}

\def\review@bookname{sample}
\def\review@language{ja}
\def\review@urnid{http://example.jp/}


\def\review@intn@list{リスト}
\def\review@intn@columnhead{■コラム}
\def\review@intn@image{図}
Expand All @@ -24,6 +31,7 @@
\def\review@figurename{図}
\def\review@tablename{表}
\def\review@appendixname{付録}

\def\review@titlepage{true}
\def\reviewprofilepagecont{\thispagestyle{empty}\chapter*{Profile}
some profile
Expand Down

0 comments on commit 09d03e8

Please sign in to comment.