summaryrefslogtreecommitdiff
path: root/tex/context/base/buff-ver.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/buff-ver.lua')
-rw-r--r--tex/context/base/buff-ver.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua
index e327a59dd..e6508d3a5 100644
--- a/tex/context/base/buff-ver.lua
+++ b/tex/context/base/buff-ver.lua
@@ -10,16 +10,16 @@ if not modules then modules = { } end modules ['buff-ver'] = {
-- supposed to use different names for their own variants.
--
-- todo: skip=auto
+--
+-- todo: update to match context scite lexing
-local type, next, rawset, rawget, setmetatable, getmetatable = type, next, rawset, rawget, setmetatable, getmetatable
+local type, next, rawset, rawget, setmetatable, getmetatable, tonumber = type, next, rawset, rawget, setmetatable, getmetatable, tonumber
local format, lower, upper,match, find, sub = string.format, string.lower, string.upper, string.match, string.find, string.sub
local splitlines = string.splitlines
local concat = table.concat
local C, P, R, S, V, Carg, Cc, Cs = lpeg.C, lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.Carg, lpeg.Cc, lpeg.Cs
local patterns, lpegmatch, is_lpeg = lpeg.patterns, lpeg.match, lpeg.is_lpeg
-local context, commands = context, commands
-
local trace_visualize = false trackers.register("buffers.visualize", function(v) trace_visualize = v end)
local report_visualizers = logs.reporter("buffers","visualizers")
@@ -29,6 +29,9 @@ visualizers = visualizers or { }
local specifications = allocate()
visualizers.specifications = specifications
+local context = context
+local commands = commands
+
local tabtospace = utilities.strings.tabtospace
local variables = interfaces.variables
local settings_to_array = utilities.parsers.settings_to_array
@@ -568,7 +571,7 @@ local function realign(lines,strip) -- "yes", <number>
if strip == v_yes then
n = math.huge
for i=1, #lines do
- local spaces = find(lines[i],"%S")
+ local spaces = find(lines[i],"%S") -- can be lpeg
if not spaces then
-- empty line
elseif spaces == 0 then
@@ -592,11 +595,13 @@ local function realign(lines,strip) -- "yes", <number>
return lines
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
for i=first,last do
local li = lines[i]
- if #li == 0 or find(li,"^%s*$") then
+ if #li == 0 or lpegmatch(onlyspaces,li) then
first = first + 1
else
break
@@ -604,7 +609,7 @@ local function getstrip(lines,first,last)
end
for i=last,first,-1 do
local li = lines[i]
- if #li == 0 or find(li,"^%s*$") then
+ if #li == 0 or lpegmatch(onlyspaces,li) then
last = last - 1
else
break