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

Unnecessary whitespace inside block-level elements is not removed, but turned to spaces instead #3

Closed
sorccu opened this issue Apr 17, 2009 · 3 comments
Labels

Comments

@sorccu
Copy link
Owner

sorccu commented Apr 17, 2009

Consider the following HTML:

```


Lorem ipsum

```

They way things are right now, cufón will attempt to render the text " Lorem ipsum ", not “Lorem ipsum” as you might expect. The issue may seem simple, but what about:

```



Lorem

ipsum

dolor

sit
amet

```

Which of the newlines should be removed? Depending on the styling of the elements the answer can be either some, all or none of them. For instance the strong element may have display: block, or the h1 may have display: inline. At the moment all elements are treated as display: inline, which often leads to incorrect results with block-level elements.

Solution: make text replacement context-aware.

@kelvinj
Copy link

kelvinj commented Apr 23, 2009

To begin with, I'd recommend trimming any whitespace from the start and end of a block element, this would fix the immediate issues I've had with this.

@sorccu
Copy link
Owner Author

sorccu commented Apr 23, 2009

Yes, we might have to do that to keep things simple.

Some additional material:

http://www.w3.org/TR/html4/appendix/notes.html#notes-line-breaks
http://www.w3.org/TR/CSS21/text.html#white-space-model

Sadly I wasn't able to find an online version of the old SGML spec, but it might not have helped anyway.

@sorccu
Copy link
Owner Author

sorccu commented May 5, 2009

Well, I've implemented a fairly simple fix in commit 9810b4c that should solve the most common issues. Like kelvinj suggested, white space at the beginning and end of a block level element (basically any display value except inline, inline-block and run-in) is removed.

Improving white space handling any further would be pretty much pointless.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants