News for hackers. Stuff that matters.
Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by e12e on Saturday May 23, 2020 @12:54PM (#23284470)
Sadly, css/html hyphenation is still pretty awful. And AFAIK on mobile kerning is pretty far off too. So to me it feels more like a latex parody than homage, unfortunately.

Additionally, it took a long time for Chrome to even implement:

https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens

https://www.chromestatus.com/feature/5642121184804864

Sadly, even with auto, there's way too much ragged right in html, or too irregular word spacing. Even with tricks like inserting soft hyphens.

A list apart long held up the pretty much gold standard, but it's still not as good as plain latex (not sure about plain tex, as I've never had occasion to use it).

See also:

https://alistapart.com/article/the-look-that-says-book/

Unfortunately it appears the current ala styling is worse than it used to be (probably due to a move to use modern css, which is understandable - but only highlights the problem).

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by mpetroff on Saturday May 23, 2020 @02:28PM (#23285200)
The problem is that CSS uses greedy line breaks. In theory, this should improve once browsers implement CSS Text Module Level 4, specifically the `pretty` value for the `text-wrap` property [1][2]. Until then, we're stuck with poor-quality typesetting, or JavaScript solutions [3].

[1] https://www.w3.org/TR/css-text-4/#text-wrap [2] https://github.com/w3c/csswg-drafts/issues/672 [3] https://github.com/robertknight/tex-linebreak

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by chrismorgan on Sunday May 24, 2020 @12:41AM (#23289149)
It’s not that CSS does that, but that browsers (all of them) do that. CSS has no opinion on the matter until text-wrap, where `text-wrap: stable` would dictate the current behaviour.

As an example showing that browsers have long been open to doing things better, this bug was opened against Firefox nine years ago, to implement Knuth-Plass: https://bugzilla.mozilla.org/show_bug.cgi?id=630181 (it hasn’t gone anywhere, of course, because it’s hard; but it shows willingness).

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by mpetroff on Monday May 25, 2020 @12:18PM (#23302483)
This had me wondering about whether it was possible to use pre-calculated line breaks to implement improved text justification in current browsers. I was able to come up with a demo [1][2] that does so, although it falls back to default line breaks in Safari due to lack of support for `text-align-last`.

[1] https://mpetroff.net/files/pre-calculated-line-breaks-demo/ [2] https://mpetroff.net/2020/05/pre-calculated-line-breaks-for-...

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by e12e on Monday May 25, 2020 @06:34PM (#23305631)
Ho-hum :) I'm slightly torn between admiration and horror:

> The key is to wrap all the potential line breaks (inserted via ::after pseudo-elements) and hyphens in <span> elements that are hidden by default with display: none;. Media queries are then used to selectively show the line breaks specific to a given column width.

Doesn't look like you compared with simply inserting soft hyphens - last I looked, that made columns bearable in browsers, although still not as good as proper line breaking.

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by mpetroff on Monday May 25, 2020 @08:57PM (#23306424)
I have `hyphens: auto` set for the browser default comparison in the demo, which is roughly equivalent to inserting soft hyphens for Firefox (where I was doing most of the development), as well as for Chrome on Android and macOS.

While browser hyphenation (either auto or soft hyphens) is definitely an improvement over no hyphens for narrower column widths, I think it generally makes things worse for wider columns, since it frequently adds unnecessary hyphens.

Edit: I updated the demo to use soft hyphens for the browser default comparison so the text is hyphenated in all browsers.

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by e12e on Tuesday May 26, 2020 @08:20AM (#23310195)
OK, I suspect Firefox hyphens auto may have improved since I last checked - at that time whatever I used (aspell?) seemed better at finding potential word breaks than whatever Firefox did (and getting Firefox to do sane word splitting on non-English was a bit of a quest).

Anyway, thank you for this - it's sad that we don't have anything really usable in the browsers still - but also nice to be able to work around the issue somewhat.

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by divbzero on Saturday May 23, 2020 @04:06PM (#23285914)
Given the emphasis on typesetting I’m surprised LaTeX.css opted for rendering speed [1] over kerning [2]

  text-rendering: optimizeSpeed;

  text-rendering: optimizeLegibility;
[1]: https://github.com/vincentdoerig/latex-css/blob/3d5c1e9/styl...

[2]: https://practicaltypography.com/kerning.html

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by doerig on Saturday May 23, 2020 @04:20PM (#23286041)
Thank you for this comment. I honestly didn't give it much thought at all when I copied it from the CSS reset [1] I used. I'll change it to `optimizeLegibility` asap.

[1]: https://github.com/hankchizljaw/modern-css-reset/blob/master...

Re:Show HN: LaTeX.css – Make your website look like a LaTeX ... by divbzero on Saturday May 23, 2020 @04:49PM (#23286297)
Awesome. I like the project and the classless approach. Will PR if I stumble across anything else.