Permalink
Browse files

add iffieldisCJK.

  • Loading branch information...
kmaed committed Feb 19, 2018
1 parent 3ea537d commit b11564f803a607270fc05ad5d58e94e9f5bd1bb3
Showing with 39 additions and 22 deletions.
  1. BIN doc/biblatex-japanese.pdf
  2. +11 −5 doc/biblatex-japanese.tex
  3. +19 −8 latex/biblatex-japanese.def
  4. +9 −9 latex/lbx/japanese.lbx
BIN +920 Bytes (100%) doc/biblatex-japanese.pdf
Binary file not shown.
@@ -161,6 +161,9 @@ \subsection{和文文字判定}
フィールド毎に和文文字を含むかどうかで動作を変更できると便利である.
このためのテストコマンドを準備しておく.
なお,Unicodeであることを前提にしているので,p\TeX の場合は
怪しい動作になる.どうなるのかをちゃんと理解したら対策するかもしれない.
\begin{ltxsyntax}
\cmditem{ifCJKstr}{tokens}{true code}{false code}
@@ -169,9 +172,6 @@ \subsection{和文文字判定}
そうでなければ\prm{false code}を実行する.
テストは一度\prm{tokens}を完全展開してから行われる.
なお,Unicodeであることを前提にしているので,p\TeX の場合は
怪しい動作になる.どうなるのかをちゃんと理解したら対策するかもしれない.
\cmditem{ifbeginwithCJKchar}{tokens}{true code}{false code}
\prm{tokens}の先頭にU+2E80以上のコードポイントの文字があれば
@@ -205,13 +205,19 @@ \subsection{置換コマンド}
\cmditem{replacenameformat}[entrytype, \dots]{format}{replace rule name}{code}
それぞれ\cmd{replacecommand}のbibmacro, field format, name list formatに対応するもの.
\cmd{replacefieldformat}, \cmd{replacenameformat}では,replace ruleの定義中にある
\cmd{blxja@format}が冒頭で\prm{format}と定義される.
このことを利用すると,\prm{format}毎にreplace ruleを用意する手間を省ける.
\end{ltxsyntax}
\prm{replace rule name}には以下のいずれかを指定する(現状では1つしかないが,
今後増やす予定).
\prm{replace rule name}には以下のいずれかを指定する.
\begin{typelist}
\typeitem{iflangidisjapanese}
文献出力処理中に,もしその文献の\bibfield{langid}が\texttt{japanese}ならば真になる.
\typeitem{iffieldisCJK}
\cmd{replacefieldformat}で用いると,対象のfieldが和文文字を含む時に真になる.
\end{typelist}
\begin{ltxsyntax}
@@ -86,12 +86,14 @@
\begingroup
\@makeother\#%
\blxja@replace@command@rc@args}
% {<command>}{<rule name>}{<code>}
\long\def\blxja@replace@command@rn@args#1#2#3{%
\ifcsundef{blxja@replacerule@\detokenize{#2}}{%
\blxja@error{Replace rule '\detokenize{#2}' undefined}{}}{%
\expandafter\etb@hooktocmd\csname blxja@replacerule@\detokenize{#2}\endcsname#1{#3}{}{%
\blxja@error{\replacecommand for the command \string#1 failed}
{Try \detokenize{\tracingpatches} to investigate the cause of the problem.\MessageBreak}}}}
% {<command>}{<rule code>}{<code>}
\long\def\blxja@replace@command@rc@args#1#2#3{%
\endgroup
\edef\blxja@reserveda{%
@@ -115,6 +117,7 @@
\begingroup
\@makeother\#%
\blxja@replace@abx@macro@rc@args}
% {<bibmacro>}{<rule name>}{<code>}
\long\def\blxja@replace@abx@macro@rn@args#1#2#3{%
\endgroup
\ifcsundef{blxja@replacerule@\detokenize{#2}}{%
@@ -125,6 +128,7 @@
\expandafter\expandafter\expandafter\etb@hooktocmd\expandafter\blxja@tempa\blxja@tempb{#3}{}{%
\blxja@error{\replacebibmacro for the bibliography macro '\detokenize{#1}' failed}
{Try \detokenize{\tracingpatches} to investigate the cause of the problem.\MessageBreak}}}}
% {<bibmacro>}{<rule code>}{<code>}
\long\def\blxja@replace@abx@macro@rc@args#1#2#3{%
\endgroup
\edef\blxja@reserveda{%
@@ -134,8 +138,8 @@
\begingroup % dummy for \endgroup in \etb@hooktocmd
\blxja@replace@abx@macro@rn@args{#1}{@temprule@}{#3}}
% {<id>}{<type>}{<macro>}
\def\blxja@def@replacemacro#1#2#3{%
% {<id>}{<type>}{<command>}
\def\blxja@def@replacecommand#1#2#3{%
\DeclareDocumentCommand{#3}{ s }{%
\IfBooleanTF{##1}
{\csuse{blxja@replace@abx@\detokenize{#1}@rulecode}}
@@ -145,14 +149,15 @@
\begingroup
\@makeother\#%
\csuse{blxja@replace@abx@\detokenize{#1}@args@}
{\csuse{blxja@replace@abx@\detokenize{#1}@rn@args}}}
{\csuse{blxja@replace@abx@\detokenize{#1}@rn@args}}}
\csdef{blxja@replace@abx@\detokenize{#1}@rulecode}{%
\etb@dbg@trce{#3*}%
\begingroup
\@makeother\#%
\csuse{blxja@replace@abx@\detokenize{#1}@args@}
{\csuse{blxja@replace@abx@\detokenize{#1}@rc@args}}}
% execute <cs> for all <entry type, ...>
% {<cs>}[<entry type, ...>]{<format>}{<replace rule name/code>}{<code>}
\expandafter\DeclareDocumentCommand\expandafter
{\csname blxja@replace@abx@\detokenize{#1}@args@\endcsname}
{ m O{*} m m +m }{%
@@ -161,7 +166,7 @@
\def\@tempc{##1}%
\@for\@tempb:=\@tempa\do{%
\expandafter\@tempc\expandafter{\@tempb}{##3}{##4}{##5}}}
% [<entry type, ...>]{<format>}{<replace rule name>}{<code>}
\expandafter\DeclareDocumentCommand\expandafter
{\csname blxja@replace@abx@\detokenize{#1}@rn@args\endcsname}
{ m m m +m }{%
@@ -170,9 +175,12 @@
\edef\blxja@tempa{\expandonce{\csname blxja@replacerule@\detokenize{##3}\endcsname}}%
\edef\blxja@tempb{\expandonce{\csname abx@#1@\detokenize{##1}@\detokenize{##2}\endcsname}}%
\begingroup % dummy for \endgroup in \etb@hooktocmd
\expandafter\expandafter\expandafter\etb@hooktocmd\expandafter\blxja@tempa\blxja@tempb{##4}{}{%
\expandafter\expandafter\expandafter\etb@hooktocmd\expandafter\blxja@tempa\blxja@tempb{##4}{%
\expandafter\pretocmd\expandafter{\blxja@tempb}{\def\blxja@format{##2}}{}{}%
}{%
\blxja@error{#3 for the #2 '\detokenize{##2}' failed}
{Try \detokenize{\tracingpatches} to investigate the cause of the problem.\MessageBreak}}}}
% [<entry type, ...>]{<format>}{<replace rule code>}{<code>}
\expandafter\DeclareDocumentCommand\expandafter
{\csname blxja@replace@abx@\detokenize{#1}@rc@args\endcsname}
{ m m m +m }{%
@@ -183,8 +191,8 @@
\begingroup % dummy for \endgroup in \etb@hooktocmd
\csuse{blxja@replace@abx@\detokenize{#1}@rn@args}[##1]{##2}{@temprule@}{##4}}}
\blxja@def@replacemacro{ffd}{field format}{\replacefieldformat}
\blxja@def@replacemacro{nfd}{name list format}{\replacenameformat}
\blxja@def@replacecommand{ffd}{field format}{\replacefieldformat}
\blxja@def@replacecommand{nfd}{name list format}{\replacenameformat}
\DeclareDocumentCommand{\newreplacerule}{ m }{%
\ifcsdef{blxja@replacerule@\detokenize{#1}}{%
@@ -208,6 +216,9 @@
{#2}
{#1}}
\newreplacerule{iffieldisCJK}{%
\ifCJKstr{\thefield{\blxja@format}}{#2}{#1}}
\def\blxja@hook@print@getname#1#2#3#4{%
\ifcsundef{blxja@hook@print@#2@\blx@imc@thefield{entrytype}@#3}
{\ifcsundef{blxja@hook@print@#2@*@#3}
@@ -96,34 +96,34 @@
{\global\togglefalse{blx@insert}}
{}}
\savefieldformat{booktitle}%
\replacefieldformat{booktitle}{iflangidisjapanese}{\mkbibwcbrackets{#1}}%
\replacefieldformat{booktitle}{iffieldisCJK}{\mkbibwcbrackets{#1}}%
\printfieldhook{booktitle}{\blxja@removeunitpunct}
\savefieldformat{citetitle}%
\replacefieldformat{citetitle}{iflangidisjapanese}{\mkbibwcbrackets{#1}}%
\replacefieldformat{citetitle}{iffieldisCJK}{\mkbibwcbrackets{#1}}%
\savefieldformats
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{citetitle}%
\replacefieldformat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{citetitle}{iflangidisjapanese}{\mkbibcbrackets{#1}}%
{citetitle}{iffieldisCJK}{\mkbibcbrackets{#1}}%
\printfieldhook{citetitle}{\blxja@removeunitpunct}%
\savefieldformat{issuetitle}%
\replacefieldformat{issuetitle}{iflangidisjapanese}{\mkbibwcbrackets{#1}}%
\replacefieldformat{issuetitle}{iffieldisCJK}{\mkbibwcbrackets{#1}}%
\savefieldformat{journaltitle}%
\replacefieldformat{journaltitle}{iflangidisjapanese}{\mkbibwcbrackets{#1}}%
\replacefieldformat{journaltitle}{iffieldisCJK}{\mkbibwcbrackets{#1}}%
\printfieldhook{journaltitle}{\blxja@removeunitpunct}%
\savefieldformat{maintitle}%
\replacefieldformat{maintitle}{iflangidisjapanese}{\mkbibwcbrackets{#1}}%
\replacefieldformat{maintitle}{iffieldisCJK}{\mkbibwcbrackets{#1}}%
\savefieldformat{pages}%
\replacefieldformat{pages}{iflangidisjapanese}{#1\bibstring{japanese-pages}}%
\replacefieldformat{pages}{iffieldisCJK}{#1\bibstring{japanese-pages}}%
\savefieldformat{title}%
\replacefieldformat{title}{iflangidisjapanese}{\mkbibwcbrackets{#1}}%
\replacefieldformat{title}{iffieldisCJK}{\mkbibwcbrackets{#1}}%
\savefieldformats
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}%
\replacefieldformat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{iflangidisjapanese}{\mkbibcbrackets{#1}}%
{title}{iffieldisCJK}{\mkbibcbrackets{#1}}%
\printfieldhook{title}{\blxja@removeunitpunct}%
\printfieldhook{volume}{\blxja@removeunitpunct}%

0 comments on commit b11564f

Please sign in to comment.