typo-chr.mkxl /size: 3026 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=typo-chr,
3%D        version=2015.01.01, % or about that time
4%D          title=\CONTEXT\ Typesetting Macros,
5%D       subtitle=Cleaning Up Mess,
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 Typesetting Macros / Characters}
15
16\unprotect
17
18%D This is a very experimental feature, mostly for Alan and me to play with in
19%D publication hell.
20%D
21%D \startbuffer
22%D before, after\par
23%D before,\removepunctuation after\par
24%D before\markcontent[gone]{\darkred   gone}\removemarkedcontent[gone]after\par
25%D before\markcontent[kept]{\darkgreen kept}\removemarkedcontent[gone]after\par
26%D \markcontent[gone]{\darkred   gone}\removemarkedcontent[gone]after\par
27%D \markcontent[kept]{\darkgreen kept}\removemarkedcontent[gone]after\par
28%D \stopbuffer
29%D
30%D \typebuffer \blank \getbuffer\blank
31%D
32%D This feature is paragraph based and is only to be used for small snippets of text,
33%D for instance when combining bit and pieces where keeping a state is complex compared
34%D to cleaning up unwanted stuff.
35
36\newinteger\c_syst_last_node_id
37
38\registerctxluafile{typo-chr}{autosuffix}
39
40\definesystemattribute[marked][public]
41
42\permanent\protected\def\removepunctuation{\clf_pickuppunctuation action{remove}\relax}
43\permanent\protected\def\pushpunctuation  {\clf_pickuppunctuation action{push}\relax}
44\permanent\protected\def\poppunctuation   {\clf_pickuppunctuation action{pop}\relax}
45
46\permanent\tolerant\protected\def\markcontent[#1]#:#2%
47  {\dontleavehmode
48   \bgroup
49   \clf_markcontent{#1}%
50   \bgroup
51   #2% double grouping makes aftergroups work ok
52   \egroup
53   \egroup}
54
55\permanent\tolerant\protected\def\startmarkedcontent[#1]%
56  {\dontleavehmode
57   \bgroup
58   \clf_markcontent{#1}%
59   % double grouping makes aftergroups work ok
60   \bgroup}
61
62\permanent\protected\def\stopmarkedcontent
63  {\egroup
64   \egroup}
65
66\permanent\tolerant\protected\def\removemarkedcontent[#1]%
67  {\clf_pickupmarkedcontent action{remove}mark{#1}\relax}
68
69\permanent\protected\def\doifelsemarkedcontent#1%
70  {\clf_doifelsemarkedcontent{#1}}
71
72%D A few helpers (put here for convenience):
73%D
74%D \starttyping
75%D test test\doifelselastnode{boundary}{word}{YES}{NOP}test
76%D test test\wordboundary \doifelselastnode{boundary}{word}{YES}{NOP}test
77%D test test\wordboundary \doifelseatwordboundary{YES}{NOP}test
78%D test test \lastnodeidstring test
79%D test test\lastnodeidstring test
80%D test test\number\lastnodeid test
81%D \stoptyping
82
83\permanent\protected\def\doifelselastnode      {\clf_lastnodeequals}                 % can be public implementors
84\permanent\protected\def\doifelseatwordboundary{\clf_atwordboundary}                 % can be public implementors
85\permanent\protected\def\lastnodeid            {\clf_lastnodeid\c_syst_last_node_id} % can be public implementors
86
87\protect \endinput
88