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

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

[nongnu] elpa/subed 4b80d73145 1/3: Make hours optional when validating


From: ELPA Syncer
Subject: [nongnu] elpa/subed 4b80d73145 1/3: Make hours optional when validating VTT
Date: Fri, 22 Jul 2022 10:59:13 -0400 (EDT)

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

    Make hours optional when validating VTT
    
    * Makefile: Test before compiling.
    (clean): Always clean autoloads file.
    * subed/subed-vtt.el (subed--validate-format): Accept mm:ss.000
    timestamp, since hours are optional.
    * tests/test-subed-vtt.el ("VTT"): Add test for optional hours.
---
 Makefile                | 5 +++--
 subed/subed-vtt.el      | 4 ++--
 tests/test-subed-vtt.el | 5 +++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index f122f28807..ef7604ae51 100644
--- a/Makefile
+++ b/Makefile
@@ -2,11 +2,12 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
-all: clean autoloads compile
+# Putting compile before test results in an invalid-function error about 
subed-for-each-subtitle
+all: clean autoloads test compile
 
 clean:
        find . -name "*.elc" -delete
-       rm subed/subed-autoloads.el
+       rm -f subed/subed-autoloads.el
        rm -f coverage/.*.json
 
 test: autoloads test-coverage package-lint checkdoc
diff --git a/subed/subed-vtt.el b/subed/subed-vtt.el
index 8554d743ff..05bdc5dd7e 100644
--- a/subed/subed-vtt.el
+++ b/subed/subed-vtt.el
@@ -340,7 +340,7 @@ Use the format-specific function for MAJOR-MODE."
         (while (and (re-search-forward (format "^\\(%s\\)" 
subed--regexp-timestamp) nil t)
                     (goto-char (match-beginning 1)))
           ;; This regex is stricter than `subed--regexp-timestamp'
-          (unless (looking-at 
"^[0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\(\\.[0-9]\\{0,3\\}\\)")
+          (unless (looking-at 
"^\\([0-9]\\{2\\}:\\)?[0-9]\\{2\\}:[0-9]\\{2\\}\\(\\.[0-9]\\{0,3\\}\\)")
             (error "Found invalid start time: %S"  (substring (or 
(thing-at-point 'line :no-properties) "\n") 0 -1)))
           (when (re-search-forward "[[:blank:]]" (point-at-eol) t)
             (goto-char (match-beginning 0)))
@@ -350,7 +350,7 @@ Use the format-specific function for MAJOR-MODE."
           (condition-case nil
               (forward-char 5)
             (error nil))
-          (unless (looking-at 
"[0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\(\\.[0-9]\\{0,3\\}\\)$")
+          (unless (looking-at 
"\\([0-9]\\{2\\}:\\)?[0-9]\\{2\\}:[0-9]\\{2\\}\\(\\.[0-9]\\{0,3\\}\\)$")
             (error "Found invalid stop time: %S" (substring (or 
(thing-at-point 'line :no-properties) "\n") 0 -1))))
         (goto-char orig-point)))))
 
diff --git a/tests/test-subed-vtt.el b/tests/test-subed-vtt.el
index 038d519cfd..ea77a4051b 100644
--- a/tests/test-subed-vtt.el
+++ b/tests/test-subed-vtt.el
@@ -1026,6 +1026,11 @@ Baz.
        (forward-char -2)
        (subed-validate)
        (expect (point) :to-equal 106)))
+    (it "accepts mm:ss timestamps."
+      (with-temp-vtt-buffer
+       (insert "WebVTT\n\n00:00.003 --> 00:05.123\nThis is a test")
+       (subed-validate)
+       (expect (point) :to-equal (point-max))))
     (it "preserves point if there is no error."
       (with-temp-vtt-buffer
        (insert mock-vtt-data)



reply via email to

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