summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/typo-chr.mkiv
blob: 7da783ceb4b709f25f034fe02a6ac90e730bfaeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
%D \module
%D   [       file=typo-chr,
%D        version=2015.01.01, % or about that time
%D          title=\CONTEXT\ Typesetting Macros,
%D       subtitle=Cleaning Up Mess,
%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.

\writestatus{loading}{ConTeXt Typesetting Macros / Characters}

\unprotect

%D This is a very experimental feature, mostly for Alan and me to play with in
%D publication hell.
%D
%D \startbuffer
%D before, after\par
%D before,\removepunctuation after\par
%D before\markcontent[gone]{\darkred   gone}\removemarkedcontent[gone]after\par
%D before\markcontent[kept]{\darkgreen kept}\removemarkedcontent[gone]after\par
%D \markcontent[gone]{\darkred   gone}\removemarkedcontent[gone]after\par
%D \markcontent[kept]{\darkgreen kept}\removemarkedcontent[gone]after\par
%D \stopbuffer
%D
%D \typebuffer \blank \getbuffer\blank
%D
%D This feature is paragraph based and is only to be used for small snippets of text,
%D for instance when combining bit and pieces where keeping a state is complex compared
%D to cleaning up unwanted stuff.

\registerctxluafile{typo-chr}{}

\definesystemattribute[marked][public]

\unexpanded\def\removepunctuation
  {\clf_pickuppunctuation action{remove}\relax} % the first experiment

\unexpanded\def\pushpunctuation
  {\clf_pickuppunctuation action{push}\relax} % the first experiment

\unexpanded\def\poppunctuation
  {\clf_pickuppunctuation action{pop}\relax} % the first experiment

\unexpanded\def\markcontent
  {\dosingleempty\typo_marked_mark}

\def\typo_marked_mark[#1]#2%
  {\dontleavehmode
   \bgroup
   \clf_markcontent{#1}%
   \bgroup
   #2% double grouping makes aftergroups work ok
   \egroup
   \egroup}

\unexpanded\def\startmarkedcontent
  {\dontleavehmode
   \bgroup
   \dosingleempty\typo_marked_start}

\def\typo_marked_start[#1]%
  {\clf_markcontent{#1}%
   % double grouping makes aftergroups work ok
   \bgroup}

\unexpanded\def\stopmarkedcontent
  {\egroup
   \egroup}

\unexpanded\def\removemarkedcontent
  {\dosingleempty\typo_marked_remove}

\def\typo_marked_remove[#1]%
  {\clf_pickupmarkedcontent action{remove}mark{#1}\relax}

%D A few helpers (put here for convenience):
%D
%D \starttyping
%D test test\doifelselastnode{boundary}{word}{YES}{NOP}test
%D test test\wordboundary \doifelselastnode{boundary}{word}{YES}{NOP}test
%D test test\wordboundary \doifelseatwordboundary{YES}{NOP}test
%D test test \lastnodeidstring test
%D test test\lastnodeidstring test
%D test test\number\lastnodeid test
%D \stoptyping

\newcount\c_syst_last_node_id

\unexpanded\def\doifelselastnode      {\clf_lastnodeequals}
\unexpanded\def\doifelseatwordboundary{\clf_atwordboundary}
\unexpanded\def\lastnodeid            {\clf_lastnodeid\c_syst_last_node_id}
%              \lastnodeidstring      % public expandable
%              \lastnodesubstring     % public expandable

\protect \endinput