|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://anggtwu.net/LUA/Tudos1.lua.html
-- http://anggtwu.net/LUA/Tudos1.lua
-- (find-angg "LUA/Tudos1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/Tudos1.lua"))
--
-- See: (find-angg ".emacs" "tudos-tex")
-- (find-es "ead" "tudos-tex")
--
-- Tools to manipulate files like this one:
-- (find-LATEX "2022-2-C2-tudo.tex")
-- Usage: run the script in
-- (to "generate-dir")
-- and then this should work:
--
-- (code-c-d "tudostex" "/tmp/tudos-tex/")
-- (find-tudostexfile "")
-- (find-tudostexgrep "grep --color=auto -niH --null -e 'dica 7' *")
-- (find-tudostexgrep "grep --color=auto -niH --null -e 'corrigir' *")
--
-- «.generate-dir» (to "generate-dir")
-- «.basic-tests» (to "basic-tests")
-- (find-angg "LUA/CaeproLisp1.lua" "parsefindpage" "string.tmatch")
string.tmatch = function (str, pat)
local A = VTable {}
for m in str:gmatch(pat) do table.insert(A, m) end
return A
end
string.grep0 = function (bigstr, pat)
local A = VTable {}
for _,li in ipairs(splitlines(bigstr)) do
local a = li:match(pat)
if a then table.insert(A, li) end
end
end
string.grep = function (bigstr, pat)
return table.concat(bigstr:grep0(pat), "\n")
end
mkformat = function (fmt)
return function (str)
return format(fmt, str)
end
end
cattexs = function (stems)
local texs = VTable(map(mkformat("%s.tex"), stems))
local cmd = "cd ~/LATEX/; cat "..table.concat(texs, " ")
local bigstr2 = getoutput(cmd)
return bigstr2
end
catincls = function (stem, outdir)
local fname1 = "~/LATEX/"..stem.."-tudo.tex"
local fname2 = outdir..stem..".tex"
local bigstr1 = ee_readfile(fname1)
local pat = "\n\\incl{([!-~]-)}"
local stems = bigstr1:tmatch(pat)
local texs = VTable(map(mkformat("%s.tex"), stems))
local cmd = "cd ~/LATEX/; cat "..table.concat(texs, " ")
local bigstr2 = getoutput(cmd)
ee_writefile(fname2, bigstr2)
return fname2
end
args = {...}
if args[1] == "-cattudoto" then print(catincls(args[2], args[3])) end
-- «generate-dir» (to ".generate-dir")
--[[
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/tudos-tex/")
rm -Rv /tmp/tudos-tex/
mkdir /tmp/tudos-tex/
cd /tmp/tudos-tex/
lua5.1 ~/LUA/Tudos1.lua -cattudoto 2022-2-C2 /tmp/tudos-tex/
A=( 2020-1 2020-2
2021-1 2021-2
2022-1 2022-2
2023-1
)
for yys in $A; do
echo $yys
lua5.1 ~/LUA/Tudos1.lua -cattudoto ${yys}-C2 /tmp/tudos-tex/
lua5.1 ~/LUA/Tudos1.lua -cattudoto ${yys}-C3 /tmp/tudos-tex/
done
--]]
-- «basic-tests» (to ".basic-tests")
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "Tudos1.lua"
-- (find-fline "~/LATEX/2022-2-C2-tudo.tex")
stem = "2022-2-C2"
outdir = "/tmp/tudos-tex/"
fname1 = "~/LATEX/"..stem.."-tudo.tex"
fname2 = outdir..stem..".tex"
= fname1
= fname2
bigstr1 = ee_readfile(fname1)
pat = "\n\\incl{([!-~]-)}"
stems = bigstr1:tmatch(pat)
texs = VTable(map(mkformat("%s.tex"), stems))
cmd = "cd ~/LATEX/; cat "..table.concat(texs, " ")
= stems
= texs
= cmd
bigstr2 = getoutput(cmd)
= fname2
ee_writefile(fname2, bigstr2)
-- (find-fline "/tmp/tudos-tex/")
-- (find-fline "/tmp/tudos-tex/2022-2-C2.tex")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "Tudos1.lua"
-- (find-fline "~/LATEX/2022-2-C2-tudo.tex")
stem = "2022-2-C2"
fname1 = "~/LATEX/"..stem.."-tudo.tex"
fname2 = "/tmp/tudos-tex/"..stem..".tex"
bigstr1 = ee_readfile(fname1)
pat = "\n\\incl{([!-~]-)}"
stems = bigstr1:tmatch(pat)
bigstr2 = cattexs(stems)
= fname2
ee_writefile(fname2, bigstr2)
-- (find-fline "/tmp/tudos-tex/")
-- (find-fline "/tmp/tudos-tex/2022-2-C2.tex")
= bigstr2:grep("c2m")
--]]
-- Local Variables:
-- coding: utf-8-unix
-- End: