[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 564b6fe 386/389: Add preliminary support for comment
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 564b6fe 386/389: Add preliminary support for comments in VTT files |
Date: |
Fri, 3 Dec 2021 11:01:03 -0500 (EST) |
branch: elpa/subed
commit 564b6fec7fddab0b0422ce3d5bba02e3985dd58b
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
Add preliminary support for comments in VTT files
* subed/subed-vtt.el (subed-vtt--regexp-separator): Add support for NOTE.
(subed-vtt--jump-to-subtitle-end): Jump before comments.
* tests/test-subed-vtt.el ("VTT"): Add test case for comments.
---
subed/subed-vtt.el | 6 ++++--
tests/test-subed-vtt.el | 21 ++++++++++++++++++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/subed/subed-vtt.el b/subed/subed-vtt.el
index 1531e47..6484886 100644
--- a/subed/subed-vtt.el
+++ b/subed/subed-vtt.el
@@ -44,7 +44,7 @@
;;; Parsing
(defconst subed-vtt--regexp-timestamp
"\\(\\([0-9]+\\):\\)?\\([0-9]+\\):\\([0-9]+\\)\\.\\([0-9]+\\)")
-(defconst subed-vtt--regexp-separator "\\(?:[[:blank:]]*\n\\)+[[:blank:]]*\n")
+(defconst subed-vtt--regexp-separator "\\(?:[[:blank:]]*\n\\)+\\(?:NOTE[
\n]\\(?:.+?\n\\)+\n\\)*\n")
(defun subed-vtt--timestamp-to-msecs (time-string)
"Find HH:MM:SS.MS pattern in TIME-STRING and convert it to milliseconds.
@@ -232,7 +232,9 @@ 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\\)+"
+ "\\(?:NOTE[ \n]\\(?:.+?\n\\)+\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 f1ff487..cfcbc93 100644
--- a/tests/test-subed-vtt.el
+++ b/tests/test-subed-vtt.el
@@ -1151,4 +1151,23 @@ Baz.
(describe "Converting msecs to timestamp"
(it "uses the right format"
(with-temp-vtt-buffer
- (expect (subed-msecs-to-timestamp 1401) :to-equal "00:00:01.401")))))
+ (expect (subed-msecs-to-timestamp 1401) :to-equal "00:00:01.401"))))
+ (describe "Working with comments"
+ (it "ignores the comment when jumping to the end of the subtitle"
+ (with-temp-vtt-buffer
+ (insert "WEBVTT
+
+00:00:00.000 --> 00:00:01.000
+This is a test.
+
+NOTE A comment can go here
+and have more text as needed.
+
+00:01:00.000 --> 00:00:02.000
+This is another test here.
+")
+ (goto-char (point-min))
+ (subed-forward-subtitle-end)
+ (expect (current-word) :to-equal "test")
+ (subed-forward-subtitle-end)
+ (expect (current-word) :to-equal "here")))))
- [nongnu] elpa/subed 3ba295b 336/389: Fix "service name too long", (continued)
- [nongnu] elpa/subed 3ba295b 336/389: Fix "service name too long", ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 961e5eb 343/389: More subed-vtt fixes: require subed-vtt, validate better, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 87b3823 353/389: subed-split-subtitle works at the beginning or end of subtitle text, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3b4b56a 384/389: Merge pull request #49 from sachac/fix-vtt-spaces, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed bee9e63 342/389: subed-vtt: Fix syncing point with player, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 016c6a5 363/389: subed-split-subtitle: Handle more cases, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6164f88 380/389: Keep track of video being played, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 70561f0 381/389: Make hours optional in VTT files, following the spec, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed bf3e832 382/389: Check if subed--cps-overlay exists before trying to update it, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b6e08c2 383/389: Handle spaces in between VTT subtitles, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 564b6fe 386/389: Add preliminary support for comments in VTT files,
ELPA Syncer <=
- [nongnu] elpa/subed d5751c5 334/389: Change default faces to inherit color values, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 65ed21c 350/389: Add tests/test-subed-vtt.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6eba992 376/389: Add ability to proportionally scale subtitles., ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7d1aa59 385/389: Make timestamp-to-msecs a generic function, ELPA Syncer, 2021/12/03