Philipp Gesang committed 312ea6a

move test for non-encodable characters to machine

  • Participants
  • Parent commits 55663be

Comments (0)

Files changed (1)

File tex/context/third/enigma/enigma.lua

 Before an input character is passed on to the actual encoding routing,
 the function \luafunction{encode_char} matches it agains the latin
-alphabet. Characters that fail this check are, at the moment, returned
-as they were.
-\TODO{Make behaviour of \luafunction{encode_char} in case of invalid
-input configurable.}
+Characters failing this test are either passed through or ignored,
+depending on the machine option \identifier{other_chars}.
 Also, the counter of encoded characters is incremented at this stage
 and some pretty printer hooks reside here.
 local variable, \identifier{pb_char}.
-  local valid_char_p = letter_to_value
   local encode_char = function (machine, char)
     machine.step = machine.step + 1
   local encode_general = function (machine, chr)
     local chr = stringlower(chr)
     local replacement
-        = pp_substitutions[chr] or valid_char_p[chr] and chr
-    if not replacement then return false end
+        = pp_substitutions[chr] or letter_to_value[chr] and chr
+    if not replacement then
+      if machine.other_chars then
+        return chr
+      else
+        return false
+      end
+    end
     if utf8len(replacement) == 1 then
       return encode_char(machine, replacement)
         local treplacement = replacement and type(replacement)
         --if replacement == false then
         if not replacement then
-          if machine.other_chars then
-            insert_encoded(head, n, nil)
-          else
-            noderemove(head, n)
-          end
+          noderemove(head, n)
         elseif treplacement == "string" then
           --print(head, n, replacement)
           head, _ = insert_encoded(head, n, replacement)
     return head
   end -- callback auxiliary
+  --- Context requires
+  ---  × argument shuffling; a properly registered “action” gets the
+  ---    head passed as its third argument
+  ---  × hacking our way around the coupling of pre_linebreak_filter
+  ---    and hpack_filter; background:
+  ---
   local cbk = function (a, _, c)
+    local head
     current_space_node = generate_space ()
     mod_5              = 0
     if format_is_context == true then