diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-mis.tex')
-rw-r--r-- | Master/texmf-dist/tex/context/base/lang-mis.tex | 350 |
1 files changed, 81 insertions, 269 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-mis.tex b/Master/texmf-dist/tex/context/base/lang-mis.tex index aa763a71918..13a3f2bb92d 100644 --- a/Master/texmf-dist/tex/context/base/lang-mis.tex +++ b/Master/texmf-dist/tex/context/base/lang-mis.tex @@ -23,7 +23,7 @@ %D \blank} %D %D \gdef\test#1% -%D {\convertargument#1\to\ascii\ascii&\hyphenatedword{#1}\cr} +%D {\defconvertedargument\ascii{#1}\ascii&\hyphenatedword{#1}\cr} \unprotect @@ -178,7 +178,8 @@ %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 \prewordbreak } \fi +\ifx\postwordbreak \undefined \def\postwordbreak{\penalty\zerocount \hskip\zeropoint\relax} \fi \ifx\hspaceamount \undefined \def\hspaceamount#1#2{\kern.16667em} \fi % language specific @@ -210,15 +211,6 @@ \def\@tmd@math@ {@tmd@m@} \def\@tmd@both@ {@tmd@b@} -% \def\installdiscretionary#1#2% -% {\setevalue{\@tmd@math@\detokenize{#1}}{\detokenize{#1}}% -% \setvalue {\@tmd@text@\detokenize{#1}}{#2}% -% \catcode`#1=\@@active % \catcode\expandafter`\detokenize{#1}=\@@active -% \scratchcounter=\the\uccode`\~ -% \uccode`\~=`#1\relax % \uccode`\~=\expandafter`\detokenize{#1}\relax -% \uppercase{\unexpanded\def~{\discretionarycommand~}}% -% \uccode`\~=\scratchcounter} - \def\installdiscretionary#1#2% {\setevalue{\@tmd@math@\detokenize{#1}}{\detokenize{#1}}% \setvalue {\@tmd@text@\detokenize{#1}}{#2}% @@ -256,6 +248,11 @@ %D \type{\checkafterdiscretionary} is responsible for handling %D the comma. +\newsignal\compoundbreakpoint + +\newconditional\punctafterdiscretionary +\newconditional\spaceafterdiscretionary + \def\checkbeforediscretionary {\ifvmode\dontleavehmode\fi \ifhmode @@ -269,13 +266,14 @@ \fi} \def\checkafterdiscretionary - {\ifx,\nextnext - \def\nextnextnext{\afterassignment\egroup\let\next=}% - \else - \let\nextnext\relax - \fi} - -\newsignal\compoundbreakpoint + {\setfalse\punctafterdiscretionary + \setfalse\spaceafterdiscretionary + \ifx\blankspace\nextnext \settrue \spaceafterdiscretionary \else + \ifx\space \nextnext \settrue \spaceafterdiscretionary \else + \ifx .\nextnext \settrue \punctafterdiscretionary \else + \ifx ,\nextnext \settrue \punctafterdiscretionary \else + \ifx :\nextnext \settrue \punctafterdiscretionary \else + \ifx ;\nextnext \settrue \punctafterdiscretionary \fi\fi\fi\fi\fi\fi} \let\domathmodediscretionary\handlemathmodediscretionary @@ -290,39 +288,49 @@ \def\activedododotextmodediscretionary#1#2% {\edef\discretionarytoken{\detokenize{#2}}% \def\textmodediscretionary{\handletextmodediscretionary{#1}}% + \checkafterdiscretionary \ifx\discretionarytoken\empty \ifx#1\nextnext % takes care of ||| and +++ and ...... - \prewordbreak\discretionary{\hbox{$#1$}}{}{\hbox{$#1$}}% - \allowbreak\postwordbreak + \ifcsname\@tmd@action@\string#1\endcsname + \csname\@tmd@action@\string#1\endcsname + \else\ifconditional\spaceafterdiscretionary + \prewordbreak\hbox{\string#1}\relax + \else\ifconditional\punctafterdiscretionary + \prewordbreak\hbox{\string#1}\relax + \else + \prewordbreak\hbox{\string#1}\prewordbreak + \fi\fi\fi \def\nextnextnext{\afterassignment\egroup\let\next=}% \else - \checkafterdiscretionary - \bgroup - \checkbeforediscretionary - % the next line has been changed (20050203) - % \prewordbreak\hbox{\textmodediscretionary\nextnext}\allowbreak\postwordbreak - % but an hbox blocks a possible \discretionary - \prewordbreak\textmodediscretionary\nextnext\allowbreak\postwordbreak - \egroup - \fi - \else\expandafter\ifx\csname\@tmd@action@\discretionarytoken\endcsname\relax - \checkafterdiscretionary - \bgroup \checkbeforediscretionary - \prewordbreak - \discretionary{\hbox{#2}}{}{\hbox{#2}}% - \allowbreak\postwordbreak - \egroup - \else\ifx\nextnextnext\egroup % so we can properly do things afterward - \@EA\egroup - \@EA\let\@EA\nextnextnext\@EA\empty + % 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 + \else\ifconditional\spaceafterdiscretionary + \prewordbreak\textmodediscretionary\relax + \else\ifconditional\punctafterdiscretionary + \prewordbreak\textmodediscretionary\relax + \else + \prewordbreak\textmodediscretionary\prewordbreak + \fi\fi\fi + % \prewordbreak\textmodediscretionary\nextnext\allowbreak\postwordbreak + \fi + \else\ifcsname\@tmd@action@\discretionarytoken\endcsname \csname\@tmd@action@\discretionarytoken\endcsname \else - \csname\@tmd@action@\discretionarytoken\endcsname - \fi\fi\fi + \checkbeforediscretionary + \ifconditional\spaceafterdiscretionary + \prewordbreak\hbox{#2}\relax + \else\ifconditional\punctafterdiscretionary + \prewordbreak\hbox{#2}\relax + \else + \prewordbreak\discretionary{\hbox{#2}}{}{\hbox{#2}}\allowbreak\postwordbreak + \fi\fi + \fi\fi \nextnextnext} % lookahead in commands - %D \macros %D {directdiscretionary} %D @@ -358,16 +366,37 @@ \def\definetextmodediscretionary #1 {\setvalue{\@tmd@action@\detokenize{#1}}} -\definetextmodediscretionary {} % empty case, also handled in parser - {\prewordbreak\compoundhyphen\allowbreak\postwordbreak} +% \start \hsize 1mm +% test |||test test|||, test\blank +% test test|-|, test|-| and test|-|test\blank +% test test|_|, test|_| and test|_|test\blank +% test cd|'|tje\blank +% test |(|test test|)|, test\blank +% test test test|x|, test\blank +% test|~|test +% test|^|test +% \stop + +\def\hyphenliketextmodediscretionary#1#2#3#4% + {\ifconditional\spaceafterdiscretionary + \prewordbreak\hbox{#1}\relax + \else\ifconditional\punctafterdiscretionary + \prewordbreak\hbox{#1}\relax + \else + \prewordbreak\discretionary{#2}{#3}{#4}\postwordbreak % was prewordbreak + \fi\fi} + +\definetextmodediscretionary {} + {\hyphenliketextmodediscretionary\compoundhyphen\compoundhyphen\empty\compoundhyphen} + +\definetextmodediscretionary - + {\hyphenliketextmodediscretionary\hyphen\hyphen\empty\hyphen} \definetextmodediscretionary ~ {\prewordbreak\discretionary{-}{}{\thinspace}\postwordbreak} \definetextmodediscretionary _ - {\prewordbreak - \discretionary{\compoundhyphen}{\compoundhyphen}{\compoundhyphen}% - \prewordbreak} + {\hyphenliketextmodediscretionary\compoundhyphen\compoundhyphen\compoundhyphen\compoundhyphen} \definetextmodediscretionary ( {\ifdim\lastskip>\zeropoint @@ -377,33 +406,24 @@ \fi} \definetextmodediscretionary ) - {\ifx\nextnext\blankspace - \prewordbreak)\relax - \else\ifx\nextnext\space - \prewordbreak)\relax - \else - \prewordbreak\discretionary{-)}{}{)}\prewordbreak - \fi\fi} + {\hyphenliketextmodediscretionary{)}{-)}{}{)}} \definetextmodediscretionary ' {\prewordbreak\discretionary{-}{}{'}\postwordbreak} +\definetextmodediscretionary ^ + {\prewordbreak\discretionary{\hbox{$|$}}{}{\hbox{$|$}}% + \allowbreak\postwordbreak} % bugged + \definetextmodediscretionary < {\beginofsubsentence\prewordbreak\beginofsubsentencespacing} \definetextmodediscretionary > {\endofsubsentencespacing\prewordbreak\endofsubsentence} -% \definetextmodediscretionary . % not yet definitive -% {\prewordbreak\midsentence\prewordbreak} - \definetextmodediscretionary = {\prewordbreak\midsentence\prewordbreak} % {\prewordbreak\compoundhyphen} -\definetextmodediscretionary ^ - {\prewordbreak\discretionary{\hbox{$|$}}{}{\hbox{$|$}}% - \allowbreak\postwordbreak} - % french \definetextmodediscretionary : {\removeunwantedspaces\prewordbreak\kern\hspaceamount\empty{:}:} @@ -660,212 +680,4 @@ \ifx\normalcompound\undefined \let\normalcompound=| \fi -%D ! ! This will be reimplemented !! - -%D \macros -%D {hyphenatedurl} -%D -%D For those who want to put full \URL's in a text, we offer -%D -%D \startbuffer -%D \hyphenatedurl{http://optimist.optimist/optimist/optimist.optimist#optimist} -%D \stopbuffer -%D -%D \typebuffer -%D -%D which breaks at the appropriate places. Watch the \type{#} -%D hack. -%D -%D When passed as argument, like in \type {\goto}, one needs -%D to substitute a \type {\\} for each \type{#}. -%D -%D \startbuffer -%D \hyphenatedurl{http://this.is.a.rather/strange/reference#indeed} -%D \stopbuffer -%D -%D \typebuffer - -\ifx\\\undefined \let\\\crlf \fi - -\chardef\urlsplitmode=1 - -% 0 => don't split -% 1 => . : na, rest voor -% 2 => alles na -% 3 => alles voor - -% \bgroup \catcode`\~=\active \catcode`\/=\active - -% Why not convert to ascii first? I will redo this one! - -\bgroup \catcode`\~=\active \catcode`\/=\active - -\unexpanded\gdef\hyphenatedurl#1% {}{} handles accents - {\bgroup - \ifnum\hyphenpenalty<10000 \else - \def\discretionary##1##2##3{##1\allowbreak##2}% - \fi - \obeyhyphens - \def\splitbefore##1% - {\setbox\scratchbox=\hbox{##1{}{}}% - \ifcase\urlsplitmode - \box\scratchbox - \or - \postwordbreak\box\scratchbox\prewordbreak - \or - \prewordbreak\discretionary{\box\scratchbox}{}{\box\scratchbox}\prewordbreak - \else - \postwordbreak\box\scratchbox\prewordbreak - \fi}% - \def\splitafter##1% - {\ifcase\urlsplitmode - ##1{}{}% - \or - \prewordbreak\discretionary{##1{}{}}{}{##1{}{}}\prewordbreak - \or - \prewordbreak\discretionary{##1{}{}}{}{##1{}{}}\prewordbreak - \else - \prewordbreak\discretionary{}{##1{}{}}{##1{}{}}\prewordbreak - \fi}% - \def\splitanyway##1% - {\prewordbreak##1\prewordbreak}% - \def\flushurl% - {\savedurl\let\savedurl\empty}% - \def\\% - {\spliturl\#}% - \let\~=\lettertilde\let~=\~% - \let\/=\letterslash\let/=\/% - \let\savedurl\empty - \scratchcounter\zerocount % used for hyphenmethod - \handletokens#1\with\scanurl\savedurl - \egroup} - -\egroup - -%D This would be better, but it spoils \type {\~} and so: -%D -%D \starttyping -%D \convertargument#1\to\ascii -%D \expandafter\handletokens\ascii\with\scanurl -%D \stoptyping - -\chardef\urlhyphenmethod=0 - -\def\scanurl#1% - {\advance\scratchcounter\plusone - \ifx#1\blankspace - \flushurl\splitanyway\normalspace - \else\ifx#1\ % - \flushurl\splitanyway\normalspace - \else\ifx#1\space - \flushurl\splitanyway\normalspace - \else\ifx#1\~% - \flushurl\splitbefore\~% - \else\ifx#1\#% - \flushurl\splitbefore\#% - \else\ifx#1\&% - \flushurl\splitbefore\&% - \else\ifx#1\%% - \flushurl\splitbefore\%% - \else\ifx#1\_% - \flushurl\splitbefore\_% - \else\if\noexpand#1\relax - #1% - \else\ifnum\catcode`#1=8 - \flushurl\splitbefore\_% - \else\ifnum\catcode`#1=6 - \flushurl\splitbefore\#% - \else\ifnum\catcode`#1=4 - \flushurl\splitbefore\&% - \else\expandafter\if\string#1\lettertilde - \flushurl\splitbefore\~% - \else\expandafter\if\string#1\letterpercent - \flushurl\splitbefore\%% - \else\expandafter\if\string#1\letterunderscore - \flushurl\splitbefore\_% - \else\expandafter\if\string#1\letterquestionmark - \flushurl\splitafter\letterquestionmark - \else\expandafter\if\string#1\letterat - \flushurl\splitafter\letterat - \else\expandafter\if\string#1\letterslash - \edef\savedurl{\savedurl\letterslash}% - \else\expandafter\if\string#1+% - \flushurl\splitafter+% - \else\expandafter\if\string#1:% - \flushurl\splitafter:% - \else\expandafter\if\string#1.% - \flushurl\splitafter.% - \else\expandafter\if\string#1(% - \flushurl\splitbefore(% - \else\expandafter\if\string#1)% - \flushurl\splitafter)% - \else - \ifx\savedurl\empty\else - \splitbefore\savedurl - \let\savedurl\empty - \fi - \ifcase\urlhyphenmethod - \string#1% - \else - \ifnum\scratchcounter>\plusthree % so, \http: will not break - \edef\savedurl{\string#1}% - \else - \string#1% - \fi - \fi - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} - -% \setupinteraction[state=start] -% \def\gotoURL#1{\useURL[foo][#1]\goto{\url[foo]}[url(foo)]} -% \starttext -% \endgraf \chardef\urlhyphenmethod=0 -% \hsize1pt\gotoURL{http://www.physik.fu-berlin.de/SomeVeryVeryVeryLongDirectory/And/AQuiteLongFileName.html} -% \endgraf \chardef\urlhyphenmethod=1 -% \hsize1pt\gotoURL{http://www.physik.fu-berlin.de/SomeVeryVeryVeryLongDirectory/And/AQuiteLongFileName.html} -% \stoptext - -% \useencoding[ffr] -% \mainlanguage[fr] -% \starttext -% \hyphenatedurl{http://somewhere.to/go} -% \stoptext - -%D When Joop Susan asked (on the \CONTEXT\ mailing list) how -%D to handle url's passed as argument, the following solutions -%D came to my mind: -%D -%D \starttyping -%D \def\whateverurl#1% -%D {{\def~{\string~}\useURL[dummy][#1]\goto{\url[dummy]}[URL(dummy)]}} -%D -%D \def\whateverurl#1% -%D {{\let~\lettertilde\useURL[dummy][#1]\goto{\url[dummy]}[URL(dummy)]}} -%D -%D \def\whateverurl#1% -%D {\convertargument#1\to\ascii -%D \expanded{\useURL[dummy][\ascii]}\goto{\url[dummy]}[URL(dummy)]} -%D \stoptyping - -%D \macros -%D {hyphenatedfile} -%D -%D For the moment we treat filenames in a similar way, -%D -%D \starttyping -%D \hyphenatedfile{here/there/filename.suffix} -%D \stoptyping - -\let\hyphenatedfile\hyphenatedurl - -% to be finished -% -% \def\hyphenatedstring#1% -% {\bgroup -% \nohyphens -% \def\next##1{##1\doif{##1}{-}{\allowbreak}}% -% \handletokens#1\with\next -% \egroup} -% -% {\hsize1cm\hyphenatedstring{ABXXXXXXXXXXC-12345-12345}} - \protect \endinput |