emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/subed 47403ce79d: 1.2.15 VTT: Allow attributes after times


From: ELPA Syncer
Subject: [nongnu] elpa/subed 47403ce79d: 1.2.15 VTT: Allow attributes after timestamps
Date: Fri, 6 Sep 2024 22:03:19 -0400 (EDT)

branch: elpa/subed
commit 47403ce79d084d7dec8599553456f35370d8aef2
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>

    1.2.15 VTT: Allow attributes after timestamps
    
    * subed/subed-vtt.el (subed--jump-to-subtitle-id):
    Allow attributes after timestamps.
    * tests/test-subed-vtt.el ("subed-vtt"): Add test.
---
 NEWS.org                | 7 ++++++-
 README.org              | 4 ++++
 subed/subed-vtt.el      | 6 +++---
 subed/subed.el          | 2 +-
 tests/test-subed-vtt.el | 9 ++++++++-
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index caa393868b..4a61028e22 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,6 +1,11 @@
 #+OPTIONS: toc:nil
 
 * subed news
+** 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
@@ -9,7 +14,7 @@
   past the end of the file.
 
   Thanks to rodrigomorales1 and rndusr for the bug reports and pull requests!
-
+  
 ** Version 1.2.13 - 2024-07-05 - Sacha Chua
 
 - Bugfix: Fix the requires in subed-waveform to load subed-common.
diff --git a/README.org b/README.org
index dc0ab1fa8b..5d4c682dd1 100644
--- a/README.org
+++ b/README.org
@@ -361,6 +361,10 @@ of ~subed-mode~. The specific backend functions (ex:
 ~subed-srt--jump-to-subtitle-id~) are also deprecated in favor of
 using generic functions such as ~subed-jump-to-subtitle-id~.
 
+** Testing
+
+You'll need to install the =buttercup= and =package-lint= Emacs packages. 
You'll also need =GNU Make= so that you can work with Makefiles. To run the 
tests, use the command =make test=.
+
 ** Contributions
    Contributions would be really appreciated! subed conforms to the 
[[https://reuse.software/spec/][REUSE
    Specification]]; this means that every file has copyright and license
diff --git a/subed/subed-vtt.el b/subed/subed-vtt.el
index f412b407dc..bfdcdd8cc8 100644
--- a/subed/subed-vtt.el
+++ b/subed/subed-vtt.el
@@ -120,17 +120,17 @@ Use the format-specific function for MAJOR-MODE."
                (goto-char (match-end 0)))
           (goto-char (point-min)))
       (cond
-       ((looking-at (concat "\\(" subed-vtt--regexp-timestamp "\\) *--> *" 
subed-vtt--regexp-timestamp " *\n"))
+       ((looking-at (concat "\\(" subed-vtt--regexp-timestamp "\\) *--> *" 
subed-vtt--regexp-timestamp "\\(?:\s+.+\\)?\n"))
         ;; no ID, use the timestamp
         (point))
-       ((looking-at (concat "\\(.*\\)\n" subed-vtt--regexp-timestamp " *--> *" 
subed-vtt--regexp-timestamp " *\n"))
+       ((looking-at (concat "\\(.*\\)\n" subed-vtt--regexp-timestamp " *--> *" 
subed-vtt--regexp-timestamp "\\(?:\s+.+\\)?\n"))
         (point))
        ((looking-at "^NOTE[ \n]")
         ;; At a subtitle's comment; scan forward for the timestamp
         (if (re-search-forward
              (concat
               subed--regexp-separator
-              (concat "\\(.*\n\\)?\\(" subed-vtt--regexp-timestamp " *--> *" 
subed-vtt--regexp-timestamp "\\) *\n")) nil t)
+              (concat "\\(.*\n\\)?\\(" subed-vtt--regexp-timestamp " *--> *" 
subed-vtt--regexp-timestamp "\\)\\(?:\s+.+\\)?*\n")) nil t)
             (progn
               (goto-char (or (match-beginning 1) (match-beginning 2) (point)))
               (point))
diff --git a/subed/subed.el b/subed/subed.el
index c16522fa8b..367d0ecc94 100644
--- a/subed/subed.el
+++ b/subed/subed.el
@@ -1,6 +1,6 @@
 ;;; subed.el --- A major mode for editing subtitles  -*- lexical-binding: t; 
-*-
 
-;; Version: 1.2.14
+;; Version: 1.2.15
 ;; Maintainer: Sacha Chua <sacha@sachachua.com>
 ;; Author: Random User
 ;; Keywords: convenience, files, hypermedia, multimedia
diff --git a/tests/test-subed-vtt.el b/tests/test-subed-vtt.el
index 100a524731..e958576e35 100644
--- a/tests/test-subed-vtt.el
+++ b/tests/test-subed-vtt.el
@@ -34,7 +34,14 @@ Baz.
          (expect (subed-subtitle-id) :to-equal "00:01:01.000")))
       (it "returns nil if no subtitle ID can be found."
         (with-temp-vtt-buffer
-         (expect (subed-subtitle-id) :to-equal nil))))
+         (expect (subed-subtitle-id) :to-equal nil)))
+      (it "handles extra attributes"
+          (with-temp-vtt-buffer
+           (insert "WEBVTT
+
+00:00:01.000 --> 00:00:02.000 align:start position:0%
+Hello world")
+           (expect (subed-subtitle-id) :to-equal "00:00:01.000"))))
     (describe "the subtitle ID at playback time"
       (it "returns subtitle ID if time is equal to start time."
         (with-temp-vtt-buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]