attr-alt.mkxl /size: 1668 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=attr-alt,
3%D        version=2007.06.06,
4%D          title=\CONTEXT\ Attribute Macros,
5%D       subtitle=Alternates,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Attribute Macros / Alternates}
15
16\registerctxluafile{attr-alt}{autosuffix}
17
18%D The main reason for providing this is that we need to make sure we have no
19%D dangling end markers when we cross a page. Public viewers don't seem to support
20%D actual text at all and acrobat has some funny selection issues.
21%D
22%D \starttyping
23%D test
24%D     \startalternate[text={A}]
25%D         \dorecurse{10}{A }
26%D         \startalternate[text={B}]
27%D             \dorecurse{10}{B }
28%D         \stopalternate
29%D         \dorecurse{10}{A }
30%D     \stopalternate
31%D test \par
32%D \stoptyping
33%D
34%D \starttyping
35%D test \startalternate[text={e=mc^2}]!$e=mc^2$\stopalternate\par
36%D test \alternate{e=mc^2}{copy:}\nbsp$e=mc^2$\par
37%D \stoptyping
38
39\unprotect
40
41\permanent\protected\def\startalternate[#S#1]% maybe better/also: [text={...}]
42  {\begingroup
43   \getdummyparameters[\c!text=,#1]%
44   \clf_setalternate text {\dummyparameter\c!text}\relax}
45
46\permanent\protected\def\stopalternate
47  {\endgroup}
48
49\permanent\protected\def\alternate#1%
50  {\groupedcommand{\clf_setalternate text {#1}\relax}{}}
51
52\permanent\protected\def\setalternate  #1{\clf_setalternate text {#1}\relax}
53\permanent\protected\def\resetalternate  {\clf_resetalternate}
54
55\protect \endinput
56