aboutsummaryrefslogtreecommitdiffstats
path: root/become-fansubber.lua
blob: 363411a2015737dbbc9de85a0518f15134729d65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
script_name="CR Restyler"
script_description="become a fansubber with a click of a button"
script_author = "garret"
script_version = "2"

include("cleantags.lua")
-- Main -> Default
-- Top -> an8
-- italics -> i1
-- flashback -> default

function add_tags(line)
    local txt = line.text
    local style = line.style
    if style:find("Italics") then
        txt="{\\i1}"..txt
    end
    if style:find("Top") then
        txt="{\\an8}"..txt
    end
    line.text = cleantags(txt)
    return line
end

function change_styles(line)
    local style = line.style
    if style:find("Top") or style:find("Italics") or style:find("Main") or style:find("Flashback") then
        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)