-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Support hyphens: auto; #34067
Comments
Which operating system are you on? Would it possible to share a minimal reproduction with us? I tried the following which was producing the same screenshot for headless and headed for me: import { test, expect } from '@playwright/test';
test('verify hyphenation in headless mode', async ({ page, headless }) => {
await page.setContent(`
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.hyphenated {
width: 200px;
hyphens: auto;
-webkit-hyphens: auto;
-ms-hyphens: auto;
text-align: justify;
border: 1px solid black;
padding: 10px;
}
</style>
</head>
<body>
<div class="hyphenated">
This is a significantly long word: supercalifragilisticexpialidocious
</div>
</body>
</html>
`);
await page.screenshot({ path: headless ? 'headless.png' : 'headed.png' });
// Get computed style
const hyphensSetting = await page.$eval('.hyphenated', el => window.getComputedStyle(el).hyphens);
// Verify hyphenation is enabled
expect(hyphensSetting).toBe('auto');
// Get the rendered text content and check for soft hyphens
const textContent = await page.$eval('.hyphenated', el => el.innerHTML);
console.log('Headless text content:', textContent);
}); |
I'm in the C# world so a small repro for C#: private static async Task PlayWrightTest(bool headless)
{
IPlaywright playwright = await Playwright.CreateAsync().ConfigureAwait(false);
IBrowser browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions()
{
Headless = headless,
}).ConfigureAwait(false);
IPage page = await browser.NewPageAsync().ConfigureAwait(false);
await page.SetContentAsync("""
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.hyphenated {
width: 200px;
hyphens: auto;
-webkit-hyphens: auto;
-ms-hyphens: auto;
text-align: justify;
border: 1px solid black;
padding: 10px;
}
</style>
</head>
<body>
<div class="hyphenated">
This is a significantly long word: supercalifragilisticexpialidocious
</div>
</body>
</html>
""").ConfigureAwait(false);
byte[] result = await page.PdfAsync().ConfigureAwait(false);
File.WriteAllBytes(headless ? "Headless.pdf" : "Headed.pdf", result);
} In headless PDF is shown a hyphen, in headed not. My environment is:
|
I was able to reproduce. Might be Windows only. Investigation:
Proposal:
We could also just ignore the |
Correct, in versions before v1.49 it wasn't working at all. I found several places where that problem is mentioned, may one can help a little bit: |
🚀 Feature Request
When I'm executing playwright with
the CSS
hyphens: auto;
is working.But when I'm running it not headless, the CSS isn't working. No automatic hyphens are shown.
I've seen that Chromium headless has a folder hyphen-data, but Chromium doesn't have this folder.
Is there any way to get hyphens: auto working with Chromium too?
Example
No response
Motivation
Supporting
hyphens: auto;
will result in same output as in standard browsersThe text was updated successfully, but these errors were encountered: