branch: elpa/subed commit 37a671b81601548264cb68a8747d1ded2a1f5440 Author: Sacha Chua <sa...@sachachua.com> Commit: Sacha Chua <sa...@sachachua.com>
VTT: Require newlines before NOTE so that it can be within cue text * subed/subed-vtt.el (subed-vtt--regexp-separator): Require newlines before NOTE. * tests/test-subed-vtt.el ("subed-vtt"): Add test for Note inside cue text. --- subed/subed-vtt.el | 2 +- tests/test-subed-vtt.el | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/subed/subed-vtt.el b/subed/subed-vtt.el index 61023cc7e3..35b0415a13 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\\)+\\(?:NOTE[ \n]\\(?:.+?\n\\)+\n\\)*\n") +(defconst subed-vtt--regexp-separator "\\(?:[[:blank:]]*\n\n+NOTE[ \n]\\(?:.+?\n\\)+\\)*\n\n+") (defconst subed-vtt--regexp-identifier ;; According to https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API ;; Cues can start with an identifier which is a non empty line that does diff --git a/tests/test-subed-vtt.el b/tests/test-subed-vtt.el index 8684707dd7..f355e0632a 100644 --- a/tests/test-subed-vtt.el +++ b/tests/test-subed-vtt.el @@ -1711,7 +1711,19 @@ This is another test here. (insert mock-vtt-comments-data) (subed-append-subtitle) (expect (subed-backward-subtitle-comment) :not :to-be nil) - (expect (looking-at "NOTE ") :to-be t))))) + (expect (looking-at "NOTE ") :to-be t)))) + (describe "when the cue text starts with Note" + (it "is not confused." + (with-temp-vtt-buffer + (insert "WEBVTT + +00:00:00.000 --> 00:00:00.999 +Note this is a test + +00:00:01.000 --> 00:00:01.000 +another test +") + (expect (elt (car (subed-subtitle-list)) 3) :to-equal "Note this is a test"))))) (describe "Merging with next subtitle" (it "throws an error in an empty buffer." (with-temp-vtt-buffer