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