diff options
author | garret <garret@airmail.cc> | 2021-09-30 00:23:28 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2021-09-30 00:37:09 +0100 |
commit | 04a61982e82a5df1cb2ec77a5d9752782a7c41e0 (patch) | |
tree | 35ec751a28b717a7cc6158f84357408173339bff /become-fansubber.lua | |
parent | 2a9e07ff9a5f7084d3e2e54ff5d065f9b0a93591 (diff) | |
download | aegisub-scripts-04a61982e82a5df1cb2ec77a5d9752782a7c41e0.tar.gz aegisub-scripts-04a61982e82a5df1cb2ec77a5d9752782a7c41e0.tar.bz2 aegisub-scripts-04a61982e82a5df1cb2ec77a5d9752782a7c41e0.zip |
macro folder
the beginning of becoming like every other cartel-aproved script repo in existence
Diffstat (limited to 'become-fansubber.lua')
-rw-r--r-- | become-fansubber.lua | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/become-fansubber.lua b/become-fansubber.lua deleted file mode 100644 index 1dfdb43..0000000 --- a/become-fansubber.lua +++ /dev/null @@ -1,54 +0,0 @@ -script_name="Restyler" -script_description="become a fansubber with a click of a button" -script_author = "garret" -script_version = "2.0.0" - -include("karaskel.lua") -include("cleantags.lua") - --- TODO: detect pre-existing inline tags - -- probably need some kind of ass parsing, or a hack with match() - -function add_tags(txt, italic, align) -- everything except txt is boolean. nil = don't change, !nil = change to this value - ---[[not quite happy with this, it overwrites the alignment - ie line is "{\an4} blah blah" and style is an8, it just changes it to an8 -realisticly this _probably_ won't be a problem, but still would like to try and stop it at some point to be safe -italics is fine, it just does {\i1\i0}, which is jank and bad but works fine so i won't worry about it too much]] - if italic == true then - txt="{\\i1}"..txt - elseif italics == false then - txt="{\\i0}"..txt - end - if align ~= nil then - txt="{\\an"..align.."}"..txt - end - txt = cleantags(txt) - return txt -end - -function get_new(old, new) - local i = nil - if old ~= new then - i = old - end - return i -end - -function main(sub, sel) - local _, styles = karaskel.collect_head(sub, false) - local new_style_name = "Default" -- the one we'll be changing stuff to - TODO: configurable - local new_style = styles[new_style_name] - for h, i in ipairs(sel) do - -- TODO: automatically exclude styles (also configurable) - local line = sub[i] - local old_style = styles[line.style] -- reinventing the wheel a bit here, since karaskel can do this with preproc_line_size (line.styleref), but it also adds loads of other crap we don't care about for the same functionality in the end, so ¯\_(ツ)_/¯ - local italic = get_new(old_style.italic, new_style.italic) - local align = get_new(old_style.align, new_style.align) - line.style = new_style_name - line.text = add_tags(line.text, italic, align) - sub[i] = line - end - aegisub.set_undo_point(script_name) -end - -aegisub.register_macro(script_name, script_description, main) |