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\registerctxluafile{typo-chr}{} 37 38\definesystemattribute[marked][public] 39 40\unexpanded\def\removepunctuation 41 { action{remove}\relax} % the first experiment 42 43\unexpanded\def\pushpunctuation 44 { action{push}\relax} % the first experiment 45 46\unexpanded\def\poppunctuation 47 { action{pop}\relax} % the first experiment 48 49\unexpanded\def\markcontent 50 {\dosingleempty\typo_marked_mark} 51 52\def\typo_marked_mark[#1]#2% 53 {\dontleavehmode 54 \bgroup 55 {#1}% 56 \bgroup 57 #2% double grouping makes aftergroups work ok 58 \egroup 59 \egroup} 60 61\unexpanded\def\startmarkedcontent 62 {\dontleavehmode 63 \bgroup 64 \dosingleempty\typo_marked_start} 65 66\def\typo_marked_start[#1]% 67 {{#1}% 68 % double grouping makes aftergroups work ok 69 \bgroup} 70 71\unexpanded\def\stopmarkedcontent 72 {\egroup 73 \egroup} 74 75\unexpanded\def\removemarkedcontent 76 {\dosingleempty\typo_marked_remove} 77 78\def\typo_marked_remove[#1]% 79 { action{remove}mark{#1}\relax} 80 81\unexpanded\def\doifelsemarkedcontent#1% 82 {{#1}} 83 84%D A few helpers (put here for convenience): 85%D 86%D \starttyping 87%D test test\doifelselastnode{boundary}{word}{YES}{NOP}test 88%D test test\wordboundary \doifelselastnode{boundary}{word}{YES}{NOP}test 89%D test test\wordboundary \doifelseatwordboundary{YES}{NOP}test 90%D test test \lastnodeidstring test 91%D test test\lastnodeidstring test 92%D test test\number\lastnodeid test 93%D \stoptyping 94 95\newcount\c_syst_last_node_id 96 97\unexpanded\def\doifelselastnode {} 98\unexpanded\def\doifelseatwordboundary{} 99\unexpanded\def\lastnodeid {\c_syst_last_node_id} 100% \lastnodeidstring % public expandable 101% \lastnodesubstring % public expandable 102 103\protect \endinput 104 |