Skip to content

https:// should not be broke into three lines #9056

Open

Description

@YDX-2147483647

Description

UAX #14: Unicode Line Breaking Algorithm does not handle URLs well, so Typst adds a special linebreak_link() function.

Recently, #8039 improved the condition for calling linebreak_link().
However, it (accidentally?) changed the line break opportunities among :// in https://example.com:

  • In Typst v0.15.1, https:// always stays on the same line.
  • On main, http:// can be split into three lines: http:, /, /.

I suggest we revert to the old behavor.

More tests

Test code
#for link in (
  "https://example.com/foo_bar",
  "git+https://git.repo/some_pkg.git@feature",
  "http://0.0.0.0:8000/foo_bar",
  "http://1up.example/foo_bar",
) {
  block(width: 0pt, link)
  line(length: 100%, stroke: gray)
}
Image Image
Expected result
https://
example.
com/
foo_
bar

git+
https://
git.
repo/
some_
pkg.
git@
feature

http://
0.
0.
0.
0:
8000/
foo_
bar

http://
1
up.
example/
foo_
bar

Cause

Before #8039, the input of linebreak_link did not include the scheme or ://. For example, linebreak_link("example.com/foo_bar", ..).
After #8039, the input became the full URL. For example, linebreak_link("https://example.com/foo_bar", ..).

linebreak_link was not designed to handle the scheme or ://, so it produced bad results.

Additional info

#9002 is related.

The initial motive of #8039 was to add a line break opportunity after ://, even when the domain starts with a number (e.g., IP host).
The current ICU4X line segmenter used by Typst is targeting Unicode 15.1. In this version of UAX #14, https:// followed by a letter (e.g., https://a) produces an opportunity, but https:// followed by a number (e.g., https://0) does not, because the latter matches SY × NU (do not break between / and numbers) in the rule LB25.

However, LB25 was modified in Unicode 16. The latest LB25 no longer contains SY × NU1, so ICU4X neo line segmenter (targeting Unicode 18) treats https://a and https://0 as equal.

Nevertheless, that does not mean that this issue can be fixed by reverting #8039 and switching to the neo line segmenter.
#8093 added a test case for a+cool.scheme://a.com/ and expected the line to be broke after cool., which I concur.
By Unicode 18, UAX #14 still can't handle this case well: it does not produce any line break opportunity among a+cool.scheme://.
As a result, passing full URLs to linebreak_link() is necessary.

Therefore, I suggest we add / as a dedicated Class::Slash, and forbid line breaks before all slashes.

impl Class {
fn of(c: char) -> Self {
if c.is_alphabetic() {
Class::Alphabetic
} else if c.is_numeric() {
Class::Digit
} else if matches!(c, '(' | '[') {
Class::Open
} else {
Class::Other
}

for (end, c) in link.char_indices() {
let class = Class::of(c);
// Emit opportunities when going from
// - other -> other
// - alphabetic -> numeric
// - numeric -> alphabetic
// Never before/after opening delimiters.
if end > 0
&& prev != Class::Open
&& if class == Class::Other { prev == Class::Other } else { class != prev }
{

Operating system

Linux, Web app, Windows

Typst version

  • I am using the latest version of Typst

Note that this issue does not exist in Typst v0.15.1. It exists on main.

Footnotes

  1. LB25 still contains NU ( SY | IS )* × NU. That is irrelevant to this issue, though. ↩

Activity

  1. added
    bug
    on Nov 10, 2026
  2. added
    text
    on Nov 13, 2026
  3. added
    urgent
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtexturgent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions