|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- https://anggtwu.net/LUA/Anchors1.lua.html
-- https://anggtwu.net/LUA/Anchors1.lua
-- (find-angg "LUA/Anchors1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
-- (find-es "lua5" "string.byte")
--
-- «.Anchors» (to "Anchors")
-- «.Anchors-tests» (to "Anchors-tests")
-- «Anchors» (to ".Anchors")
Anchors = Class {
type = "Anchors",
width = 33,
prefix = "% ",
fromfile = function (fname) return Anchors{}:readfile(fname) end,
__index = {
pat = "\194?\171([!-~]+)\194?\187",
totags = function (a,bigstr)
local tags = VTable {}
for tag in bigstr:gmatch(a.pat) do
if tag:match("^[^.]") then table.insert(tags, tag) end
end
return tags
end,
readfile = function (a,fname)
a.tags = a:totags(ee_readfile(fname))
return a
end,
totabs = function (a,nspaces)
local tabs = ""
while nspaces > 1 do tabs=tabs.."\t"; nspaces=nspaces-8 end
return tabs
end,
toindexline = function (a,tag)
local str0 = Anchors.prefix .. format("<.%s>", tag)
local str1 = Anchors.prefix .. format("«.%s»", tag)
local str3 = format("(to \"%s\")", tag)
local nspaces = Anchors.width - #str0
local str2 = a:totabs(nspaces)
return str1..str2..str3
end,
indexlines = function (a)
local f = function (tag) return a:toindexline(tag) end
return mapconcat(f, a.tags, "\n")
end,
},
}
-- «Anchors-tests» (to ".Anchors-tests")
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "Anchors1.lua"
aa = Anchors.fromfile "~/LATEX/2026logica-para-pessoas.tex"
aa = Anchors.fromfile "~/LUA/Anchors1.lua"
= aa.tags
= aa:indexlines()
--]]
-- Local Variables:
-- coding: utf-8-unix
-- End: