|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://anggtwu.net/LUA/SubtitlesLint1.lua.html
-- http://anggtwu.net/LUA/SubtitlesLint1.lua
-- (find-angg "LUA/SubtitlesLint1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/SubtitlesLint1.lua"))
fname = "~/SUBTITLES/emacsconf2024.lua"
pat = '%% %(find%-[0-9A-Za-z]+video "([0-9:]+)"'
-- (find-blogme3 "cruft-jan2024.lua" "youtube_make_url")
toseconds = function (time)
if type(time) ~= "string" then return end
local mm,ss = time:match("^(%d?%d):(%d%d)$")
if ss then return mm*60+ss end
local hh,mm,ss = time:match("^(%d?%d):(%d%d):(%d%d)$")
if ss then return hh*3600+mm*60+ss end
return
end
STLine = Class {
type = "STLine",
from = function (n,time) return STLine {n=n, time=time, s=toseconds(time)} end,
__tostring = function (stl)
return format('(find-fline "%s" %d)', fname, stl.n)
end,
__index = {
},
}
STBadPair = Class {
type = "STBadPair",
from = function (stl1,stl2) return STBadPair {stl1,stl2} end,
__tostring = function (stbp)
return format("%s\n%s", tostring(stbp[1]), tostring(stbp[2]))
end,
__index = {
},
}
Lint = Class {
type = "Lint",
from = function (fname0)
return Lint.from0(fname0):makeA():makeB():print()
end,
from0 = function (fname0)
fname = fname0
bigstr = ee_readfile(fname)
return Lint {}
end,
__index = {
makeA = function (lint)
A = VTable {}
for n,line in ipairs(splitlines(bigstr)) do
local time = line:match(pat)
if time then
table.insert(A, STLine.from(n,time))
end
end
return lint
end,
makeB = function (lint)
B = VTable {}
for i=1,#A-1 do
local l0,l1 = A[i],A[i+1]
local s0,s1 = l0.s,l1.s
if s1-s0 <= 1 then
table.insert(B, STBadPair.from(l0,l1))
end
end
return lint
end,
makeB = function (lint)
B = VTable {}
for i=1,#A-1 do
local l0,l1 = A[i],A[i+1]
local s0,s1 = l0.s,l1.s
if s1-s0 <= 1 then
table.insert(B, STBadPair.from(l0,l1))
end
end
return lint
end,
print = function (lint)
for _,b in ipairs(B) do print(); print(b) end
return lint
end,
},
}
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "SubtitlesLint1.lua"
Lint.from "~/SUBTITLES/2024-piano-roll-macros.lua"
Lint.from "~/SUBTITLES/emacsconf2019.lua"
Lint.from "~/SUBTITLES/emacsconf2020.lua"
Lint.from "~/SUBTITLES/emacsconf2021-dednat6.lua"
Lint.from "~/SUBTITLES/emacsconf2021.lua"
Lint.from "~/SUBTITLES/emacsconf2022-kla.lua"
Lint.from "~/SUBTITLES/emacsconf2022-py.lua"
Lint.from "~/SUBTITLES/emacsconf2023-repls-b.lua"
Lint.from "~/SUBTITLES/emacsconf2023-repls.lua"
Lint.from "~/SUBTITLES/emacsconf2024.lua"
Lint.from "~/SUBTITLES/mathologer-calculus-easy.lua"
Lint.from "~/SUBTITLES/2024-bash-test-blocks.lua"
Lint.from "~/SUBTITLES/2024-convite-maxima.lua"
Lint.from "~/SUBTITLES/2024-eev-git.lua"
Lint.from "~/SUBTITLES/2024-find-luaso-links.lua"
Lint.from "~/SUBTITLES/2024-lean4-oficina-0-aula-2.lua"
Lint.from "~/SUBTITLES/2024-lean4-oficina-0.lua"
Lint.from "~/SUBTITLES/2024-philosophy-tube-butler.lua"
Lint.from "~/SUBTITLES/2024-trying-eev-with-a-sexp.lua"
s1 = STLine.from(4, "1:23")
s2 = STLine.from(6, "1:24")
= s1
p = STBadPair.from(s1, s2)
= p
PP(p)
Lint.from "~/SUBTITLES/emacsconf2024.lua"
fnames = getoutput("cd ~/SUBTITLES; ls *.lua | cat")
= fnames
for _,fname in ipairs(split(fnames)) do
printf('Lint.from "~/SUBTITLES/%s"\n', fname)
-- Lint.from(fname)
end
fname = "~/SUBTITLES/emacsconf2024.lua"
lint = Lint.from0(fname):makeA():makeB():print()
= B
--]]
-- Local Variables:
-- coding: utf-8-unix
-- End: