Problem/Motivation

In some languages including german it is very common to combine words so they can become pretty long. Since not all browsers have the ability to use automatic hyphenation, especially on Windows (see https://caniuse.com/?search=hyphen) and simple text fields don't allow the usage of the HTML entity ­ a common workaround is using the unicode character for a soft hyphen (see https://en.wikipedia.org/wiki/Soft_hyphen) as a workaround.

Because pathauto treats it like a special character but doesn't make it configurable what to do with it, the soft hyphens become "real", visible hyphens (or replaced by another seperator if another is configured) in the path generation which is unintended and breaks the readability of the path.

Example

Donau­dampf­schiff­fahrts­gesell­schaft

The above word contains some unicode soft hyphens which will only become visible when the word needs to be broken apart to fit it's container

When using pathauto with this string it becomes:

donau-dampf-schiff-fahrts-gesell-schaft

Steps to reproduce

Use a soft hyphen for example in the title of a node and generate a path alias with it. It will fill in the soft hyphens with visible hyphens.

Proposed resolution

Add the option to configure how soft hyphens should be handled just like with other punctuation symbols.

Remaining tasks

Review the patch I made, for me it is working, seems like a no-brainer.

User interface changes

New option to configure how soft hyphens are handled will appear on the settings page of pathauto.

API changes

None

Data model changes

None except that the exported pathauto config will include a new "soft_hyphen" setting.

Issue fork pathauto-3181986

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fisherman90 created an issue. See original summary.

fisherman90’s picture

StatusFileSize
new877 bytes

Here is a simple patch I made.

fisherman90’s picture

StatusFileSize
new1.44 KB

Added a new version of the patch because I forgot the tests.

fisherman90’s picture

Issue summary: View changes

Updated issue description to make clear that the soft hyphens get replaced by the separator which is a normal hyphen by default.

alessons’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new5.52 KB

Hi there!, I've tested the patch and seems to work as expected.

Soft hyphens test.

mably made their first commit to this issue’s fork.

  • mably committed 51d487c6 on 8.x-1.x
    feat: #3181986 Add support for unicode soft hyphens on punctuation logic...
mably’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.