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

prune XMDuals with mirrored single tokens #1327

Merged
merged 7 commits into from
Aug 23, 2020

Conversation

dginev
Copy link
Collaborator

@dginev dginev commented Aug 20, 2020

Continues the work of #1309 to now also compress duals with single mirrored tokens.
The changes to the test suite are a very good illustration of the exact effect here.

I stumbled on this while working on the a11y PR #1305 , and wanted to detach it into a standalone PR, to make merging the various pieces easier.

<XMTok meaning="gradient"/>
<XMTok name="nabla" role="OPERATOR">∇</XMTok>
</XMDual>
<XMTok font="italic" meaning="gradient" name="nabla" role="OPERATOR">∇</XMTok>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I noticed that font="italic" gets added to the tokens when merged, I was wondering what causes that and how to avoid it - since I am pretty sure we don't want it added for the cases in the tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, figured it out, simply do not overwrite the presentation XMTok's attributes with attributes of the parent XMDual, in the cases where both have the same attribute. With a special exception where xml:id gets overwritten to be the XMDual id, in case it was being referenced from somewhere else.

@dginev
Copy link
Collaborator Author

dginev commented Aug 20, 2020

Should be good for a review.

@dginev dginev requested a review from brucemiller August 20, 2020 14:15
$self->replaceNode($dual, $presentation);
# transfer the attributes after replacing, so that the bookkeeping has been undone
for my $key (keys %transfer_attrs) {
if (($key eq 'xml:id') || !$presentation->getAttribute($key)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Some of the dual's attributes should override the presentation's attributes, certainly role, meaning, probably anything from @CONTENT_TRANSFER_ATTRS.

Also, theoretically if more than 1 of (dual,presentation,content)have ids, all referrers to the extras should get updated to use the one you keep.

Copy link
Collaborator Author

@dginev dginev Aug 20, 2020

Choose a reason for hiding this comment

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

Thanks, hadn't thought that part through to be honest, and the changes to the tests are Good - e.g. \Langle from mathbbol and \Ydown from stmaryrd now once again have the correct roles.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ready for re-review

@dginev
Copy link
Collaborator Author

dginev commented Aug 23, 2020

This PR is now magically updated with the improved refactoring by @brucemiller , as you can see in the commit history 👍

@brucemiller
Copy link
Owner

Got no more excuses...

@brucemiller brucemiller merged commit 529fd12 into brucemiller:master Aug 23, 2020
@brucemiller brucemiller deleted the prune-token-xmduals branch August 23, 2020 15:55
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.

2 participants