diff options
author | Karl Berry <karl@freefriends.org> | 2015-08-03 22:05:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-08-03 22:05:09 +0000 |
commit | 2d5aaeac9797374ab4ba49d579116893e1e949a3 (patch) | |
tree | 8b4ff321ffaebcc8c6d160013ef6e60f41e32af2 /Master/texmf-dist/source/latex/babel | |
parent | b1bd2dbbfd4d6be2af62246fa1889e5470fd45f0 (diff) |
babel (3aug15)
git-svn-id: svn://tug.org/texlive/trunk@38036 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel')
-rw-r--r-- | Master/texmf-dist/source/latex/babel/babel.dtx | 59 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/babel/bbunicode.dtx | 120 |
2 files changed, 151 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index 236d513ef3c..d37a62decf5 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -36,7 +36,7 @@ %\iffalse %% File 'babel.dtx' %\fi -%%\ProvidesFile{babel.dtx}[2014/09/25 v3.9l The Babel package] +%%\ProvidesFile{babel.dtx}[2015/08/03 v3.9m The Babel package] %\iffalse % % Babel DOCUMENT-STYLE option for LaTeX version 2.09 or plain TeX; @@ -196,8 +196,8 @@ \vspace{2cm}\hspace{1.5cm} \begin{minipage}{5cm} \Large -Version 3.9l\newline -2014/09/25 +Version 3.9m\newline +2015/08/03 \vspace{1cm} \textit{Original author}\newline @@ -733,6 +733,8 @@ in \textsf{english} the shorthands defined by \textsf{ngerman} with \begin{verbatim} \addto\extrasenglish{\languageshorthands{ngerman}} \end{verbatim} +(You may also need to activate them with, for example, +|\useshorthands|.) Very often, this is a more convenient way to deactivate shorthands than |\shorthandoff|, as for example if you want to define a macro @@ -839,7 +841,8 @@ option with the value |normal| they are deactivated in math mode a shorthand) are not a source of trouble any more. \Describe{config=}{\meta{file}} Load \meta{file}\texttt{.cfg} instead -of the default config file |bblopts.cfg|. +of the default config file |bblopts.cfg| (the file is loaded even +with |noconfigs|). \Describe{main=}{\meta{language}} Sets the main language, as explained above, ie, this language is always loaded last. If it is not given as @@ -861,7 +864,7 @@ loaded when the format was created: number (remember dialects can share it), name, hyphenation file and exceptions file. \Describe{nocase}{} \New{3.9l} Language settings for uppercase and -lowercase mapping (as set by |\SetCase|) is ignored. Use only if there +lowercase mapping (as set by |\SetCase|) are ignored. Use only if there are incompatibilities with other packages. \Describe{silent}{} \New{3.9l} No warnings and no \textit{infos} are @@ -1111,6 +1114,27 @@ Listed words are saved expanded and therefore it relies on the LICR. Of course, it also works without the LICR if the input and the font encodings are the same, like in Unicode based engines. +\Describe\babelpatterns{\texttt{[}\langlist\texttt{]}%^^A + \marg{patterns}} + +\New{3.9m} \textit{In \textsf{luatex} only},\footnote{With +\textsf{luatex} exceptions and patterns can be modified almost +freely. However, this is very likely a task for a separate package +and \texttt{babel} only provides the most basic tools.} adds or +replaces patterns for the languages given or, without the optional +argument, for \textit{all} languages. If a pattern for a certain +combination already exists, it gets replaced by the new one. + +It can be used only in the preamble, and patterns are added when the +language is first selected, thus taking into account changes of +|\lccodes|'s done in |\extras|\m{lang} as well as the language specific +encoding (not set in the preamble by default). Multiple +|\babelpatterns|'s are allowed. + +Listed patterns are saved expanded and therefore it relies on the +LICR. Of course, it also works without the LICR if the input and the +font encodings are the same, like in Unicode based engines. + \subsection{Language attributes} \DescribeMacro{\languageattribute} @@ -1143,7 +1167,7 @@ current options may be different. \sffamily \item[Afrikaans] afrikaans \item[Bahasa] bahasa, indonesian, indon, bahasai, - bahasam, malay, meyalu + bahasam, malay, melayu \item[Basque] basque \item[Breton] breton \item[Bulgarian] bulgarian @@ -1596,7 +1620,7 @@ explained in in sec. \ref{s:strings} (\babel{} 3.9 and later). \begin{verbatim} \ProvidesLanguage{<language>} - [2014/09/25 v0.0 <Language> support from the babel system] + [2015/08/03 v0.0 <Language> support from the babel system] \LdfInit{<language>}{captions<language>} \ifx\undefined\l@<language> @@ -1712,7 +1736,7 @@ instance, be used in adding instructions to a macro like Be careful when using this macro, because depending on the case the assignment could be either global (usually) or local (sometimes). That -does not seems very consistent, but this behaviour is preserved for +does not seem very consistent, but this behaviour is preserved for backward compatibility. If you are using \pkg{etoolbox}, by Philipp Lehman, consider using the tools provided by this package instead of |\addto|. @@ -2367,7 +2391,7 @@ help from Bernd Raichle, for which I am grateful. % \file{babel.def} and provides a few tools for Plain. % \item[hyphen.cfg] is the file to be used when generating the % formats to load hyphenation patterns. By default it also loads -% \file{suçwitch.def}. +% \file{switch.def}. % \end{description} % % The \babel{} installer extends \textsf{docstrip} with a few @@ -2378,8 +2402,8 @@ help from Bernd Raichle, for which I am grateful. % little bit of literate programming. % % \begin{macrocode} -%<<version=3.9l>> -%<<date=2014/09/25>> +%<<version=3.9m>> +%<<date=2015/08/03>> % \end{macrocode} % % We define some basic macros which just make the code cleaner. @@ -2844,7 +2868,7 @@ help from Bernd Raichle, for which I am grateful. % \changes{babel~3.8h}{2005/11/23}{added synonyms \Lopt{indonesian}, % \Lopt{indon} and \Lopt{bahasai} for the original bahasa % (indonesia) support} -% \changes{babel~3.8h}{2005/11/23}{added \Lopt{malay}, \Lopt{meyaluy} +% \changes{babel~3.8h}{2005/11/23}{added \Lopt{malay}, \Lopt{meyalu} % and \Lopt{bahasam} for the Bahasa Malaysia support} % \changes{babel~3.5b}{1995/05/25}{Added \Lopt{brazilian} as % alternative for \Lopt{brazil}} @@ -2880,6 +2904,8 @@ help from Bernd Raichle, for which I am grateful. % \Lopt{USenglish}} % \changes{babel~3.9i}{2014/03/01}{Removed German options, because % they are now loaded directly} +% \changes{babel~3.9m}{2015/07/28}{Added melayu (meyalu preserved for +% compatibility)} % % Languages are loaded when processing the corresponding option % \textit{except} if a |main| language has been set. In such a @@ -2930,6 +2956,7 @@ help from Bernd Raichle, for which I am grateful. \DeclareOption{lowersorbian}{\bbl@load@language{lsorbian}} \DeclareOption{malay}{\bbl@load@language{bahasam}} \DeclareOption{meyalu}{\bbl@load@language{bahasam}} +\DeclareOption{melayu}{\bbl@load@language{bahasam}} \DeclareOption{newzealand}{\bbl@load@language{english}} \DeclareOption{nynorsk}{\bbl@load@language{norsk}} \DeclareOption{polutonikogreek}{% @@ -4794,7 +4821,7 @@ help from Bernd Raichle, for which I am grateful. \ifx\bbl@hyphlist\@empty\else \bbl@warning{% You must not intermingle \string\selectlanguage\space and\\% - \string\babelhyphenation\space or some exception will not\\% + \string\babelhyphenation\space or some exceptions will not\\% be taken into account. Reported}% \fi \ifx\@empty#1% @@ -6584,7 +6611,7 @@ help from Bernd Raichle, for which I am grateful. % \changes{babel~3.6u}{1999/04/20}{Moved this code to % \file{babel.def}} % \changes{babel~3.9l}{2014/08/02}{fontspec used to set -% \cs{latinencoding} to EUx, but now it doesn't. So,it's done here.} +% \cs{latinencoding} to EUx, but now it doesn't. So, it's done here.} % \begin{macrocode} \AtBeginDocument{% \@ifpackageloaded{fontspec}% @@ -7540,6 +7567,8 @@ help from Bernd Raichle, for which I am grateful. % \changes{babel~3.8l}{2008/07/06}{Macro added} % \changes{babel~3.9a}{2012/08/28}{Extended to set hyphenation % exceptions as defined with \cs{babelhyphenation}} +% \changes{babel~3.9m}{2015/07/25}{Preset \cs{bbl@pttnlist} and +% \cs{bbl@patterns@} to relax, for luatex.} % This macro selects the hyphenation patterns by changing the % \cs{language} register. If special hyphenation patterns % are available specifically for the current font encoding, @@ -7556,6 +7585,8 @@ help from Bernd Raichle, for which I am grateful. % \begin{macrocode} \let\bbl@hyphlist\@empty \let\bbl@hyphenation@\relax +\let\bbl@pttnlist\@empty +\let\bbl@patterns@\relax \let\bbl@hymapsel=\@cclv \def\bbl@patterns#1{% \language=\expandafter\ifx\csname l@#1:\f@encoding\endcsname\relax diff --git a/Master/texmf-dist/source/latex/babel/bbunicode.dtx b/Master/texmf-dist/source/latex/babel/bbunicode.dtx index ce94a0cea59..bcbc4792840 100644 --- a/Master/texmf-dist/source/latex/babel/bbunicode.dtx +++ b/Master/texmf-dist/source/latex/babel/bbunicode.dtx @@ -31,7 +31,7 @@ % \iffalse %<*dtx> \ProvidesFile{bbunicode.dtx} - [2014/03/21 v1.0d Babel hooks for Unicode engines] + [2015/05/10 v1.0e Babel hooks for Unicode engines] %</dtx> % %% File `bbunicode.dtx' @@ -187,10 +187,19 @@ % letter or other} % \changes{bbunicode~1.0d}{2014/03/21}{Removed the `misfeature' for % `initiateactive'} +% \changes{bbunicode~1.0e}{2015/05/10}{Use brackets instead of +% \cs{luaescapestring}} +% \changes{bbunicode~1.0e}{2015/07/26}{Added function addpatterns and +% modified the patterns hook.} % % \begin{macrocode} %<*luatex> -\directlua{% +\begingroup +\catcode`\%=12 +\catcode`\'=12 +\catcode`\"=12 +\catcode`\:=12 +\directlua{ require("luatex-hyphen") Babel = {} function Babel.bytes(line) @@ -199,7 +208,8 @@ end function Babel.begin_process_input() if luatexbase and luatexbase.add_to_callback then - luatexbase.add_to_callback('process_input_buffer',Babel.bytes,'Babel.bytes') + luatexbase.add_to_callback('process_input_buffer', + Babel.bytes,'Babel.bytes') else Babel.callback = callback.find('process_input_buffer') callback.register('process_input_buffer',Babel.bytes) @@ -212,7 +222,33 @@ callback.register('process_input_buffer',Babel.callback) end end + function Babel.addpatterns(pp, lg) + local lg = lang.new(lg) + local pats = lang.patterns(lg) or '' + lang.clear_patterns(lg) + for p in pp:gmatch('[^%s]+') do + ss = '' + for i in string.utfcharacters(p:gsub('%d', '')) do + ss = ss .. '%d?' .. i + end + ss = ss:gsub('^%%d%?%.', '%%.') .. '%d?' + ss = ss:gsub('%.%%d%?$', '%%.') + pats, n = pats:gsub('%s' .. ss .. '%s', ' ' .. p .. ' ') + if n == 0 then + tex.sprint( + [[\string\csname\space bbl@info\endcsname{New pattern: ]] + .. p .. [[}]]) + pats = pats .. ' ' .. p + else + tex.sprint( + [[\string\csname\space bbl@info\endcsname{Renew pattern: ]] + .. p .. [[}]]) + end + end + lang.patterns(lg, pats) + end } +\endgroup \def\BabelStringsDefault{unicode} \let\luabbl@stop\relax \AddBabelHook{luatex}{encodedcommands}{% @@ -226,25 +262,39 @@ \luabbl@stop \let\luabbl@stop\relax} \AddBabelHook{luatex}{patterns}{% - \ifx\directlua\relax\else - \ifcsname lu@texhyphen@loaded@\the\language\endcsname \else - \global\@namedef{lu@texhyphen@loaded@\the\language}{}% - \directlua{ - luatexhyphen.loadlanguage('\luatexluaescapestring{\string#1}', - '\the\language')}% - \fi - \fi} + \ifcsname lu@texhyphen@loaded@\the\language\endcsname \else + \global\@namedef{lu@texhyphen@loaded@\the\language}{}% + \directlua{ + luatexhyphen.loadlanguage([[\string#1]], + '\the\language')}% + \fi + \@ifundefined{bbl@patterns@}{}{% + \begingroup + \@expandtwoargs\in@{,\number\language,}{,\bbl@pttnlist}% + \ifin@\else + \ifx\bbl@patterns@\@empty\else + \directlua{ Babel.addpatterns( + [[\bbl@patterns@]], \number\language) }% + \fi + \@ifundefined{bbl@patterns@#1}% + \@empty + {\directlua{ Babel.addpatterns( + [[\space\csname bbl@patterns@#1\endcsname]], + \number\language) }}% + \xdef\bbl@pttnlist{\bbl@pttnlist\number\language,}% + \fi + \endgroup}} \AddBabelHook{luatex}{adddialect}{% \ifx\directlua\relax\else \directlua{ - luatexhyphen.adddialect('\luatexluaescapestring{\string#1}', - '\luatexluaescapestring{\string#2}') + luatexhyphen.adddialect([[\string#1]], + [[\string#2]]) }% \fi} \AddBabelHook{luatex}{everylanguage}{% \directlua{ processnow = (tex.language == 0) or - (luatexhyphen.lookupname('\luatexluaescapestring{\string#1}') == nil)}% + (luatexhyphen.lookupname([[\string#1]]) == nil)}% \ifnum0=\directlua{tex.sprint(processnow and "0" or "1")}\relax \global\@namedef{lu@texhyphen@loaded@\the\language}{}% \fi} @@ -257,6 +307,48 @@ \input #1\relax \fi \directlua{processnow = nil}} +% \end{macrocode} +% +% \begin{macro}{\babelpatterns} +% +% This macro adds patterns. Two macros are used to store them: +% |\bbl@patterns@| for the global ones and |\bbl@patterns<lang>| +% for language ones. We make sure there is a space between words +% when multiple commands are used. +% \changes{bbunicode~1.0e}{2015/07/26}{Macro \cs{babelpatterns} added} +% +% \begin{macrocode} +\@onlypreamble\babelpatterns +\AtEndOfPackage{% + \newcommand\babelpatterns[2][\@empty]{% + \ifx\bbl@patterns@\relax + \let\bbl@patterns@\@empty + \fi + \ifx\bbl@pttnlist\@empty\else + \bbl@warning{% + You must not intermingle \string\selectlanguage\space and\\% + \string\babelpatterns\space or some patterns will not\\% + be taken into account. Reported}% + \fi + \ifx\@empty#1% + \protected@edef\bbl@patterns@{\bbl@patterns@\space#2}% + \else + \edef\bbl@tempb{\zap@space#1 \@empty}% + \bbl@for\bbl@tempa\bbl@tempb{% + \bbl@fixname\bbl@tempa + \bbl@iflanguage\bbl@tempa{% + \bbl@csarg\protected@edef{patterns@\bbl@tempa}{% + \@ifundefined{bbl@patterns@\bbl@tempa}% + \@empty + {\csname bbl@patterns@\bbl@tempa\endcsname\space}% + #2}}}% + \fi}} +% \end{macrocode} +% \end{macro} +% +% Common stuff. +% +% \begin{macrocode} <@Restore Unicode catcodes before loading patterns@> <@Font selection@> %</luatex> |