Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/CoreModels/SubtitleMarkup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ extension SubtitleColor {
"white": .init(red: 1, green: 1, blue: 1),
"black": .init(red: 0, green: 0, blue: 0),
"red": .init(red: 1, green: 0, blue: 0),
"lime": .init(red: 0, green: 1, blue: 0),
"green": .init(red: 0, green: 0.5, blue: 0),
"lime": .green,
// Caption "green" means the bright broadcast (CEA-608) green, not HTML's
// dim #008000, which reads as murky over video.
"green": .green,
"blue": .init(red: 0, green: 0, blue: 1),
"yellow": .init(red: 1, green: 1, blue: 0),
"cyan": .init(red: 0, green: 1, blue: 1),
Expand Down
3 changes: 2 additions & 1 deletion Sources/CoreModels/SubtitlePrimitives.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public struct SubtitleColor: Codable, Equatable, Sendable, Hashable {
public static let cyan = SubtitleColor(red: 0.25, green: 0.85, blue: 1)
public static let pink = SubtitleColor(red: 1, green: 0.55, blue: 0.75)
public static let orange = SubtitleColor(red: 1, green: 0.6, blue: 0.15)
public static let green = SubtitleColor(red: 0.45, green: 0.85, blue: 0.45)
/// Broadcast (CEA-608) caption green, shared by the preset and markup colours.
public static let green = SubtitleColor(red: 0, green: 1, blue: 0)
public static let clear = SubtitleColor(red: 0, green: 0, blue: 0, alpha: 0)

/// The curated palette offered by the appearance editor's colour picker.
Expand Down
6 changes: 6 additions & 0 deletions Tests/CoreModelsTests/SubtitleMarkupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ final class SubtitleMarkupTests: XCTestCase {
XCTAssertNil(t.runs?.last?.color)
}

func testWebVTTGreenClassIsBrightCaptionGreen() throws {
let t = try text("WEBVTT\n\n00:00:01.000 --> 00:00:02.000\n<c.green>Caller</c>: hi\n")
XCTAssertEqual(t.runs?.first?.color, SubtitleColor(red: 0, green: 1, blue: 0))
XCTAssertEqual(t.runs?.first?.color, .green, "markup and the Green preset must match")
}

func testEntitiesDecodeInsideRuns() throws {
let t = try text("1\n00:00:01,000 --> 00:00:02,000\n<font color=red>Tom &amp; Jerry</font>\n")
XCTAssertEqual(t.string, "Tom & Jerry")
Expand Down
Loading