summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/xpinyin
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-02-03 23:02:21 +0000
committerKarl Berry <karl@freefriends.org>2016-02-03 23:02:21 +0000
commitf4a543aed2bbfaec5c3f8dbfee5985322cd1b938 (patch)
tree782264b0fd48eaed1f2448fecaed4ecb3697d801 /Master/texmf-dist/source/latex/xpinyin
parent0cac99615b136e1d48a6bf1c06c94de0fc0cc6b9 (diff)
xpinyin (2feb16)
git-svn-id: svn://tug.org/texlive/trunk@39566 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/xpinyin')
-rw-r--r--Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx218
-rw-r--r--Master/texmf-dist/source/latex/xpinyin/xpinyin.ins62
2 files changed, 202 insertions, 78 deletions
diff --git a/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx b/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
index 34757cc9032..4d15e103178 100644
--- a/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
+++ b/Master/texmf-dist/source/latex/xpinyin/xpinyin.dtx
@@ -43,7 +43,7 @@ Email: sobenlee@gmail.com
If you are interested in the process of development you may observe
- http://code.google.com/p/ctex-kit/
+ https://github.com/CTeX-org/ctex-kit
Installation
------------
@@ -51,7 +51,7 @@ The package is supplied in dtx format and as a pre-extracted zip file,
xpinyin.tds.zip. The later is most convenient for most users: simply
unzip this in your local texmf directory and run texhash to update the
database of file locations. If you want to unpack the dtx yourself,
-running "luatex xpinyin.dtx" will extract the package whereas
+running "luatex xpinyin.ins" will extract the package whereas
"xelatex xpinyin.dtx" will typeset the documentation.
The package requires LaTeX3 support as provided in the l3kernel and l3packages
@@ -71,20 +71,59 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%</internal>
%<*install>
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname directlua\endcsname\relax
- \begingroup
- \newlinechar=10 %
- \errmessage{^^J
- ********************************************^^J
- * LuaTeX is required to unpack this package.^^J
- ********************************************^^J
- }
- \endgroup
- \csname @@end\expandafter\endcsname\expandafter\end
+%<install>\begingroup\expandafter\expandafter\expandafter\endgroup
+%<install>\expandafter\ifx\csname directlua\endcsname\relax
+%<install> \begingroup
+%<install> \newlinechar=10 %
+%<install> \errmessage{^^J
+%<install> ********************************************^^J
+%<install> * LuaTeX is required to unpack this package.^^J
+%<install> ********************************************^^J
+%<install> }
+%<install> \endgroup
+%<install> \csname @@end\expandafter\endcsname\expandafter\end
+%<install>\fi
+
+\newread\inputcheck
+\openin\inputcheck=xpinyin.ver
+\ifeof\inputcheck
+ \def\xpinyinPutVersion{\string\GetIdInfo$Id$}
+\else
+ \input xpinyin.ver
\fi
+\closein\inputcheck
\input l3docstrip.tex
+\def\checkOption<#1{%
+ \ifcase
+ \ifx*#10\else \ifx/#11\else
+ \ifx+#12\else \ifx-#13\else
+ \ifx<#14\else \ifx @#15\else
+ \ifx.#16\else
+ 7\fi\fi\fi\fi\fi\fi\fi\relax
+ \expandafter\starOption\or
+ \expandafter\slashOption\or
+ \expandafter\plusOption\or
+ \expandafter\minusOption\or
+ \expandafter\verbOption\or
+ \expandafter\moduleOption\or
+ \expandafter\expOption\or
+ \expandafter\doOption\fi
+ #1%
+}
+\def\expOption .#1>#2\endLine{%
+ \maybeMsg{<.#1 . >}%
+ \Evaluate{#1}%
+ \begingroup
+ \catcode`\\=0 \catcode`\{=1 \catcode`\}=2
+ \xdef\expandedLineStuff{\scantokens{#2\noexpand}}%
+ \endgroup
+ \def\do##1##2##3{%
+ \if1\Expr{##2}\StreamPut##1{\expandedLineStuff}\fi
+ }%
+ \activefiles
+}
+
\keepsilent
\askforoverwritefalse
@@ -92,7 +131,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\preamble
- Copyright (C) 2012-2014 by Qing Lee <sobenlee@gmail.com>
+ Copyright (C) 2012-2016 by Qing Lee <sobenlee@gmail.com>
--------------------------------------------------------------------------
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
@@ -131,22 +170,31 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\file{xpinyin.lua} {\from{\jobname.dtx}{lua}}
}
-\directlua{dofile("xpinyin.lua")}
-
\let\MetaPrefix\DoubleperCent
+%<install>\directlua
+%<install> {
+%<install> if not kpse.find_file("xpinyin.db") then
+%<install> dofile(kpse.find_file("xpinyin.lua"))
+%<install> end
+%<install> }
+%<install>\generate
+%<install> {
+%<install> \usedir{tex/latex/xpinyin}
+%<install> \usepostamble\emptypostamble
+%<install> \file{xpinyin-database.def}
+%<install> {
+%<install> \from{\jobname.dtx} {database}
+%<install> \from{xpinyin.db} {}
+%<install> }
+%<install> }
+
\generate
{
\usedir{source/latex/xpinyin}
\file{xpinyin.ins} {\from{\jobname.dtx}{install}}
\usedir{tex/latex/xpinyin}
\file{xpinyin.sty} {\from{\jobname.dtx}{package}}
- \usepostamble\emptypostamble
- \file{xpinyin-database.def}
- {
- \from{\jobname.dtx} {database}
- \from{xpinyin.db} {}
- }
\nopreamble\nopostamble
\usedir{doc/latex/xpinyin}
\file{README.txt} {\from{\jobname.dtx}{readme}}
@@ -161,22 +209,29 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%<*driver|package>
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\GetIdInfo$Id: xpinyin.dtx 749 2014-12-24 15:05:15Z sobenlee@gmail.com $
+%<.!driver>\xpinyinPutVersion
+%<*driver>
+\InputIfFileExists{xpinyin.ver}{}{
+ \def\xpinyinGetVersionInfo{\GetIdInfo$Id$}}
+\xpinyinGetVersionInfo
+%</driver>
{Automatically add pinyin to Chinese characters}
%<*driver>
\ProvidesExplFile{\ExplFileName.\ExplFileExtension}
%</driver>
%<package>\ProvidesExplPackage{\ExplFileName}
- {\ExplFileDate}{2.1}{\ExplFileDescription}
+ {\ExplFileDate}{2.2}{\ExplFileDescription}
%<*driver>
\ExplSyntaxOff
%</driver>
%</driver|package>
%<database>\ProvidesFile{xpinyin-database.def}%
-%<database> [2014/12/24 v2.1 xpinyin database]
+%<database> [2015/02/02 v2.2 xpinyin database]
%
%<*driver>
-\documentclass[full,a4paper]{l3doc}
+\let\ctexrevnum\ExplFileVersion
+\expandafter\let\csname ver@thumbpdf.sty\endcsname\fmtversion
+\documentclass[numbered,full,a4paper]{l3doc}
\usepackage{xeCJK}
\usepackage{indentfirst}
\usepackage{xpinyin}
@@ -198,15 +253,18 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\newfontfamily\PinYinFont{TeX Gyre Adventor}
\xpinyinsetup{font=\PinYinFont,multiple=\color{red}}
\def\MacroFont{\linespread{1}\small\normalfont\ttfamily}
+\def\ctexkitrev#1{%
+ \href{https://github.com/CTeX-org/ctex-kit/commit/#1}{\texttt{ctex-kit} rev. #1}}
\makeatletter
\ExplSyntaxOn
\DeclareDocumentCommand \package { o m }
{
- \exp_args:Nx \tex_lowercase:D
+ \exp_args:Nx \href
{
- \exp_not:N \href
- { http \token_to_str:N : //www.ctan.org/pkg/ \IfNoValueTF {#1} {#2} {#1} }
- } { \pkg {#2} }
+ http \token_to_str:N : //www.ctan.org/pkg/
+ \IfNoValueTF {#1} { \str_fold_case:n {#2} } {#1}
+ }
+ { \pkg {#2} }
}
\cs_set_protected:Npn \__codedoc_special_index_aux:nnnnn #1#2#3#4#5
{
@@ -254,11 +312,11 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\def\LaTeX{\hologo{LaTeX}}
\def\pdfLaTeX{\hologo{pdfLaTeX}}
\def\XeLaTeX{\hologo{XeLaTeX}}
-\def\TF{true\orval{}false}
-\def\TTF{\defaultval{true}\orval{}false}
-\def\TFF{true\orval\defaultval{false}}
-\def\orval{\textup{\textbar}}
+\def\TF{true\orbar false}
+\def\TTF{\defaultval{true}\orbar false}
+\def\TFF{true\orbar\defaultval{false}}
\def\defaultval#1{\textbf{\textup{#1}}}
+\def\orbar{\textup{\textbar}}
\makeatother
\def\indexname{代码索引}
\IndexPrologue{%
@@ -274,12 +332,12 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%</driver>
% \fi
%
-% \CheckSum{707}
+% \CheckSum{719}
% \GetFileInfo{\jobname.dtx}
%
% \title{\bfseries\pkg{xpinyin} 宏包}
% \author{李清\\ \path{sobenlee@gmail.com}}
-% \date{\filedate\qquad\fileversion}
+% \date{\filedate\qquad\fileversion\thanks{\ctexkitrev{\ctexrevnum}.}}
% \maketitle
%
% \begin{documentation}
@@ -398,7 +456,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%
% \begin{function}{\xpinyinsetup}
% \begin{syntax}
-% \tn{xpinyinsetup} \{ \meta{key_1}=\meta{val_1}, \meta{key_2}=\meta{val_2}, ... \}
+% \tn{xpinyinsetup} \{ <key_1>=<val_1>, <key_2>=<val_2>, ... \}
% \end{syntax}
% 用于在导言区或文档中,设置拼音的格式。目前可以设置的 \meta{key} 如下介绍。
% \end{function}
@@ -463,7 +521,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%
% \begin{function}[added=2014/01/12]{footnote}
% \begin{syntax}
-% footnote = \meta{\TFF}
+% footnote = <\TFF>
% \end{syntax}
% 是否对拼音环境中的脚注(\tn{footnote})汉字加上拼音。缺省值为 \texttt{false}。
% 更一般的情况,请使用 \tn{disablepinyin}。
@@ -488,13 +546,26 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{macrocode}
%
% \begin{macrocode}
-\msg_new:nnn { xpinyin } { no-LuaTeX }
+\msg_new:nnn { xpinyin } { l3-too-old }
+ {
+ Support~package~'expl3'~too~old. \\\\
+ Please~update~an~up~to~date~version~of~the~bundles\\\\
+ 'l3kernel'~and~'l3packages'\\\\
+ using~your~TeX~package~manager~or~from~CTAN.
+ }
+\@ifpackagelater { expl3 } { 2015/09/24 } { }
+ { \msg_error:nn { xpinyin } { l3-too-old } }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\msg_new:nnn { xpinyin } { engine-not-supported }
+ { Engine~`\c_sys_engine_str'~is~not~yet~supported,~xpinyin~will~abort! }
+\bool_if:nF
{
- The~xpinyin~package~is~not~supported~in~LuaTeX.\\\\
- You~must~change~your~typesetting~engine~to\\
- "xelatex"~or~"pdflatex"~or~"latex"~instead~of~"lualatex".
+ \sys_if_engine_xetex_p: ||
+ \sys_if_engine_pdftex_p:
}
-\luatex_if_engine:T { \msg_critical:nn { xpinyin } { no-LuaTeX } }
+ { \msg_critical:nn { xpinyin } { engine-not-supported } }
% \end{macrocode}
%
% \begin{macrocode}
@@ -623,7 +694,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\bool_gset_true:N \g_@@_GBK_bool
}
{
- \xetex_if_engine:TF
+ \sys_if_engine_xetex:TF
{
\RequirePackage { xeCJK }
\AtEndOfPackage { \@@_adjust_xeCJK_hook: }
@@ -657,8 +728,8 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%
% \begin{macro}[internal]{\@@_leave_vmode:}
% \begin{macrocode}
-\cs_if_exist:NTF \quitvmode
- { \cs_new_eq:NN \@@_quit_vmode: \quitvmode }
+\cs_if_exist:NTF \pdftex_quitvmode:D
+ { \cs_new_eq:NN \@@_quit_vmode: \pdftex_quitvmode:D }
{
\cs_new_protected_nopar:Npn \@@_quit_vmode:
{
@@ -706,7 +777,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
}
}
\tl_new:N \l_@@_pinyin_box_hook_tl
-\pdftex_if_engine:T
+\sys_if_engine_pdftex:T
{
\tl_put_right:Nn \l_@@_pinyin_box_hook_tl
{ \cs_set_eq:NN \CJK@plane \tex_undefined:D }
@@ -886,7 +957,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{
\tl_set:Nx \l_@@_current_coor_tl { \l_@@_coor_tl }
\@@_select_font_aux:
- \int_compare:nNnF { \XeTeXfonttype \tex_font:D } = \c_zero
+ \int_compare:nNnF { \xetex_fonttype:D \tex_font:D } = \c_zero
{
\exp_last_unbraced:NNV
\cs_gset_eq:cN \l_@@_current_coor_tl \tex_font:D
@@ -1295,7 +1366,6 @@ end
%
% \begin{macrocode}
xpinyin = {
- svnid = "$Id: xpinyin.dtx 749 2014-12-24 15:05:15Z sobenlee@gmail.com $",
uchar = unicode.utf8.char,
readings = { },
fixreadings = {
@@ -1314,25 +1384,29 @@ xpinyin = {
version = "Unicode version: 7.0.0",
dbfile = "xpinyin.db"
},
-% \end{macrocode}
-% \pkg{DocStrip} 会将一行开头的 |%%| 替换成 \tn{MetaPrefix},因此我们在行首加了
-% 空格,需要把它去掉。
-% \begin{macrocode}
- preamble = string.gsub([[
- %%
- %% Do not edit this file!
- %% Created from Unihan database:
- %%
- %% $file
- %% $date
- %% $version
- %%
- %% by "texlua xpinyin.lua" on ]]
- .. os.date("%Y-%m-%d %X ") .. xpinyin.tzoffset
- .. "\n%%", "[ ]+(%%%%)", "%1")
+ preamble = [[
+%<<COMMENT
+%%
+%% Do not edit this file!
+%% Created from Unihan database:
+%%
+%% $file
+%% $date
+%% $version
+%%
+%% by "texlua xpinyin.lua" on ]]
+ .. os.date("%Y-%m-%d %X ") .. xpinyin.tzoffset
+ .. "\n%%"
+%COMMENT
}
% \end{macrocode}
%
+% \begin{macrocode}
+local http_request = require("socket.http").request
+local ltn12_sink_file = require("ltn12").sink.file
+local zip_open = require("zip").open
+% \end{macrocode}
+%
% 将 \file{Unihan_Readings.txt}^^A
% \footnote{\url{http://http://www.unicode.org/reports/tr38/}。} 保存到一张表里面。
% \begin{macrocode}
@@ -1341,10 +1415,10 @@ function xpinyin.maketable (txt)
if not f then
local source = xpinyin.database.source
local zfilename = source:match("[^/]+$")
- local zfile = zip.open(zfilename)
+ local zfile = zip_open(zfilename)
if not zfile then
xpinyin.download(source, zfilename)
- zfile = assert(zip.open(zfilename))
+ zfile = assert(zip_open(zfilename))
end
f = assert(zfile:open(xpinyin.database.file))
zfile:close()
@@ -1379,10 +1453,12 @@ end
% \begin{macrocode}
function xpinyin.download (source, zip)
print("\nRetrieving Unihan Database from\n", source)
- local unihan_data = assert(socket.http.request(source), "download failed")
- local f = assert(io.open(zip, "wb"), "Unihan file (" .. zip .. ") not writable")
- f:write(unihan_data)
- f:close()
+ local status, err = http_request{
+ url = source,
+ sink = ltn12_sink_file(io.open(zip, "wb")) }
+ if not status then
+ error([[Download ']] .. zip .. [[' failed because of ]] .. err .. ".")
+ end
end
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/xpinyin/xpinyin.ins b/Master/texmf-dist/source/latex/xpinyin/xpinyin.ins
index 9060d87460d..890cad23f79 100644
--- a/Master/texmf-dist/source/latex/xpinyin/xpinyin.ins
+++ b/Master/texmf-dist/source/latex/xpinyin/xpinyin.ins
@@ -6,7 +6,7 @@
%%
%% xpinyin.dtx (with options: `install')
%%
-%% Copyright (C) 2012-2014 by Qing Lee <sobenlee@gmail.com>
+%% Copyright (C) 2012-2016 by Qing Lee <sobenlee@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -33,7 +33,46 @@
\csname @@end\expandafter\endcsname\expandafter\end
\fi
+\newread\inputcheck
+\openin\inputcheck=xpinyin.ver
+\ifeof\inputcheck
+ \def\xpinyinPutVersion{\string\GetIdInfo$Id$}
+\else
+ \input xpinyin.ver
+\fi
+\closein\inputcheck
+
\input l3docstrip.tex
+\def\checkOption<#1{%
+ \ifcase
+ \ifx*#10\else \ifx/#11\else
+ \ifx+#12\else \ifx-#13\else
+ \ifx<#14\else \ifx @#15\else
+ \ifx.#16\else
+ 7\fi\fi\fi\fi\fi\fi\fi\relax
+ \expandafter\starOption\or
+ \expandafter\slashOption\or
+ \expandafter\plusOption\or
+ \expandafter\minusOption\or
+ \expandafter\verbOption\or
+ \expandafter\moduleOption\or
+ \expandafter\expOption\or
+ \expandafter\doOption\fi
+ #1%
+}
+\def\expOption .#1>#2\endLine{%
+ \maybeMsg{<.#1 . >}%
+ \Evaluate{#1}%
+ \begingroup
+ \catcode`\\=0 \catcode`\{=1 \catcode`\}=2
+ \xdef\expandedLineStuff{\scantokens{#2\noexpand}}%
+ \endgroup
+ \def\do##1##2##3{%
+ \if1\Expr{##2}\StreamPut##1{\expandedLineStuff}\fi
+ }%
+ \activefiles
+}
+
\keepsilent
\askforoverwritefalse
@@ -41,7 +80,7 @@
\preamble
- Copyright (C) 2012-2014 by Qing Lee <sobenlee@gmail.com>
+ Copyright (C) 2012-2016 by Qing Lee <sobenlee@gmail.com>
--------------------------------------------------------------------------
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
@@ -80,22 +119,31 @@
\file{xpinyin.lua} {\from{\jobname.dtx}{lua}}
}
-\directlua{dofile("xpinyin.lua")}
-
\let\MetaPrefix\DoubleperCent
+\directlua
+ {
+ if not kpse.find_file("xpinyin.db") then
+ dofile(kpse.find_file("xpinyin.lua"))
+ end
+ }
\generate
{
- \usedir{source/latex/xpinyin}
- \file{xpinyin.ins} {\from{\jobname.dtx}{install}}
\usedir{tex/latex/xpinyin}
- \file{xpinyin.sty} {\from{\jobname.dtx}{package}}
\usepostamble\emptypostamble
\file{xpinyin-database.def}
{
\from{\jobname.dtx} {database}
\from{xpinyin.db} {}
}
+ }
+
+\generate
+ {
+ \usedir{source/latex/xpinyin}
+ \file{xpinyin.ins} {\from{\jobname.dtx}{install}}
+ \usedir{tex/latex/xpinyin}
+ \file{xpinyin.sty} {\from{\jobname.dtx}{package}}
\nopreamble\nopostamble
\usedir{doc/latex/xpinyin}
\file{README.txt} {\from{\jobname.dtx}{readme}}