branch: elpa/subed
commit 3b4b56ab45549e86b1fb9d1f954335530bcf5c2c
Merge: bf3e832 b6e08c2
Author: Sacha Chua <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #49 from sachac/fix-vtt-spaces
Handle spaces in between VTT subtitles
---
subed/subed-vtt.el | 2 +-
tests/test-subed-vtt.el | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/subed/subed-vtt.el b/subed/subed-vtt.el
index f0fd28f..1531e47 100644
--- a/subed/subed-vtt.el
+++ b/subed/subed-vtt.el
@@ -232,7 +232,7 @@ can be found."
;; `subed-vtt--regexp-separator' here because if subtitle text is empty,
;; it may be the only empty line in the separator, i.e. there's only one
;; "\n".
- (let ((regex (concat "\\([[:blank:]]*\n+" subed-vtt--regexp-timestamp
"\\|\\([[:blank:]]*\n*\\)\\'\\)")))
+ (let ((regex (concat "\\([[:blank:]]*\n\\)+\\("
subed-vtt--regexp-timestamp "\\)\\|\\([[:blank:]]*\n*\\)\\'")))
(when (re-search-forward regex nil t)
(goto-char (match-beginning 0))))
(unless (= (point) orig-point)
diff --git a/tests/test-subed-vtt.el b/tests/test-subed-vtt.el
index 04c244c..f1ff487 100644
--- a/tests/test-subed-vtt.el
+++ b/tests/test-subed-vtt.el
@@ -260,6 +260,15 @@ Baz.
(backward-char 2)
(expect (subed-vtt--jump-to-subtitle-end) :to-be 112)
(expect (looking-back "^Baz.$") :to-be t)))
+ (it "handles spaces in between subtitles."
+ (with-temp-vtt-buffer
+ (insert mock-vtt-data)
+ (goto-char (point-min))
+ (re-search-forward "Foo\\.\n")
+ (replace-match "Foo.\n ")
+ (goto-char (point-min))
+ (expect (subed-vtt--jump-to-subtitle-end) :to-be 43)
+ (expect (looking-back "^Foo.$") :to-be t)))
(it "returns nil if subtitle end cannot be found."
(with-temp-vtt-buffer
(expect (subed-vtt--jump-to-subtitle-end) :to-be nil)))