2021-06-13 14:00:29 +00:00
|
|
|
script_name="CR Restyler"
|
|
|
|
script_description="become a fansubber with a click of a button"
|
|
|
|
script_author = "garret"
|
2021-06-15 15:59:50 +00:00
|
|
|
script_version = "2021-06-15"
|
2021-06-13 14:00:29 +00:00
|
|
|
|
2021-06-13 14:08:28 +00:00
|
|
|
include("cleantags.lua")
|
2021-06-13 14:00:29 +00:00
|
|
|
-- Main -> Default
|
|
|
|
-- Top -> an8
|
|
|
|
-- italics -> i1
|
|
|
|
-- flashback -> default
|
|
|
|
|
|
|
|
function add_tags(line)
|
|
|
|
local txt = line.text
|
|
|
|
local style = line.style
|
2021-06-15 15:59:50 +00:00
|
|
|
if style:match("Italics") then
|
2021-06-13 14:08:28 +00:00
|
|
|
txt="{\\i1}"..txt
|
|
|
|
end
|
2021-06-15 15:59:50 +00:00
|
|
|
if style:match("Top") then
|
2021-06-13 14:08:28 +00:00
|
|
|
txt="{\\an8}"..txt
|
2021-06-13 14:00:29 +00:00
|
|
|
end
|
2021-06-13 14:08:28 +00:00
|
|
|
line.text = cleantags(txt)
|
2021-06-13 14:00:29 +00:00
|
|
|
return line
|
|
|
|
end
|
|
|
|
|
|
|
|
function change_styles(line)
|
|
|
|
local style = line.style
|
2021-06-15 15:59:50 +00:00
|
|
|
if style:match("Top") or style:match("Italics") or style:match("Main") or style:match("Flashback") then
|
2021-06-13 14:00:29 +00:00
|
|
|
line.style="Default"
|
|
|
|
end
|
|
|
|
return line
|
|
|
|
end
|
|
|
|
|
|
|
|
function main(sub, sel)
|
|
|
|
for h, i in ipairs(sel) do
|
|
|
|
local line = sub[i]
|
|
|
|
line = add_tags(line)
|
|
|
|
line = change_styles(line)
|
|
|
|
sub[i] = line
|
|
|
|
end
|
|
|
|
aegisub.set_undo_point(script_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
aegisub.register_macro(script_name, script_description, main)
|