aboutsummaryrefslogtreecommitdiffstats
path: root/em-dash.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2021-04-05 16:03:24 +0100
committergarret <garret@airmail.cc>2021-04-05 16:03:24 +0100
commit9c2c5b5424abd2c61a3d293c2c578134fe1de9ba (patch)
treee91c8ac1dd622c6096bb945a337bf9bad77516f7 /em-dash.lua
downloadaegisub-scripts-9c2c5b5424abd2c61a3d293c2c578134fe1de9ba.tar.gz
aegisub-scripts-9c2c5b5424abd2c61a3d293c2c578134fe1de9ba.tar.bz2
aegisub-scripts-9c2c5b5424abd2c61a3d293c2c578134fe1de9ba.zip
initial commit
Diffstat (limited to 'em-dash.lua')
-rw-r--r--em-dash.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/em-dash.lua b/em-dash.lua
new file mode 100644
index 0000000..99d22df
--- /dev/null
+++ b/em-dash.lua
@@ -0,0 +1,27 @@
+script_name = "Em-dash"
+script_description = "I do not have an em-dash key on my keyboard"
+script_author = "garret"
+script_version = "2021-04-05"
+em = "—"
+function append(sub, sel)
+ for si, li in ipairs(sel) do
+ local line = sub[li]
+ line.text = line.text..em
+ sub[li] = line
+ end
+ aegisub.set_undo_point(script_name)
+end
+
+function replace(sub, sel)
+ for si, li in ipairs(sel) do
+ local line = sub[li]
+ local text = sub[li].text
+ text = text:gsub("%-%-",em)
+ line.text=text
+ sub[li] = line
+ end
+ aegisub.set_undo_point(script_name)
+end
+
+aegisub.register_macro(script_name.."/Append", "Appends an Em-dash to the selected line(s)", append)
+aegisub.register_macro(script_name.."/Replace", "Replaces -- with "..em, replace)