Skip to content

Commit

Permalink
1.2.16: Changed behavior: Merging now combines lines
Browse files Browse the repository at this point in the history
I kept running into this with short subtitles. If
you prefer it the other way (keeping line breaks),
let me know and we can make it an option.

* subed/subed-srt.el (subed--merge-with-next): Add
a space instead of a newline.
* subed/subed-vtt.el (subed--merge-with-next): Add
a space instead of a newline.
* tests/test-subed-common.el ("subed-common"):
Update merge test.
* tests/test-subed-srt.el ("subed-srt"): Update
merge test.
* tests/test-subed-vtt.el ("subed-vtt"): Update
merge test.
  • Loading branch information
sachac committed Oct 7, 2024
1 parent 010b98c commit 4558c30
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
12 changes: 11 additions & 1 deletion NEWS.org
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#+OPTIONS: toc:nil

* subed news

** Version 1.2.16 - 2024-10-06 - Sacha Chua

- subed-merge-with-next separates subtitles
with spaces instead of newlines. If you prefer
it the other way (keeping line breaks), let me
know and we can make it an option.

- subed-create-file regenerates IDs.

** Version 1.2.15 - 2024-09-06 - Sacha Chua

- Bugfix: Handle extra attributes after VTT timestamps (for example, from YouTube VTTs).
Thanks to Jeff Trull for reporting this!

** Version 1.2.14 - 2024-07-05 - Sacha Chua

- Bugfix: subed-waveform should now handle the
Expand Down
2 changes: 1 addition & 1 deletion subed/subed-srt.el
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Use the format-specific function for MAJOR-MODE."
(setq new-end (subed-timestamp-to-msecs (match-string 0))))
(subed-jump-to-subtitle-text)
(delete-region pos (point))
(insert "\n")
(insert " ")
(let ((subed-enforce-time-boundaries nil))
(subed-set-subtitle-time-stop new-end))
(run-hooks 'subed-subtitle-merged-hook)
Expand Down
2 changes: 1 addition & 1 deletion subed/subed-vtt.el
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ Use the format-specific function for MAJOR-MODE."
(setq new-end (subed-timestamp-to-msecs (match-string 0))))
(subed-jump-to-subtitle-text)
(delete-region pos (point))
(insert "\n")
(insert " ")
(let ((subed-enforce-time-boundaries nil))
(subed-set-subtitle-time-stop new-end))
(run-hooks 'subed-subtitle-merged-hook))
Expand Down
2 changes: 1 addition & 1 deletion subed/subed.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; subed.el --- A major mode for editing subtitles -*- lexical-binding: t; -*-

;; Version: 1.2.15
;; Version: 1.2.16
;; Maintainer: Sacha Chua <[email protected]>
;; Author: Random User
;; Keywords: convenience, files, hypermedia, multimedia
Expand Down
10 changes: 3 additions & 7 deletions tests/test-subed-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -3651,9 +3651,7 @@ Baz.
(subed-merge-region (point-min) (point-max))
(expect (buffer-string) :to-equal "1
00:01:01,000 --> 00:03:15,500
Foo.
Bar.
Baz.
Foo. Bar. Baz.
")))
(it "merges some subtitles."
(with-temp-srt-buffer
Expand All @@ -3662,8 +3660,7 @@ Baz.
(subed-merge-region (point-min) (point))
(expect (buffer-string) :to-equal "1
00:01:01,000 --> 00:02:10,345
Foo.
Bar.
Foo. Bar.
3
00:03:03,45 --> 00:03:15,5
Expand All @@ -3680,8 +3677,7 @@ Foo.
2
00:02:02,234 --> 00:03:15,500
Bar.
Baz.
Bar. Baz.
"))))

(describe "Merging a region and setting the text"
Expand Down
5 changes: 2 additions & 3 deletions tests/test-subed-srt.el
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ This is second subtitle.
(insert mock-srt-data)
(subed-jump-to-subtitle-text 2)
(subed-merge-with-next)
(expect (subed-subtitle-text) :to-equal "Bar.\nBaz.")
(expect (subed-subtitle-text) :to-equal "Bar. Baz.")
(expect (subed-subtitle-msecs-start) :to-equal 122234)
(expect (subed-subtitle-msecs-stop) :to-equal 195500)))
(it "handles lines that are all numbers."
Expand Down Expand Up @@ -1585,8 +1585,7 @@ This is the third subtitle.
4
00:00:03,000 --> 00:00:06,000
This is the fourth subtitle.
123456789
This is the sixth subtitle."))))
123456789 This is the sixth subtitle."))))

(describe "A comment"
(it "is validated."
Expand Down
2 changes: 1 addition & 1 deletion tests/test-subed-vtt.el
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ This is another test here.
(insert mock-vtt-data)
(subed-jump-to-subtitle-text "00:02:02.234")
(subed-merge-with-next)
(expect (subed-subtitle-text) :to-equal "Bar.\nBaz.")
(expect (subed-subtitle-text) :to-equal "Bar. Baz.")
(expect (subed-subtitle-msecs-start) :to-equal 122234)
(expect (subed-subtitle-msecs-stop) :to-equal 195500)))
(it "updates looping."
Expand Down

0 comments on commit 4558c30

Please sign in to comment.