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

Improve support of sub/superscript #755

Merged
merged 3 commits into from
Aug 8, 2014
Merged

Conversation

peitschie
Copy link
Contributor

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2047/

textDecorationStyle += ' double';
break;
case 'single':
textDecorationStyle += ' double';
Copy link
Member

Choose a reason for hiding this comment

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

Should be single.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eek. Fixed.

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2050/

@adityab
Copy link
Member

adityab commented Aug 5, 2014

This works fine, and after one pass through the patch, the code also looks good.

But I'd suggest splitting up the strikethrough and the font size commits into two separate PRs... with getComputedStyle tests for the double strikethroughs.

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2053/

@peitschie
Copy link
Contributor Author

I've pulled the strikethrough stuff out and will push it up, but (as was hinted by the lack of tests for that specific feature) no tests are possible for that part. getComputedStyle only returns style information it understands, which differs from browser to browser. I can write a layouttest that passes in FF, or one that passes in Chrome (not that I can check anything in Chrome), but not one that passes in both.

@peitschie peitschie changed the title Improve support of text strikethrough and sub/superscript Improve support of sub/superscript Aug 6, 2014
@kossebau
Copy link
Contributor

kossebau commented Aug 7, 2014

Without a layout test possible, would it make sense to add this to visual-tests.odt, with some png as reference? Something like "Striked! Should be IMAGE_OF_Striked_being_striked"
Could also be a separate document.

@peitschie
Copy link
Contributor Author

@kossebau except, it can't be visually detected in browsers other than FF either :(. Note, I didn't make strikethrough work, that already did. All I did was make double-strikethrough work on FF only (and things supporting the new CSS3 text-decoration-style attribute... which is no browser yet).

I split that out a into new PR either way, so #758 is the correct place for further discussion on that :-).

@kossebau
Copy link
Contributor

kossebau commented Aug 7, 2014

(strike was only taken as example because I knew a markdown notation to have it rendered)
But having now also read the full text including 758 I understand the problem.

* @return {!{verticalTextPosition: !string, fontHeight: (!string|undefined)}}
*/
function parseTextPosition(position) {
var parts = position.split(/\s/g);
Copy link
Contributor

Choose a reason for hiding this comment

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

I could not find a definition of what "white space separated" exactly means in "The style:text-position attribute has one or two white space separated values.". So for now I assume in my superficial knowledge it could mean that first better collapsing is to be done on the whitespaces in the list, if it is to be a list value as specified by XML (cmp 2.5.1.2 List datatypes, where the constraining facets contains "whiteSpace" with a fixed value of "collapse". http://www.w3.org/TR/xmlschema-2/#atomic-vs-list).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I've extracted this out into odf.StyleParseUtils and even provided unit tests!

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2072/

}
// Calling split on an empty string returns a [""]. Avoid this by only attempting to split if the
// string is non-zero-length
return text && text.length > 0 ? text.split(/\s/) : [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious: I guess you did replace(/\s+/g, " ") above for a reason instead of text.split(/\s+/), right? What is the catch with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Contrary to my initial expectations, text.split(/\s+/) creates a bunch of empty strings in the array as well, rather than consuming multiple spaces as one separator :-/

Copy link
Contributor

Choose a reason for hiding this comment

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

So could you please add a note about that (and mention where it fails), to prevent somebody "improving" this? E.g. on my Firefox and Chromium it works as expected:

"   a   b  ".replace(/^\s*(.*?)\s*$/g, "$1").split(/\s+/)
["a", "b"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do... it isn't completely vital though. If someone "improves" this and it breaks, the unit tests will fail, hence informing said developer that their improvement was a failure. I don't trust to comments what I can enforce with failing tests...

Copy link
Contributor

Choose a reason for hiding this comment

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

(well, unit tests do not fail for me on this "improvement") 🏄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have confirmed here, so I will choose to avoid the extra doco overhead that would simply record I was partially blind at the time of concocting this reason, and instead update the code ^_^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2077/

@@ -2,6 +2,8 @@

## WebODF

* Add support for subscript & superscript ([#755](https://github.com/kogmbh/WebODF/pull/755))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also add Section title ### Improvements

@kossebau
Copy link
Contributor

kossebau commented Aug 8, 2014

Otherwise fine for shipment! :)

style:text-position defines sub and super-script text properties.
ODT files are generally created in this directory as a result of running
the layout tests from the source directory.
@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2079/

peitschie added a commit that referenced this pull request Aug 8, 2014
Improve support of sub/superscript
@peitschie peitschie merged commit 8154b6f into webodf:master Aug 8, 2014
@peitschie peitschie deleted the style-tweaks branch August 8, 2014 12:44
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.

4 participants