From 5ad40746e49a91fec7a9490a2ff485f347fa213f Mon Sep 17 00:00:00 2001 From: tilmann Date: Sun, 6 Dec 2015 14:54:58 +0100 Subject: [PATCH] Better support for Japanese #34 by kshramt --- Makefile | 2 +- latexdiff | 4 +++- testsuite/ja-diff-1.1.0.tex | 30 ++++++++++++++++++++++++++++++ testsuite/ja-new.tex | 7 +++++++ testsuite/ja-old.tex | 7 +++++++ testsuite/verify | 13 ++++++++++--- 6 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 testsuite/ja-diff-1.1.0.tex create mode 100644 testsuite/ja-new.tex create mode 100644 testsuite/ja-old.tex diff --git a/Makefile b/Makefile index 6b4958d..5151559 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ cleanall: clean cleantest \rm -r dist test: - cd testsuite; verify --run + cd testsuite; ./verify --run diff --git a/latexdiff b/latexdiff index 33f2ec9..7d884e0 100755 --- a/latexdiff +++ b/latexdiff @@ -33,6 +33,7 @@ # Version 1.1.1alpha # - patch mhchem: allow ce in equations # - flatten now also expands \input etc. in the preamble (but not \usepackage!) +# - Better support for Japanese ( contributed by github user kshramt ) # # Version 1.1.0 # - treat diacritics (\",\', etc) as safe commands @@ -577,7 +578,8 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); # such that a\_b is interpreted as a{\_}b by latex but a{\_b} by perl my $quotedunderscore='\\\\_'; # word: sequence of letters or accents followed by letter - my $word='(?:[-\w\d*]|\\\\[\"\'\`~^][A-Za-z\*])+'; + my $word_ja='\p{Han}+|\p{InHiragana}+|\p{InKatakana}+'; + my $word='(?:' . $word_ja . '|(?:(?:[-\w\d*]|\\\\[\"\'\`~^][A-Za-z\*])(?!(?:' . $word_ja . ')))+)'; my $cmdleftright='\\\\(?:left|right|[Bb]igg?[lrm]?|middle)\s*(?:[<>()\[\]|]|\\\\(?:[|{}]|\w+))'; ### my $word='(?:[-\p{IsL}*]|\\\\[\"\'\`~^][\p{IsL}A-Za-z\*])+'; ### standard $cmdoptseq without intervening spaces diff --git a/testsuite/ja-diff-1.1.0.tex b/testsuite/ja-diff-1.1.0.tex new file mode 100644 index 0000000..20af26d --- /dev/null +++ b/testsuite/ja-diff-1.1.0.tex @@ -0,0 +1,30 @@ +\documentclass{ltjsarticle} +%DIF LATEXDIFF DIFFERENCE FILE +%DIF DEL ja-old.tex Fri Dec 4 17:00:51 2015 +%DIF ADD ja-new.tex Fri Dec 4 17:00:26 2015 +%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF +%DIF CFONT PREAMBLE %DIF PREAMBLE +\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE +\providecommand{\DIFadd}[1]{{\protect\color{blue} \sf #1}} %DIF PREAMBLE +\providecommand{\DIFdel}[1]{{\protect\color{red} \scriptsize #1}} %DIF PREAMBLE +%DIF SAFE PREAMBLE %DIF PREAMBLE +\providecommand{\DIFaddbegin}{} %DIF PREAMBLE +\providecommand{\DIFaddend}{} %DIF PREAMBLE +\providecommand{\DIFdelbegin}{} %DIF PREAMBLE +\providecommand{\DIFdelend}{} %DIF PREAMBLE +%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE +\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE +\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE +\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE +\providecommand{\DIFaddendFL}{} %DIF PREAMBLE +\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE +\providecommand{\DIFdelendFL}{} %DIF PREAMBLE +%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF + +\begin{document} + +例えば\DIFdelbegin \DIFdel{S}\DIFdelend \DIFaddbegin \DIFadd{P}\DIFaddend 波の到達時刻を知りたい場合,\DIFdelbegin \DIFdel{ジェフェリーズ}\DIFdelend \DIFaddbegin \DIFadd{ジェフリーズ}\DIFaddend とブレンの\DIFdelbegin \DIFdel{掃除表}\DIFdelend \DIFaddbegin \DIFadd{走時表}\DIFaddend が使\DIFdelbegin \DIFdel{えますか? +}\DIFdelend \DIFaddbegin \DIFadd{えます. +}\DIFaddend + +\end{document} diff --git a/testsuite/ja-new.tex b/testsuite/ja-new.tex new file mode 100644 index 0000000..7c6e615 --- /dev/null +++ b/testsuite/ja-new.tex @@ -0,0 +1,7 @@ +\documentclass{ltjsarticle} + +\begin{document} + +例えばP波の到達時刻を知りたい場合,ジェフリーズとブレンの走時表が使えます. + +\end{document} diff --git a/testsuite/ja-old.tex b/testsuite/ja-old.tex new file mode 100644 index 0000000..9ab7bfa --- /dev/null +++ b/testsuite/ja-old.tex @@ -0,0 +1,7 @@ +\documentclass{ltjsarticle} + +\begin{document} + +例えばS波の到達時刻を知りたい場合,ジェフェリーズとブレンの掃除表が使えますか? + +\end{document} diff --git a/testsuite/verify b/testsuite/verify index 08d428e..08b0bad 100755 --- a/testsuite/verify +++ b/testsuite/verify @@ -17,9 +17,16 @@ set testroots=( test rapine_et_al island_obs2004 texdiffsample gershwin12 gershw delequ latin9 pollack move-equation nomarkup subscript doubledollar \ DIFDELCMDBUG eqnarray subscriptm delequ2 schneider gennady umesh underwood endfloat outerrise \ delequ3 delequ4 "simplefrac --allow-spaces" "master --flatten" titlediffTest2 exampleDiff bornd2 \ -"rolla --math-markup=2" mini "complex-maths --math-markup=1" margalit circonflex mwe-comment "apacite-test --flatten" quoteddollarunderscore units ) +"rolla --math-markup=2" mini "complex-maths --math-markup=1" margalit circonflex mwe-comment "apacite-test --flatten" quoteddollarunderscore units \ +) #set testroots= ( test subscript ) +### Note that ja tex needs lualatex +###<<<<<<< HEAD +###======= +###"ja --encoding=utf8 --type=CFONT" \ +###) +###>>>>>>> b81af5579366f393f813580575b2a5e58801a08c # ttest-siunitx ttest-glossaries ttest-chem ttest-cleveref @@ -54,7 +61,7 @@ while ( $#testroots >= 1 ) set sample=( $testroots[1] ) shift testroots if ( $#sample > 1 ) then - set eopt=$sample[2-] + set eopt="$sample[2-]" else set eopt endif @@ -107,7 +114,7 @@ while ( $#testroots >= 1 ) endif run: if ( $run ) then - pdflatex -interaction=batchmode ${sample}-diff.tex + pdflatex -interaction=batchmode ${sample}-diff.tex if ($status || ! -e ${sample}-diff.pdf ) then echo "Compilation of ${sample}-diff.tex did not complete as expected."