HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
robertknight
tex-linebreak
TypeScript2020–2026
robertknight / tex-linebreak

tex-linebreak

JavaScript implementation of the Knuth-Plass linebreaking algorithm

5Distinct people
6Mentions
0Explicit recommenders
200GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

JavaScript implementation of the Knuth-Plass linebreaking algorithm

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year6 dated mentions

Observed mentions: 2020-05-23 18:28:36 UTC to 2026-05-08 18:41:09 UTC.

01232020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20232024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC303
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC000
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC202
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC110

What Hacker News says

6 sources
If you enjoyed this you'll probably also enjoy "The Games People Play With Cash Flow" [0] And for the classic HN comment about the site itself: I think it looks very nice, but the native justification algorithm is not very good (especially with hyphenation turned off) so it ends up looking quite sparse at parts on mobile and is a bit jarring to read. I'm a big fan of this implementation [1] of the TeX linebreak algorithm for the web, and think it would make this site look even better with minimal effort. [0] https://commoncog.com/cash-flow-games/ [1] https://github.com/robertknight/tex-linebreak
In Operating Margins
This is excellent, thank you! I hadn't heard of "balance" before either, so definitely going to experiment with that now too. Anything that can improve typography on the web, even a little bit is a big win in my opinion. I'm also stealing that 1lh tip they link to! If you like this and are interested in something closer to TeX, why not the TeX algorithm itself!? There's this lovely package that works wonderfully on the web https://github.com/robertknight/tex-linebreak?tab=readme-ov-... And if you want to play around with a live example to check the performance, I use it on my site's about page: https://lynkmi.com/about Been on a big LaTeX buzz recently and even added support for it in comments there too!
In Better typography with text-wrap pretty
Don’t think I’ve ever seen anyone suggest setting text-justify. It’s one of those properties that I could imagine having been used in anger and with cause (justifiedly :P) less than a hundred times in total, though the true number is probably higher than that. Anyway, in this case it won’t change anything, because the text is English, and the default value of auto will be equivalent to inter-word. (If the text was Japanese, it would actively harm things, because auto would be equivalent to inter-character, and you’d mess that up.) Anyway, in all current browsers, `text-align: justify` does greedy text layout, where it fits as many words in each line as it can before wrapping. This is technically trivial, but visually inferior to Knuth-Plass line breaking, which tries to find the most visually-pleasing place to break lines. Look at the scr
Read the rest
eenshots of https://github.com/robertknight/tex-linebreak to see the difference. It can be rather stark.
In Perfect Edition: A lightweight, responsive web e-book template
If you open most books on the shelf you will notice that text is not left-aligned, but is in fact justified to create a consistent vertical margin on the right-hand side[0]. It's the big thing I always miss when I try reading on the web. One way to do this is with JavaScript implementations of the LaTeX hyphenation/justification algorithm. Check out [1] and [2] for examples. [0]: https://i.imgur.com/65ICUVW.png [1]: https://github.com/robertknight/tex-linebreak [2]: https://github.com/bramstein/typeset
In Perfect Edition: A lightweight, responsive web e-book template
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
In Show HN: LaTeX.css – Make your website look like a LaTeX document

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.