News for hackers. Stuff that matters.
Re:Show HN: ReLaXed – High-quality PDFs using web technologies by leephillips on Monday April 30, 2018 @12:58PM (#16960246)
The examples lack hyphenation, which partly explains the too-variable interword spacing. Is this because Chrome still fails to support hyphenation, unlike, for example, Firefox?

There are other subtle defects, which make these PDFs pretty good, but not high quality.

Here is a brief discussion of some of the shortcomings of web typography, and why we still need to use TeX if we want the most beautiful and easiest to read results:

https://lwn.net/Articles/662053/

All that aside, this is impressive and should be useful to many people.

Re:Show HN: ReLaXed – High-quality PDFs using web technologies by drb91 on Monday April 30, 2018 @09:46PM (#16964046)
I would say similarly to hyphenation is TeX's ability to place page breaks optimally. I don't believe any web technology can solve this problem at the moment.

Just printing the <p> tag, with its constraints of text layout on all layers (word, line, paragraph, page) already has a lot of details you need to get right to get naturally readable text flow before adding on all the other complexities of html. For instance, if you have a single line creep onto the next page, but you could also just move the entire paragraph to the next page and subtly adjust spacing on the first page, then that is preferable so that each paragraph resides entirely on one page. This is obviously not always possible or desirable, so it turns into a search problem with many variables that can be dynamically altered in the middle of text flowing.

My understanding of modern CSS engines is both that a) CSS itself lacks the natural primitives to even express constraints you'd find in TeX, and also b) the concerns necessary to solve page layout to this degree fall into the type of search problem that browsers tend to try to avoid when rendering.

Of course, there's an argument to be made that if people don't realize it's missing, maybe it wasn't terribly valuable to begin with. I'd imagine for most home uses it's not very useful, but the fact that you can typeset decades old documents at a de-facto professional level, for free, OR with heavily modified engines allowing more modern practices, is really quite amazing. I hope the effort that went into formalizing "readable text" doesn't get lost as people move on from TeX--it'd be great to get some of this capacity in a browser with competing implementations; TeX is a lot to learn for most people, and it's also turing complete, which is IMHO mostly a bad sign for accessibility.

There are also projects which attempt to render HTML to TeX, but they were frankly mostly terrible the last time I looked. I honestly wonder if it's easier these days for javascript to attempt to render the DOM to TeX and just leverage the browser as much as possible, but I'm not familiar enough with the DOM to speculate on how much this is likely to work on unaltered pages. My guess is you only get so much for free before you have to specifically consider that output scenario, just like other types of responsive layout.

Re:Show HN: ReLaXed – High-quality PDFs using web technologies by TylerE on Monday April 30, 2018 @11:39PM (#16964436)
> I would say similarly to hyphenation is TeX's ability to place page breaks optimally. I don't believe any web technology can solve this problem at the moment.

I wonder how hard it would be to just compile TeX to WebASM or something.... TeX is _ridiculously_ fast on a modern PC, hundreds of pages per second. All the libraries/macros might be problem, but I bet you could prepare a useful-but-minimal set that would fit in a MB or two gzipped.

Re:Show HN: ReLaXed – High-quality PDFs using web technologies by taeric on Monday April 30, 2018 @11:52PM (#16964472)
I've always been bemused by the major focus that we need a brand new implementation of the algorithms so that they can take advantage of modern computers. Ignoring just how bloody well it already takes advantage of faster processing power.

(I get that there are some good arguments for a more developer friendly extension language.)

Re:Show HN: ReLaXed – High-quality PDFs using web technologies by stev0lution on Tuesday May 01, 2018 @08:22AM (#16966393)
I think Latexbase does something like this (they claim it works offline too, using service workers). They claim to be using Emscripten/LLVM but it doesn't seem like they use wasm yet (probably because they didn't consider it a viable option back in 2016 https://latexbase.com/p/b0a174a5-09b3-4598-9686-3a73be2dc8e5). And while it's not open source I still think it's a really cool proof of concept..
Re:Show HN: ReLaXed – High-quality PDFs using web technologies by zulko on Monday April 30, 2018 @01:09PM (#16960318)
Hyphenation can be tuned via CSS but I have never been happy with it:

https://www.w3schools.com/cssref/css3_pr_word-break.asp

From what I remember LaTeX has better algorithms, both in how to distribute words between lines, and in knowing where in a word it is ok to cut.

Re:Show HN: ReLaXed – High-quality PDFs using web technologies by agussell on Monday April 30, 2018 @05:05PM (#16962339)
https://github.com/bramstein/typeset This is an implementation of the line breaking algorithm used in TeX in Javascript.
Re:Show HN: ReLaXed – High-quality PDFs using web technologies by taeric on Monday April 30, 2018 @01:22PM (#16960433)
For anyone that wants to have a good read, try reading the TeX-book's section on hyphenation. Tons of fun that goes over some of the difficulties.

As a fun trivia, think where to hyphenate the word record. In all forms.

Re:Show HN: ReLaXed – High-quality PDFs using web technologies by ximeng on Monday April 30, 2018 @11:57PM (#16964493)
Re:Show HN: ReLaXed – High-quality PDFs using web technologies by leephillips on Monday April 30, 2018 @01:24PM (#16960447)
As recently as a year ago, Chrome support of automatic hyphenation only worked on some platforms. If the support is better now, I'm glad to hear it.
Re:Show HN: ReLaXed – High-quality PDFs using web technologies by blaisio on Monday April 30, 2018 @06:46PM (#16963169)
It is not. They have not made progress.
Re:Show HN: ReLaXed – High-quality PDFs using web technologies by gyrgtyn on Monday April 30, 2018 @03:22PM (#16961420)
maybe something like :

https://github.com/ytiurin/hyphen Franklin M. Liang's hyphenation algorithm, implemented in Javascript.

could be integrated.