diff options
author | Marius <mariausol@gmail.com> | 2014-01-07 16:40:22 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2014-01-07 16:40:22 +0200 |
commit | 5226686f1a384404da122effff2d5eb8d4519711 (patch) | |
tree | 52c9fb30ace5b3897d27d0adfff85f1c70df4b14 /tex/context/base/lang-rep.mkiv | |
parent | ff54944f72aa8a402a330a82e847c9c19fba5f24 (diff) | |
download | context-5226686f1a384404da122effff2d5eb8d4519711.tar.gz |
beta 2014.01.07 15:19
Diffstat (limited to 'tex/context/base/lang-rep.mkiv')
-rw-r--r-- | tex/context/base/lang-rep.mkiv | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tex/context/base/lang-rep.mkiv b/tex/context/base/lang-rep.mkiv new file mode 100644 index 000000000..da5aa955c --- /dev/null +++ b/tex/context/base/lang-rep.mkiv @@ -0,0 +1,69 @@ +%D \module +%D [ file=lang-rep, +%D version=2013.04.28, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Substitution, +%D author=Hans Hagen, +%D date=\currentdate, +%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 +%C details. + +%D As I needed an example of messing with nodes for the bacho\TEX\ tutorial +%D I cooked up this. In the end I decided to stick to a simpler example and +%D just finished this off in case someone really needs it. + +\writestatus{loading}{ConTeXt Language Macros / Replacements} + +\unprotect + +\registerctxluafile{lang-rep}{1.001} + +\definesystemattribute[replacements][public] + +%D \startluacode +%D +%D languages.replacements.add("basics", { +%D ["aap"] = "monkey", +%D ["noot"] = "nut", +%D ["never"] = "forever", +%D ["newer"] = "cooler", +%D ["new"] = "cool", +%D }) +%D +%D \stopluacode +%D +%D \replaceword[more][this][that] +%D \replaceword[more][crap][support] +%D \replaceword[more][---][—] +%D +%D \starttyping +%D \start \setreplacements[basics] What the heck, it's now or never, isn't it new? \stop \par +%D \start \setreplacements[more] Do we --- {\it really} --- need this kind of crap? \stop \par +%D \stoptyping + +\unexpanded\def\setreplacements[#1]% + {\ctxcommand{setreplacements("#1")}} + +\unexpanded\def\resetreplacements + {\attribute\replacementsattribute\attributeunsetvalue} + +\unexpanded\def\replaceword + {\dotripleargument\languages_replacements_replace} + +\unexpanded\def\languages_replacements_replace[#1][#2][#3]% + {\ifthirdargument + \ctxcommand{addreplacements("#1",\!!bs#2\!!es,\!!bs#3\!!es)}% + \fi} + +\appendtoks + \resetreplacements +\to \everyresettypesetting + +\appendtoks + \resetreplacements +\to \everyinitializeverbatim + +\protect \endinput |