From ee0e10b17847045b623b0fd69d41a7a948616e71 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Mar 2010 20:04:31 +0100 Subject: Help from the ConTeXt Code Review Squad (Taco & Wolfgang) --- tex/context/interface/third/t-transliterator.xml | 6 +- .../third/transliterator/t-transliterator.mkii | 3 + .../third/transliterator/t-transliterator.mkiv | 84 ++++++++++++++-------- .../third/transliterator/t-transliterator.tex | 2 +- 4 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 tex/context/third/transliterator/t-transliterator.mkii (limited to 'tex') diff --git a/tex/context/interface/third/t-transliterator.xml b/tex/context/interface/third/t-transliterator.xml index 3320d7b..2217e12 100644 --- a/tex/context/interface/third/t-transliterator.xml +++ b/tex/context/interface/third/t-transliterator.xml @@ -4,9 +4,9 @@ name="context" language="en" version="2010.02.27"> - + - + @@ -38,7 +38,7 @@ - + diff --git a/tex/context/third/transliterator/t-transliterator.mkii b/tex/context/third/transliterator/t-transliterator.mkii new file mode 100644 index 0000000..2fcfb0b --- /dev/null +++ b/tex/context/third/transliterator/t-transliterator.mkii @@ -0,0 +1,3 @@ +% Suggested by Taco +\message{Module is unsupported under mkii} +\endinput diff --git a/tex/context/third/transliterator/t-transliterator.mkiv b/tex/context/third/transliterator/t-transliterator.mkiv index aff2be5..deca291 100644 --- a/tex/context/third/transliterator/t-transliterator.mkiv +++ b/tex/context/third/transliterator/t-transliterator.mkiv @@ -1,7 +1,7 @@ %D \enableregime[utf] %D \module -%D [ file=t-degrade, -%D version=2010.02.26, +%D [ file=t-transliterator, +%D version=2010.03.07, %D title=\CONTEXT\ User Module, %D subtitle=The Transliterator, %D author=Philipp Gesang, @@ -21,13 +21,14 @@ %D Use the Transliterator by adding \type{\usemodule[transliterator]} somewhere %D before \type{\starttext}. Adjust the Transliterator through the -%D \type{\setupTranslit} command. As a first argument it accepts a set of +%D \type{\setuptransliterate} command. As a first argument it accepts a set of %D key-value options; at present you may configure \type{mode} and %D \type{hyphenate}. -\def\setupTranslit[#1]{\getparameters[TRL][#1]} +% emendation by Wolfgang Schuster +\def\setuptransliterate{\dodoubleargument\getparameters[TRL]} %D At first we'll set some defaults: -\setupTranslit[mode=ru_old,hyphenate=cz,debug=false] +\setuptransliterate[mode=ru_old,hyphenate=cz,debug=false] %D Possible values for \type{mode} are by the time of this writing: %D \type{ru}, \type{ru_transcript_de}, \type{ru_transcript_en}, \type{ru_old}, %D \type{all}, \type{iso9_ocs}, \type{ocs}, \type{ocs_gla}, \type{ru_cz}, @@ -1788,7 +1789,8 @@ translit.tables["Greek transliteration archaic characters"] = translit.gr_other function translit.subst (text, tab) for symbol, replacement in pairs(tab) do - text = utf.gsub(text, symbol, replacement) + -- using ordinary gsub as suggested by Taco + text = string.gsub(text, symbol, replacement) end return text end @@ -2037,44 +2039,64 @@ end %D switching to a given language (for hyphenation) and adjusting the %D substitution method locally. It takes an optional list \type{[#1]} of %D key-value arguments to allow ad-hoc specification of either two that deviate -%D from the defaults set initially by means of \type{\setupTranslit}. +%D from the defaults set initially by means of \type{\setuptransliterate}. %D %D Internally, \type{\dotransliterate} is called according to the \CONTEXT\ %D coding style and in case the user provides \type{hyphenate=} or %D \type{mode=} those will be used instead of the globals. Note that this %D leaves the latter unchanged. Thus, in order to permanently switch to %D another transliteration style the user would have to set it by calling -%D \type{\setupTranslit} again. +%D \type{\setuptransliterate} again. +% thanks again, Wolfgang! \def\dotransliterate[#1]#2{% - \iffirstargument% - \let\TRLlocalhyphenate\undefined% - \let\TRLlocalmode\undefined% - \getparameters[TRLlocal][#1]% - \ifcsname TRLlocalhyphenate\endcsname% - \translitDebug{\type{\TRLlocalhyphenate} expands to \TRLlocalhyphenate\ (global: \TRLhyphenate). }% - \language[\TRLlocalhyphenate]% - \else% - \translitDebug{\type{\TRLlocalhyphenate} is undefined. Using \TRLhyphenate instead. }% - \language[\TRLhyphenate]% - \fi% - \ifcsname TRLlocalmode\endcsname% - %\translitDebug{{\type{\TRLlocalmode} expands to \TRLlocalmode. }}% - \translitDebug{\type{\TRLlocalmode} is defined. }% - \ctxlua{translit.transliterate ("\TRLlocalmode", "\luaescapestring{#2}")}% - \else% - \translitDebug{\type{\TRLlocalmode} is undefined. Using global \type{\TRLmode}. }% - \ctxlua{translit.transliterate ("\TRLmode", "\luaescapestring{#2}")}% - \fi% - \else% + \bgroup% + \iffirstargument + \getparameters[TRL][#1]% + \fi \language[\TRLhyphenate]% - \translitDebug{No translit options given. Using defaults. }% - \ctxlua{translit.transliterate ("\TRLmode", "\luaescapestring{#2}")}% - \fi% + \ctxlua{translit.transliterate("\TRLmode","\luaescapestring{#2}")}% + \egroup% } +%\definestartstop[transliterate][% + %before={\startbuffer}, + %after={\stopbuffer\transliterate{\getbuffer}} +%] + \def\transliterate{\dosingleempty\dotransliterate} +%\def\starttransliterate {% + %\bgroup\dostarttransliterate% +%} + +%\def\stoptransliterate {% + %\egroup + %\@EA\transliterate{% + %\getbuffer[trl]% + %}% +%} + +%\def\dostarttransliterate{% + %\dostartbuffer[trl][starttransliterate][stoptransliterate]% +%} + +\def\starttransliterate{% + \bgroup% + \dosingleempty\dostarttransliterate +} + +\long\def\dostarttransliterate[#1]#2\stoptransliterate{% + \iffirstargument + \setuptransliterate[#1]% + \fi + \language[\TRLhyphenate]% + \ctxlua{translit.transliterate("\TRLmode","\luaescapestring{#2}")}% + \egroup% +} + \protect +\endinput + % vim:ft=context diff --git a/tex/context/third/transliterator/t-transliterator.tex b/tex/context/third/transliterator/t-transliterator.tex index c08e822..9d4e9f0 100644 --- a/tex/context/third/transliterator/t-transliterator.tex +++ b/tex/context/third/transliterator/t-transliterator.tex @@ -1 +1 @@ -\loadmarkfile[t-transliterator] +\loadmarkfile{t-transliterator} -- cgit v1.2.3