Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ebuttd/Unnesting divs, spans #38

Merged

Conversation

PhoebeWheelerCode
Copy link

Code for unnesting various nested elements, correctly inheriting/combining different aspects of them (languages, regions, font sizes, etc)
The divs are recursively iterated through until something other than a div (such as a 'p') is found. A new div is created to contain the non-div, using the merged attributes of the parent divs, and these new divs are added to a list. These then replace the old divs.
The new unnested spans are created using a similar function, (iterating until they find something other than a span) with different code for combining their attributes. It also has functions for calculating the font size and correctly inheriting attributes/combining styles.
There are measures in place to prevent the code from creating styles that are functionally identical to an existing one (except in name) to prevent duplicates and keep the overall number of styles down.
It also does not create a new style when it would have the name of an existing style. This may pose an issue if two different style combinations end up producing the same name, eg:

newStyle + exampleStyle = newStyleexampleStyle
newStyleex + ampleStyle = newStyleexampleStyle

These combined styles later have their font sizes removed and made into their own styles, meaning that duplicate styles (identical in content but not in name) are possible in the end result.

@nigelmegitt nigelmegitt changed the base branch from master to tt3-to-ttd-conversion October 1, 2019 11:00
mm326 and others added 21 commits October 1, 2019 15:42
…identical styles)

Adapting existing tests to work with functions that have been modified
Modifying functions used for unnesting spans, correcting the order of inheritance for styles
Modifying the functions that calculated text size to work with more than two styles
check-equal method added to the style_type class
Updated expected xml used in tests to more accurately reflect expected output
Added more tests for nesting styles
@PhoebeWheelerCode PhoebeWheelerCode force-pushed the ebuttd/MSPA-458-nested-elements branch from fd60e31 to 09f2591 Compare October 2, 2019 08:33
Handles a bug where a p with no explicit start time will take the earliest computed begin time of a span it contains, causing spans to calculate their begin/end times incorrectly
Copy link
Collaborator

@nigelmegitt nigelmegitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pushing review comments now even though there's another issue that isn't directly commented on: some of the timing tests fail. I'm mid-way through trying to trace through because they are complex edge cases and probably not the fault of any code here. I'll push some fixes to that separately.

ebu_tt_live/bindings/validation/presentation.py Outdated Show resolved Hide resolved
ebu_tt_live/node/denester.py Outdated Show resolved Hide resolved
ebu_tt_live/documents/converters.py Outdated Show resolved Hide resolved
ebu_tt_live/documents/converters.py Show resolved Hide resolved
ebu_tt_live/node/denester.py Outdated Show resolved Hide resolved
testing/bdd/test_ebuttd_nested_elements.py Outdated Show resolved Hide resolved
testing/bdd/test_ebuttd_nested_elements.py Outdated Show resolved Hide resolved
testing/bdd/test_ebuttd_nested_elements.py Outdated Show resolved Hide resolved
testing/bdd/test_ebuttd_nested_elements.py Show resolved Hide resolved
testing/bdd/test_ebuttd_nested_elements.py Outdated Show resolved Hide resolved
… of milliseconds regardless of number of digits

Previously, `00:00:00.17` was converted to a timedelta with _17_ milliseconds instead of 170, and resulted in a different value from `00:00:00.170`, but the spec says stuff after the decimal point is a decimal fraction not a number of milliseconds.

This commit truncates any digits in the fraction beyond the third, without rounding.
Catch regressions to any timedelta conversions from timing types
@nigelmegitt
Copy link
Collaborator

I've reviewed the changes up to now, all looking good, thanks @PhoebeWheelerCode - I understand you're looking at the last review comment too so will review that change when you've done it.

Modifying tests to work with the DenesterNode
Removing some facet-based code in tests that was missed when facets were removed
Copy link
Collaborator

@nigelmegitt nigelmegitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff making this a node, on the right track, a few (increasingly minor) comments/questions.

ebu_tt_live/documents/converters.py Outdated Show resolved Hide resolved
ebu_tt_live/node/denester.py Outdated Show resolved Hide resolved
docs/source/inode.puml Show resolved Hide resolved
…unt for this

Removed creation of DenesterNode inside converters.py
Modified tests to account for changes in Denester indentation
@PhoebeWheelerCode
Copy link
Author

Still have rst file to do but have pushed fixes for other recent minor comments

Added an rst file for the Denester node
Copy link
Collaborator

@nigelmegitt nigelmegitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improved documentation. Possibly extra code is needed: the output of the Denester must have a different sequence identifier to its input, to be spec conformant. It's not in the documentation so I'm not sure if it's in the code either...

docs/source/configurator.rst Outdated Show resolved Hide resolved
docs/source/denesting.rst Outdated Show resolved Hide resolved
docs/source/denesting.rst Outdated Show resolved Hide resolved
ebu_tt_live/node/denester.py Outdated Show resolved Hide resolved
This could do with a standard config file and an `ebu-run` command line to run it to demonstrate it in action.
Copy link
Collaborator

@nigelmegitt nigelmegitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible (even likely) that with a change this complex some bugs are present, but it's good enough that we should merge it now and raise any issues we find later to solve them another time. It's really complex, so overall great work - I am not trying to do it down! Thanks @PhoebeWheelerCode and @mm326 for your hard work on this (and sorry if I've missed anyone out!)

@PhoebeWheelerCode PhoebeWheelerCode merged commit 1312433 into tt3-to-ttd-conversion Nov 8, 2019
@PhoebeWheelerCode PhoebeWheelerCode deleted the ebuttd/MSPA-458-nested-elements branch November 8, 2019 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants