2 -- luatexja/ltj-inputbuf.lua
5 luatexja.load_module('base'); local ltjb = luatexja.base
6 luatexja.load_module('charrange'); local ltjc = luatexja.charrange
9 local utflen = unicode.utf8.len
10 local utfbyte = unicode.utf8.byte
11 local node_new = node.new
12 local node_free = node.free
13 local id_glyph = node.id('glyph')
14 local getcatcode = tex.getcatcode
15 local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist
16 local FFFFF = string.char(0xF3,0xBF,0xBF,0xBF)
18 --- the following function is modified from jafontspec.lua (by K. Maeda).
19 --- Instead of "%", we use U+FFFFF for suppressing spaces.
20 --DEBUG require"socket"
22 local start_time_measure, stop_time_measure
23 = ltjb.start_time_measure, ltjb.stop_time_measure
24 local function add_comment(buffer)
25 start_time_measure('inputbuf')
26 local i = utflen(buffer)
27 while (i>0) and (getcatcode(utfbyte(buffer, i))==1
28 or getcatcode(utfbyte(buffer, i))==2) do
32 local c = utfbyte(buffer, i)
34 local ct = getcatcode(c)
35 local te = tex.endlinechar
36 local ctl = (te ~= -1) and (getcatcode(te)==5) and (getcatcode(0xFFFFF)==14)
37 -- Is the catcode of endline character is 5 (end-of-line)?
38 -- Is the catcode of U+FFFFF (new comment char) is 14 (comment)?
39 if ((ct==11) or (ct==12)) and ctl then
40 if ltjc_is_japanese_char_curlist(c) then
41 buffer = buffer .. FFFFF -- U+FFFFF
46 stop_time_measure('inputbuf')
50 luatexbase.add_to_callback('process_input_buffer',
51 add_comment,'ltj.process_input_buffer')