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 utfchar = unicode.utf8.char
12 local node_new = node.new
13 local node_free = node.free
14 local id_glyph = node.id('glyph')
15 local getcatcode, getcount = tex.getcatcode, tex.getcount
16 local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist
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(getcount('ltjlineendcomment'))==14)
37 -- Is the catcode of endline character is 5 (end-of-line)?
38 -- Is the catcode of \ltjlineendcomment (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 .. utfchar(getcount('ltjlineendcomment'))
46 stop_time_measure('inputbuf')
50 luatexbase.add_to_callback('process_input_buffer',
51 add_comment,'ltj.process_input_buffer')