Improve conversion by incorporating color and alignment #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes are tailored towards subtitle files coming from the German televisions (ARD, NDR, ZDF, ZDF Neo, ORF, …) being converted into the ASS format. I do hope they're not breaking any other test cases, but I have no way to verify that.
The first commit is a fix finding the position styles. They are behind a namespace in my test files which are now correctly found. Notice the
style
,styling
,region
andlayout
tags being prefixed with the namespacett
in the following very common header.Example header
The next two commits are reading the color values for both foreground and background and assigning the values to inline modifiers.
Details
The last commit makes use of the rarely used
textAlign
tag. Those allow shifting text to either side away from the center while still being at the same height. To make calculations easier, I changed the current format of the position (top
|bottom
) into the ASS format (8
|2
). This allows to subtract or add1
and have the correct positioning on screen regarding the ASS numpad layout (1..9).Details
In this example, the
tt:p
is manually edited to feature thestyle="textLeft"
tag. The header is the same as in the first example above.