Live data from Hacker News

Knuth and Plass line breaking algorithm in JavaScript

bramstein.com

41–44 of 44 posts

Re: Knuth and Plass line breaking algorithm in JavaScript

#42

Earlier quoted context omitted.

But it would only apply when the web page author "opted in" with the appropriate CSS, no? Doesn't seem like it should affect performance on pages that don't use the feature.

If you made it an opt-in, that might be doable... though there would still be the danger of pages cargo-culting into the opt-in. But at that point you're also asking browsers to maintain two separate line-wrapping codepaths, of which one is not used anywhere to a first approximation. Browser vendors seem to be somewhat resistant to doing that sort of thing.

It could maybe be switched off (even if requested) once a paragraph hits a certain threshold size. Of course I suppose that could get complicated as the paragraph gets mutated by JavaScript... you don't want to be turning it on and off all the time.

Re: Knuth and Plass line breaking algorithm in JavaScript

#43
I recall the first interesting example usage my professor taught of dynamic programming was this example (well, described, not taught). He basically just said that all you do is take the L^2 or L^3 sum of extra space and minimize it using a DP. The fact that that yields great-looking text I thought was pretty cool.

Re: Knuth and Plass line breaking algorithm in JavaScript

#44
post #11

The web is now twenty and browsers are still incapable of something as basic and commonplace as hyphenation and justification. It’s a real shame that this problem has to be solved with JavaScript in 2010. How old is TeX again?

It's not only browsers. Look at Word, for god's sake.

[deleted]
Post reply on HN