summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-03-07 20:04:31 +0100
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-03-07 20:04:31 +0100
commitee0e10b17847045b623b0fd69d41a7a948616e71 (patch)
treeab5483c9b9de220c2aa6657d11b45b06fc3a0b2a
parent14bfa2f7005009f1691b1df6b761b5994ed1091a (diff)
downloadtransliterator-ee0e10b17847045b623b0fd69d41a7a948616e71.tar.gz
Help from the ConTeXt Code Review Squad (Taco & Wolfgang)
l---------doc/context/third/transliterator/t-transliterator.mkiv1
l---------doc/context/third/transliterator/t-transliterator.xml1
-rw-r--r--doc/context/third/transliterator/transliterator.tex29
-rw-r--r--tex/context/interface/third/t-transliterator.xml6
-rw-r--r--tex/context/third/transliterator/t-transliterator.mkii3
-rw-r--r--tex/context/third/transliterator/t-transliterator.mkiv84
-rw-r--r--tex/context/third/transliterator/t-transliterator.tex2
7 files changed, 76 insertions, 50 deletions
diff --git a/doc/context/third/transliterator/t-transliterator.mkiv b/doc/context/third/transliterator/t-transliterator.mkiv
deleted file mode 120000
index fe8c6e5..0000000
--- a/doc/context/third/transliterator/t-transliterator.mkiv
+++ /dev/null
@@ -1 +0,0 @@
-../../../../tex/context/third/transliterator/t-transliterator.mkiv \ No newline at end of file
diff --git a/doc/context/third/transliterator/t-transliterator.xml b/doc/context/third/transliterator/t-transliterator.xml
deleted file mode 120000
index 476ff63..0000000
--- a/doc/context/third/transliterator/t-transliterator.xml
+++ /dev/null
@@ -1 +0,0 @@
-../../../../tex/context/interface/third/t-transliterator.xml \ No newline at end of file
diff --git a/doc/context/third/transliterator/transliterator.tex b/doc/context/third/transliterator/transliterator.tex
index d769609..92c6ee3 100644
--- a/doc/context/third/transliterator/transliterator.tex
+++ b/doc/context/third/transliterator/transliterator.tex
@@ -242,12 +242,12 @@ pgesang -- AT -- ix -- DOT -- urz -- DOT -- uni-heidelberg -- DOT -- de\par
\completecontent
\chapter{Usage and Functionality}
\section{Overview}
-The Transliterator provides two commands: \type{\setupTranslit}
+The Transliterator provides two commands: \type{\setuptransliterator}
preferably goes into the preamble and allows for global configuration.
The Transliterator is invoked locally by \type{\transliterate} which does the
actual transliteration of text passages.
-\setup{setupTranslit}
+\setup{setuptransliterator}
\setup{transliterate}
@@ -259,7 +259,7 @@ In order to use the Transliterator in a document we put the following somewhere
\stoptyping
Although it has some defaults already set at this point they will most likely
not correspond to what is needed in the document.
-To override the presets we use the command \type{\setupTranslit[#1]}.
+To override the presets we use the command \type{\setuptransliterator[#1]}.
It takes a comma separated list of two key-value pairs: \type{mode} and
\type{hyphenate}.
Through {\em mode} we specify the transliteration method.
@@ -296,7 +296,7 @@ transliteration modes are discussed in detail later in this document.
Through the \type{hyphenate} argument it is possible to adjust the language
that is used for hyphenation.
-Specifying \type{\setupTranslit[hyphenate=nl]} will let every transliterated
+Specifying \type{\setuptransliterator[hyphenate=nl]} will let every transliterated
part of the document be processed according to dutch rules, leaving the overall
\type{\language[#1]} configuration unchanged for the rest of the content.
@@ -419,7 +419,7 @@ to \type{[hyphenate=cs]} (Czech) which produces reasonable results when using
\type{all}, \type{iso9_ocs} or \type{ru_cz}.
For stuff like the English and German transcription use their respective native
hyphenation.\footnote{%
- You'll have to specify this through \type{\setupTranslit}
+ You'll have to specify this through \type{\setuptransliterator}
or locally because the default hyphenation is {\em not} the same as your
documents'.
}
@@ -437,7 +437,10 @@ which will be applied successively to ensure that multi-character rules
are processed first.
\setupfloats[spacebefore=small,spaceafter=small]
-\placetable[left][none]{Processing speed according to GNU time(1) and the \CONTEXT\ stats.}{
+\placetable[left][none]{%
+ Processing time for corpus Evgenij Onegin according
+ to GNU time(1) and the \CONTEXT\ stats.
+}{
\setupTABLE[c][each] [frame=off]
\setupTABLE[r][first] [style=bold,topframe=on,bottomframe=on]
\setupTABLE[r][each] [frame=off,topframe=off,bottomframe=off]
@@ -449,23 +452,23 @@ are processed first.
\bTABLE[split=no,stretch=yes]
\bTABLEhead
\bTR
- \bTH mode \eTH\bTH GNU \eTH\bTH \CONTEXT \eTH
+ \bTH mode \eTH\bTH time(1) \eTH\bTH \CONTEXT \eTH
\eTR
\eTABLEhead
\bTABLEbody
\bTR
- \bTC <none> \eTC\bTC 8.89 \eTC\bTC 8.75 \eTC
+ \bTC <none> \eTC\bTC 8.59 \eTC\bTC 8.43 \eTC
\eTR\bTR
- \bTC \type{ru} \eTC\bTC 9.66 \eTC\bTC 9.45 \eTC
+ \bTC \type{ru} \eTC\bTC 8.84 \eTC\bTC 8.71 \eTC
\eTR\bTR
- \bTC \type{all} \eTC\bTC 12.18 \eTC\bTC 12.04\eTC
+ \bTC \type{all} \eTC\bTC 10.14 \eTC\bTC 10.01 \eTC
\eTR\bTR
- \bTC \type{ru_cz} \eTC\bTC 10.17 \eTC\bTC 10.02 \eTC
+ \bTC \type{ru_cz} \eTC\bTC 9.05 \eTC\bTC 8.92 \eTC
\eTR\bTR
- \bTC \type{ru_transcript_en} \eTC\bTC 11.24 \eTC\bTC 11.11 \eTC
+ \bTC \type{ru_transcript_en} \eTC\bTC 11.36 \eTC\bTC 11.23 \eTC
\eTR\bTR
- \bTC \type{ru_transcript_de} \eTC\bTC 56.58 \eTC\bTC 56.42 \eTC
+ \bTC \type{ru_transcript_de} \eTC\bTC 36.19 \eTC\bTC 36.03 \eTC
\eTR
\eTABLEbody
\eTABLE
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">
- <cd:command name="setupTranslit" file="t-transliterator.mkiv">
+ <cd:command name="setuptransliterator" file="t-transliterator.mkiv">
<cd:sequence>
- <cd:string value="setupTranslit"/>
+ <cd:string value="setuptransliterator"/>
</cd:sequence>
<cd:arguments>
<cd:assignments list="yes" optional="no">
@@ -38,7 +38,7 @@
</cd:sequence>
<cd:arguments>
<cd:assignments list="yes" optional="yes">
- <cd:inherit name="setupTranslit"/>
+ <cd:inherit name="setuptransliterator"/>
</cd:assignments>
</cd:arguments>
</cd:command>
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}