2 -- luatexja/ltj-inputbuf.lua
5 luatexja.load_module('charrange'); local ltjc = luatexja.charrange
7 local utf = unicode.utf8
8 local node_new = node.new
9 local id_glyph = node.id('glyph')
10 local getcatcode = tex.getcatcode
11 local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char
13 --- the following function is modified from jafontspec.lua (by K. Maeda).
14 --- Instead of "%", we use U+FFFFF for suppressing spaces.
15 local function add_comment(buffer)
16 local i = utf.len(buffer)
17 while (i>0) and (getcatcode(utf.byte(buffer, i))==1
18 or getcatcode(utf.byte(buffer, i))==2) do
22 local c = utf.byte(buffer, i)
24 local ct = getcatcode(c)
25 local te = tex.endlinechar
26 local ctl = (te ~= -1) and (getcatcode(te)==5) and (getcatcode(0xFFFFF)==14)
27 -- Is the catcode of endline character is 5 (end-of-line)?
28 -- Is the catcode of U+FFFFF (new comment char) is 14 (comment)?
29 if ((ct==11) or (ct==12)) and ctl then
30 local p = node_new(id_glyph)
32 if ltjc_is_ucs_in_japanese_char(p) then
33 buffer = buffer .. string.char(0xF3,0xBF,0xBF,0xBF) -- U+FFFFF
42 luatexbase.add_to_callback('process_input_buffer',
43 add_comment,'ltj.process_input_buffer')