diff options
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/selnolig/selnolig.lua')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/selnolig/selnolig.lua | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/lualatex/selnolig/selnolig.lua b/Master/texmf-dist/tex/lualatex/selnolig/selnolig.lua index 02a265b4e62..f155b119020 100644 --- a/Master/texmf-dist/tex/lualatex/selnolig/selnolig.lua +++ b/Master/texmf-dist/tex/lualatex/selnolig/selnolig.lua @@ -15,31 +15,20 @@ selnolig = { } selnolig.module = { name = "selnolig", - version = "0.218", - date = "2013/05/28", + version = "0.221", + date = "2013/06/12", description = "Selective suppression of typographic ligatures", author = "Mico Loretan", copyright = "Mico Loretan", license = "LPPL 1.3 or later" } --- Define variables corresponding to various text nodes --- (cf. section 8.1.2 of LuaTeX reference guide) -local hlist = node.id('hlist') -local vlist = node.id('vlist') +-- Define variables corresponding to various text nodes; +-- cf. sections 8.1.2 and 8.1.4 of LuaTeX reference guide local rule = node.id('rule') -local ins = node.id('ins') -local mark = node.id('mark') -local adjust = node.id('adjust') -local disc = node.id('disc') -local math = node.id('math') local glue = node.id("glue") -- local kern = node.id('kern') -local penalty = node.id('penalty') local glyph = node.id('glyph') -- -local margin_kern = node.id('margin_kern') - --- see section 8.1.4 for whatsit nodes: local whatsit = node.id("whatsit") -- local userdefined @@ -51,7 +40,7 @@ end local identifier = 123456 -- any unique identifier local noliga={} local keepliga={} -- String -> Boolean -debug=false +debug=true function debug_info(s) if debug then @@ -63,6 +52,8 @@ local blocknode = node.new(whatsit, userdefined) blocknode.type = 100 blocknode.user_id = identifier +local suppression_on = true -- if false, process_ligatures won't do anything + local prefix_length = function(word, byte) return unicode.utf8.len( string.sub(word,0,byte) ) end @@ -91,6 +82,10 @@ local unicode_find = function(s, pattern, position) end function process_ligatures(nodes,tail) + if not suppression_on then + return -- suppression disabled + end + local s={} local current_node=nodes local build_liga_table = function(strlen,t) @@ -136,9 +131,8 @@ function process_ligatures(nodes,tail) for t in node.traverse(nodes) do if t.id==glyph then s[#s+1]=unicode.utf8.char(t.char) - -- Up until version 0.215, the next instruction was - -- coded simply as "elseif (t.id==glue) then" - elseif ( t.id==glue or t.id==rule or t.id==kern ) then + end + if ( t.id==glue or t.next==nil or t.id==kern or t.id==rule ) then local f=string.gsub(table.concat(s,""),"[\\?!,\\.]+","") local throwliga={} for k,v in pairs (noliga) do @@ -186,6 +180,15 @@ function always_keep_liga(s) keepliga[s] = true end +function enable_suppression(val) + suppression_on = val + if val then + debug_info("Turning ligature suppression on") + else + debug_info("Turning ligature suppression off") + end +end + function enableselnolig() luatexbase.add_to_callback( "ligaturing", process_ligatures, "Suppress ligatures selectively", 1 ) |