diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-mis.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/lang-mis.mkiv | 280 |
1 files changed, 130 insertions, 150 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-mis.mkiv b/Master/texmf-dist/tex/context/base/lang-mis.mkiv index 231697c7ee7..ce23c0f60e8 100644 --- a/Master/texmf-dist/tex/context/base/lang-mis.mkiv +++ b/Master/texmf-dist/tex/context/base/lang-mis.mkiv @@ -5,7 +5,7 @@ %D subtitle=Compounds, %D author=Hans Hagen, %D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for @@ -13,17 +13,10 @@ \writestatus{loading}{ConTeXt Language Macros / Compounds} -%D \gdef\starttest -%D {\blank -%D \noindent -%D \halign\bgroup\tt##\hskip2em&##\hskip2em&##\cr} -%D -%D \gdef\stoptest -%D {\egroup -%D \blank} -%D -%D \gdef\test#1% -%D {\defconvertedargument\ascii{#1}\ascii&\hyphenatedword{#1}\cr} +%D More or less replaced. + +%D \gdef\starttest#1\stoptest{\starttabulate[|l|l|p|]#1\stoptabulate} +%D \gdef\test #1{\NC\detokenize{#1}\NC\hyphenatedword{#1}\NC#1\NC\NR} \unprotect @@ -131,31 +124,30 @@ %D compound words is using \type{||}, which is installed by: %D %D \starttyping -%D \installdiscretionaries || - +%D \installdiscretionary | - %D \stoptyping %D %D Some alternative definitions are: %D %D \startbuffer -%D \installdiscretionaries ** - -%D \installdiscretionaries ++ - -%D \installdiscretionaries // - -%D \installdiscretionaries ~~ - +%D \installdiscretionary * - +%D \installdiscretionary + - +%D \installdiscretionary / - +%D \installdiscretionary ~ - %D \stopbuffer %D %D \typebuffer %D %D after which we can say: %D -%D \bgroup -%D \getbuffer +%D \start \getbuffer %D \starttest %D \test {test**test**test} %D \test {test++test++test} %D \test {test//test//test} %D \test {test~~test~~test} %D \stoptest -%D \egroup +%D \stop %D \macros %D {compoundhyphen, @@ -165,10 +157,9 @@ %D In the main \CONTEXT\ modules these can be tuned by a setup %D command. Watch the (maybe) better looking compound hyphen. -\ifx\compoundhyphen \undefined \def\compoundhyphen{\hbox{-\kern-.25ex-}} \fi - -\ifx\beginofsubsentence \undefined \def\beginofsubsentence{\hbox{---}} \fi -\ifx\endofsubsentence \undefined \def\endofsubsentence {\hbox{---}} \fi +\ifx\compoundhyphen \undefined \def\compoundhyphen {\hbox{-\kern-.25ex-}} \fi +\ifx\beginofsubsentence\undefined \def\beginofsubsentence{\hbox{---}} \fi +\ifx\endofsubsentence \undefined \def\endofsubsentence {\hbox{---}} \fi %D The last two variables are needed for subsentences %D |<|like this one|>| which we did not yet mention. @@ -177,11 +168,10 @@ %D compound characters like |-| or || to be separated from the %D words. \TEX\ hackers will recognise the next two macro's: -\ifx\prewordbreak \undefined \def\prewordbreak {\penalty\plustenthousand\hskip\zeropoint\relax} \fi -%ifx\postwordbreak \undefined \def\postwordbreak{\penalty\zerocount \prewordbreak } \fi -\ifx\postwordbreak \undefined \def\postwordbreak{\penalty\zerocount \hskip\zeropoint\relax} \fi - -\ifx\hspaceamount \undefined \def\hspaceamount#1#2{.16667em} \fi % language specific +\ifx\prewordbreak \undefined \def\prewordbreak {\penalty\plustenthousand\hskip\zeropoint\relax} \fi +%ifx\postwordbreak\undefined \def\postwordbreak {\penalty\zerocount \prewordbreak } \fi +\ifx\postwordbreak\undefined \def\postwordbreak {\penalty\zerocount \hskip\zeropoint\relax} \fi +\ifx\hspaceamount \undefined \def\hspaceamount#1#2{.16667em} \fi % language specific %D \macros %D {beginofsubsentencespacing,endofsubsentencespacing} @@ -206,20 +196,20 @@ %D |x_n-{1\over2}| &for ${1\over2}<x_n\le1$ \cr}} %D \stopformula -\def\@tmd@action@{@tmd@a@} -\def\@tmd@text@ {@tmd@t@} -\def\@tmd@math@ {@tmd@m@} -\def\@tmd@both@ {@tmd@b@} +\installcorenamespace{discretionaryaction} +\installcorenamespace{discretionarytext} +\installcorenamespace{discretionarymath} +\installcorenamespace{discretionaryboth} \def\installdiscretionary#1#2% - {\setevalue{\@tmd@math@\detokenize{#1}}{\detokenize{#1}}% - \setvalue {\@tmd@text@\detokenize{#1}}{#2}% - \setvalue {\@tmd@both@\detokenize{#1}}{\discretionarycommand#1}% + {\setevalue{\??discretionarymath\detokenize{#1}}{\detokenize{#1}}% ? + \setvalue {\??discretionarytext\detokenize{#1}}{#2}% + \setvalue {\??discretionaryboth\detokenize{#1}}{\lang_discretionaries_command#1}% \scratchcounter\expandafter`\detokenize{#1}% - \@EA\uedcatcodecommand\@EA\ctxcatcodes\@EA\scratchcounter\csname\@tmd@both@\detokenize{#1}\endcsname} + \expandafter\uedcatcodecommand\expandafter\ctxcatcodes\expandafter\scratchcounter\csname\??discretionaryboth\detokenize{#1}\endcsname} -\def\handlemathmodediscretionary#1{\executeifdefined{\@tmd@math@\detokenize{#1}}\donothing} -\def\handletextmodediscretionary#1{\executeifdefined{\@tmd@text@\detokenize{#1}}\donothing} +\def\handlemathmodediscretionary#1{\executeifdefined{\??discretionarymath\detokenize{#1}}\donothing} +\def\handletextmodediscretionary#1{\executeifdefined{\??discretionarytext\detokenize{#1}}\donothing} \def\installdiscretionaries#1#2{\writestatus\m!system{use \string \installdiscretionary}} % obsolete @@ -228,24 +218,24 @@ \def\ignorediscretionaries {\discretionarymode\zerocount} -\def\discretionarycommand +\def\lang_discretionaries_command {% if direct if, we need \relax for lookahead in math mode \csname \ifcase\discretionarymode - \strippedcsname\dononemodediscretionary + \strippedcsname\lang_discretionaries_process_none \else\ifmmode - \strippedcsname\domathmodediscretionary + \strippedcsname\lang_discretionaries_process_math \else - \strippedcsname\dotextmodediscretionary + \strippedcsname\lang_discretionaries_process_text \fi\fi \endcsname} -\def\dononemodediscretionary#1% +\def\lang_discretionaries_process_none#1% {\detokenize{#1}} -%D The macro \type{\checkbeforediscretionary} takes care of -%D loners like \type{||word}, while it counterpart -%D \type{\checkafterdiscretionary} is responsible for handling +%D The macro \type{\lang_discretionaries_check_before} takes care +%D of loners like \type{||word}, while it counterpart \type +%D {\lang_discretionaries_check_after} is responsible for handling %D the comma. \newsignal\compoundbreakpoint @@ -253,8 +243,10 @@ \newconditional\punctafterdiscretionary \newconditional\spaceafterdiscretionary -\def\checkbeforediscretionary - {\ifvmode\dontleavehmode\fi +\def\lang_discretionaries_check_before + {\ifvmode + \dontleavehmode + \fi \ifhmode \begingroup \setbox\scratchbox\lastbox @@ -265,7 +257,7 @@ \endgroup \fi} -\def\checkafterdiscretionary +\def\lang_discretionaries_check_after {\setfalse\punctafterdiscretionary \setfalse\spaceafterdiscretionary \ifx\blankspace\nextnext \settrue \spaceafterdiscretionary \else @@ -275,9 +267,9 @@ \ifx :\nextnext \settrue \punctafterdiscretionary \else \ifx ;\nextnext \settrue \punctafterdiscretionary \fi\fi\fi\fi\fi\fi} -\let\domathmodediscretionary\handlemathmodediscretionary +\let\lang_discretionaries_process_math\handlemathmodediscretionary -\def\dotextmodediscretionary#1% grouped ! +\def\lang_discretionaries_process_text#1% grouped ! {\bgroup \let\nextnextnext\egroup \def\next##1#1% @@ -288,11 +280,11 @@ \def\activedododotextmodediscretionary#1#2% {\edef\discretionarytoken{\detokenize{#2}}% \def\textmodediscretionary{\handletextmodediscretionary{#1}}% - \checkafterdiscretionary + \lang_discretionaries_check_after \ifx\discretionarytoken\empty \ifx#1\nextnext % takes care of ||| and +++ and ...... - \ifcsname\@tmd@action@\string#1\endcsname - \csname\@tmd@action@\string#1\endcsname + \ifcsname\??discretionaryaction\string#1\endcsname + \csname\??discretionaryaction\string#1\endcsname \else\ifconditional\spaceafterdiscretionary \prewordbreak\hbox{\string#1}\relax \else\ifconditional\punctafterdiscretionary @@ -302,12 +294,12 @@ \fi\fi\fi \def\nextnextnext{\afterassignment\egroup\let\next=}% \else - \checkbeforediscretionary + \lang_discretionaries_check_before % the next line has been changed (20050203) % \prewordbreak\hbox{\textmodediscretionary\nextnext}\allowbreak\postwordbreak % but an hbox blocks a possible \discretionary - \ifcsname\@tmd@action@\endcsname - \csname\@tmd@action@\endcsname + \ifcsname\??discretionaryaction\endcsname + \csname\??discretionaryaction\endcsname \else\ifconditional\spaceafterdiscretionary \prewordbreak\textmodediscretionary\relax \else\ifconditional\punctafterdiscretionary @@ -317,10 +309,10 @@ \fi\fi\fi % \prewordbreak\textmodediscretionary\nextnext\allowbreak\postwordbreak \fi - \else\ifcsname\@tmd@action@\discretionarytoken\endcsname - \csname\@tmd@action@\discretionarytoken\endcsname + \else\ifcsname\??discretionaryaction\discretionarytoken\endcsname + \csname\??discretionaryaction\discretionarytoken\endcsname \else - \checkbeforediscretionary + \lang_discretionaries_check_before \ifconditional\spaceafterdiscretionary \prewordbreak\hbox{#2}\relax \else\ifconditional\punctafterdiscretionary @@ -340,31 +332,31 @@ \def\directdiscretionary {\csname \ifcase\discretionarymode - \strippedcsname\dononemodediscretionary + \strippedcsname\lang_discretionaries_process_none \else - \strippedcsname\dodirectdiscretionary + \strippedcsname\lang_discretionaries_process_direct \fi \endcsname} \def\indirectdiscretionary {\csname \ifcase\discretionarymode - \strippedcsname\dononemodediscretionary + \strippedcsname\lang_discretionaries_process_none \else - \strippedcsname\doindirectdiscretionary + \strippedcsname\lang_discretionaries_process_indirect \fi \endcsname} -\unexpanded\def\dodirectdiscretionary#1% +\unexpanded\def\lang_discretionaries_process_direct#1% {\edef\discretionarytoken{\detokenize{#1}}% \let\textmodediscretionary\compoundhyphen - \executeifdefined{\@tmd@action@\discretionarytoken}{\indirectdiscretionary{#1}}} + \executeifdefined{\??discretionaryaction\discretionarytoken}{\indirectdiscretionary{#1}}} -\unexpanded\def\doindirectdiscretionary#1% +\unexpanded\def\lang_discretionaries_process_indirect#1% {\prewordbreak\discretionary{\hbox{#1}}{}{\hbox{#1}}\allowbreak\postwordbreak} \unexpanded\def\definetextmodediscretionary #1 - {\setvalue{\@tmd@action@\detokenize{#1}}} + {\setvalue{\??discretionaryaction\detokenize{#1}}} % \start \hsize 1mm % test |||test test|||, test\blank @@ -383,7 +375,7 @@ % xxx3xxx % xxx1<newline>2xxx -\def\hyphenliketextmodediscretionary#1#2% +\def\lang_discretionaries_hyphen_like#1#2% {\ifconditional\spaceafterdiscretionary \prewordbreak\hbox{#1}\relax \else\ifconditional\punctafterdiscretionary @@ -393,16 +385,16 @@ \fi\fi} \definetextmodediscretionary {} - {\hyphenliketextmodediscretionary\textmodehyphen\textmodehyphendiscretionary} + {\lang_discretionaries_hyphen_like\textmodehyphen\textmodehyphendiscretionary} \definetextmodediscretionary - - {\hyphenliketextmodediscretionary\normalhyphen\normalhyphendiscretionary} + {\lang_discretionaries_hyphen_like\normalhyphen\normalhyphendiscretionary} \definetextmodediscretionary _ - {\hyphenliketextmodediscretionary\composedhyphen\composedhyphendiscretionary} + {\lang_discretionaries_hyphen_like\composedhyphen\composedhyphendiscretionary} \definetextmodediscretionary ) - {\hyphenliketextmodediscretionary{)}{\discretionary{-)}{}{)}}} + {\lang_discretionaries_hyphen_like{)}{\discretionary{-)}{}{)}}} \definetextmodediscretionary ( {\ifdim\lastskip>\zeropoint @@ -447,7 +439,7 @@ % \ifx\normalcompound\undefined \let\normalcompound=| \fi -%D \installdiscretionary | + +%D \installdiscretionary | + %D \installdiscretionary + = \def\defaultdiscretionaryhyphen{\compoundhyphen} @@ -466,10 +458,10 @@ %D \goto{Some||Long||Word} %D \stoptyping -\def\fakecompoundhyphen - {\def\|{\mathortext\vert\dofakecompoundhyphen}} +\unexpanded\def\fakecompoundhyphen + {\def\|{\mathortext\vert\lang_compounds_fake_hyphen}} -\def\dofakecompoundhyphen +\def\lang_compounds_fake_hyphen {\def##1|% {\doifelsenothing{##1}\compoundhyphen{##1}% \kern\compoundbreakpoint\allowbreak}} @@ -483,13 +475,13 @@ %D earlier, this one also looks ahead for spaces and grouping %D tokens. -\def\midworddiscretionary - {\futurelet\next\domidworddiscretionary} +\unexpanded\def\midworddiscretionary + {\futurelet\nexttoken\lang_discretionaries_mid_word} -\def\domidworddiscretionary - {\ifx\next\blankspace\else - \ifx\next\bgroup \else - \ifx\next\egroup \else +\def\lang_discretionaries_mid_word + {\ifx\nexttoken\blankspace\else + \ifx\nexttoken\bgroup \else + \ifx\nexttoken\egroup \else \discretionary{-}{}{}% \fi\fi\fi} @@ -533,10 +525,10 @@ %D mentioned earlier in this module. We take care of two %D arguments, which complicates things a bit. -\def\@nc@{@nc@} % normal character -\def\@cc@{@cc@} % compound character -\def\@cs@{@cs@} % compound characters -\def\@cx@{@cx@} % compound definition +\installcorenamespace{compoundnormal} +\installcorenamespace{compoundsingle} +\installcorenamespace{compoundmultiple} +\installcorenamespace{compounddefinition} %D When we started working on MK IV code, we needed a different %D approach for defining the active character itself. In MK II as @@ -544,39 +536,26 @@ \setnewconstant\compoundcharactermode\plusone +\newcount\c_lang_compounds_character + \def\installcompoundcharacter #1#2#3 #4% {#4} no grouping {\ifcase\compoundcharactermode % ignore mode \else - \chardef\thecompoundcharacter`#1% - \@EA\chardef\csname\@nc@\string#1\endcsname\thecompoundcharacter + \chardef\c_lang_compounds_character`#1% + \expandafter\chardef\csname\??compoundnormal\string#1\endcsname\c_lang_compounds_character \def\!!stringa{#3}% - \@EA\def\csname\ifx\!!stringa\empty\@cc@\else\@cs@\fi\detokenize{#1#2#3}\endcsname{#4}% - \setevalue{\@cx@\detokenize{#1}}{\noexpand\handlecompoundcharacter{\detokenize{#1}}}% beter nr's - \@EA\letcatcodecommand\@EA\ctxcatcodes\@EA\thecompoundcharacter\csname\@cx@\detokenize{#1}\endcsname + \expandafter\def\csname\ifx\!!stringa\empty\??compoundsingle\else\??compoundmultiple\fi\detokenize{#1#2#3}\endcsname{#4}% + \setevalue{\??compounddefinition\detokenize{#1}}{\noexpand\lang_compounds_handle_character{\detokenize{#1}}}% beter nr's + \expandafter\letcatcodecommand\expandafter\ctxcatcodes\expandafter\c_lang_compounds_character\csname\??compounddefinition\detokenize{#1}\endcsname \fi} -%D In order to serve the language specific well, we will introduce -%D a namespace: - -% \ifx\currentlanguage\undefined - \let\compoundcharacterclass\empty -% \else -% \def\compoundcharacterclass{\currentlanguage} -% \fi - -\def\@cc@{@cc@\compoundcharacterclass} % compound character -\def\@cs@{@cs@\compoundcharacterclass} % compound characters - %D We can also ignore definitions (needed in for instance \XML). Beware, %D this macro is supposed to be used grouped! \def\ignorecompoundcharacter {\compoundcharactermode\zerocount} -\let\restorecompoundcharacter \gobbleoneargument % obsolete -\let\enableactivediscretionaries\relax % obsolete - %D In handling the compound characters we have to take care of %D \type{\bgroup} and \type{\egroup} tokens, so we end up with %D a multi||step interpretation macro. We look ahead for a @@ -589,40 +568,41 @@ %D with \type{\futurelet} to prevent spaces from %D disappearing. -\def\handlecompoundcharacter#1% - {\def\xhandlecompoundcharacter{\dohandlecompoundcharacter{#1}}% - \futurelet\next\xhandlecompoundcharacter} - -\def\dohandlecompoundcharacter - {\ifx\next\bgroup - %\@EA\dodohandlecompoundcharacter % handle "{ee} -> \"ee - %\@EA\gobbleoneargument % forget "{ee} -> ee - \@EA\handlecompoundcharacterone % ignore "{ee} -> "ee - \else\ifx\next\egroup - \@EAEAEA\donohandlecompoundcharacter - \else\ifx\next\blankspace - \@EA\@EAEAEA\@EA\donohandlecompoundcharacter +\def\lang_compounds_handle_character#1% + {\def\lang_compounds_handle_character_finish{\lang_compounds_handle_character_finish_indeed{#1}}% + \futurelet\nexttoken\xhandlecompoundcharacter} + +\def\lang_compounds_handle_character_finish_indeed + {\ifx\nexttoken\bgroup + %\expandafter\lang_compounds_handle_character_pickup % handle "{ee} -> \"ee + %\expandafter\gobbleoneargument % forget "{ee} -> ee + \expandafter\lang_compounds_handle_character_one % ignore "{ee} -> "ee + \else\ifx\nexttoken\egroup + \doubleexpandafter\lang_compounds_handle_character_normal + \else\ifx\nexttoken\blankspace + \tripleexpandafter\lang_compounds_handle_character_normal \else - \@EA\@EAEAEA\@EA\dodohandlecompoundcharacter + \tripleexpandafter\lang_compounds_handle_character_pickup \fi\fi\fi} -\def\donohandlecompoundcharacter#1{\csname\@nc@\string#1\endcsname} +\def\lang_compounds_handle_character_normal#1% + {\csname\??compoundnormal\string#1\endcsname} + +\def\lang_compounds_handle_character_pickup#1#2% preserve space + {\def\lang_compounds_handle_character_finish{\lang_compounds_handle_character_finish_indeed#1#2}% + \futurelet\nexttoken\lang_compounds_handle_character_finish} -\def\dododohandlecompoundcharacter - {\ifx\next\bgroup - \@EA\handlecompoundcharacterone - \else\ifx\next\egroup - \@EAEAEA\handlecompoundcharacterone - \else\ifx\next\blankspace - \@EA\@EAEAEA\@EA\handlecompoundcharacterone +\def\lang_compounds_handle_character_finish_indeed + {\ifx\nexttoken\bgroup + \expandafter\lang_compounds_handle_character_one + \else\ifx\nexttoken\egroup + \doubleexpandafter\lang_compounds_handle_character_one + \else\ifx\nexttoken\blankspace + \tripleexpandafter\lang_compounds_handle_character_one \else - \@EA\@EAEAEA\@EA\handlecompoundcharactertwo + \tripleexpandafter\lang_compounds_handle_character_two \fi\fi\fi} -\def\dodohandlecompoundcharacter#1#2% preserve space - {\def\xdodohandlecompoundcharacter{\dododohandlecompoundcharacter#1#2}% - \futurelet\next\xdodohandlecompoundcharacter} - %D Besides taken care of the grouping and space tokens, we have %D to deal with three situations. First we look if the next %D character equals the first one, if so, then we just insert @@ -636,25 +616,25 @@ %D %D In later modules we will see how these commands are used. -\long\def\handlecompoundcharacterone#1#2% +\def\lang_compounds_handle_character_one#1#2% {\if\string#1\string#2% was: \ifx#1#2% - \def\next{\csname\@nc@\string#1\endcsname}% - \else\ifcsname\@cc@\string#1\string#2\endcsname - \def\next{\csname\@cc@\string#1\string#2\endcsname}% + \def\next{\csname\??compoundnormal\string#1\endcsname}% + \else\ifcsname\??compoundsingle\string#1\string#2\endcsname + \def\next{\csname\??compoundsingle\string#1\string#2\endcsname}% \else - \def\next{\csname\@nc@\string#1\endcsname#2}% + \def\next{\csname\??compoundnormal\string#1\endcsname#2}% \fi\fi \next} -\long\def\handlecompoundcharactertwo#1#2#3% +\def\lang_compounds_handle_character_two#1#2#3% {\if\string#1\string#2% - \def\next{\csname\@nc@\string#1\endcsname#3}% - \else\ifcsname\@cs@\string#1\string#2\string#3\endcsname - \def\next{\csname\@cs@\string#1\string#2\string#3\endcsname}% - \else\ifcsname\@cc@\string#1\string#2\endcsname - \def\next{\csname\@cc@\string#1\string#2\endcsname#3}% + \def\next{\csname\??compoundnormal\string#1\endcsname#3}% + \else\ifcsname\??compoundmultiple\string#1\string#2\string#3\endcsname + \def\next{\csname\??compoundmultiple\string#1\string#2\string#3\endcsname}% + \else\ifcsname\??compoundsingle\string#1\string#2\endcsname + \def\next{\csname\??compoundsingle\string#1\string#2\endcsname#3}% \else - \def\next{\csname\@nc@\string#1\endcsname#2#3}% + \def\next{\csname\??compoundnormal\string#1\endcsname#2#3}% \fi\fi\fi \next} @@ -662,8 +642,8 @@ %D {lang-sla.tex}) we provide: \def\simplifiedcompoundcharacter#1#2% - {\ifcsname\@cc@\string#1\string#2\endcsname - \@EA\@EA\@EA\firstofoneargument\csname\@cc@\string#1\string#2\endcsname + {\ifcsname\??compoundsingle\string#1\string#2\endcsname + \doubleexpandafter\firstofoneargument\csname\??compoundsingle\string#1\string#2\endcsname \else #2% \fi} @@ -682,6 +662,6 @@ %D %D Handy in for instance XML. (Kind of obsolete) -\ifx\normalcompound\undefined \let\normalcompound=| \fi +\ifdefined\normalcompound \else \let\normalcompound=| \fi \protect \endinput |