From 64f6e8fc0c6cb9254a6fe3db0b4ab31c51cf8524 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 4 Apr 2019 14:11:01 +0200 Subject: 2019-04-04 13:38:00 --- tex/context/base/mkiv/buff-ver.lua | 63 ++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) (limited to 'tex/context/base/mkiv/buff-ver.lua') diff --git a/tex/context/base/mkiv/buff-ver.lua b/tex/context/base/mkiv/buff-ver.lua index bfc9ef89c..969a28055 100644 --- a/tex/context/base/mkiv/buff-ver.lua +++ b/tex/context/base/mkiv/buff-ver.lua @@ -142,7 +142,8 @@ local functions = { __index = { local handlers = { } function visualizers.newhandler(name,data) - local tname, tdata = type(name), type(data) + local tname = type(name) + local tdata = type(data) if tname == "table" then -- (data) setmetatable(name,getmetatable(name) or functions) return name @@ -615,7 +616,12 @@ end local onlyspaces = S(" \t\f\n\r")^0 * P(-1) local function getstrip(lines,first,last) - local first, last = first or 1, last or #lines + if not first then + first = 1 + end + if not last then + last = #lines + end for i=first,last do local li = lines[i] if #li == 0 or lpegmatch(onlyspaces,li) then @@ -741,9 +747,10 @@ local function filter(lines,settings) -- todo: inline or display in settings if strip ~= v_no and strip ~= false then lines = realign(lines,strip) end - local line, n = 0, 0 - local first, last, m = getstrip(lines) + local line = 0 + local n = 0 local range = settings.range + local first, last, m = getstrip(lines) if range then first, last = getrange(lines,first,last,range) first, last = getstrip(lines,first,last) @@ -810,7 +817,7 @@ local function typestring(settings) local compact = settings.compact local compactor = compact and compactors[compact] if compactor then - content = lpegmatch(compactor,content) + content = lpegmatch(compactor,content) or content end -- content = decodecomment(content) -- content = dotabs(content,settings) @@ -846,7 +853,7 @@ implement { actions = typestring, arguments = { { - { "data" }, + { "data" }, { "tab" }, { "method" }, { "compact" }, @@ -856,6 +863,50 @@ implement { } } +-- implement { +-- name = "type_x", +-- actions = typestring, +-- arguments = { +-- { +-- { "data", "verbatim" }, +-- { "tab" }, +-- { "method" }, +-- { "compact" }, +-- { "nature" }, +-- { "escape" }, +-- } +-- } +-- } + +-- local function typestring_y(settings) +-- local content = tex.toks[settings.n] +-- if content and content ~= "" then +-- local compact = settings.compact +-- local compactor = compact and compactors[compact] +-- if compactor then +-- content = lpegmatch(compactor,content) +-- end +-- -- content = decodecomment(content) +-- -- content = dotabs(content,settings) +-- visualize(content,checkedsettings(settings,"inline")) +-- end +-- end + +-- implement { +-- name = "type_y", +-- actions = typestring_y, +-- arguments = { +-- { +-- { "n", "integer" }, +-- { "tab" }, +-- { "method" }, +-- { "compact" }, +-- { "nature" }, +-- { "escape" }, +-- } +-- } +-- } + implement { name = "processbuffer", actions = processbuffer, -- cgit v1.2.3