Skip to content

Commit

Permalink
Updated "unbreakable-punctuation" to "non-breaking-punctuation"
Browse files Browse the repository at this point in the history
  • Loading branch information
toonvandenbos committed Jul 26, 2024
1 parent 4b57338 commit 44f0405
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Typography Rules for Laravel

Rendering strings provided by users can result in unexpected typographic results. For instance, in most latin languages (such as french) it is recommended to add a non-breakable space in front of, amongst others, exclamation or question marks (`!` and `?`). Most users will probably just type a regular space, which could result in an unwanted line break just before these punctuation marks.
Rendering strings provided by users can result in unexpected typographic results. For instance, in most latin languages (such as french) it is recommended to add a non-breaking space in front of, amongst others, exclamation or question marks (`!` and `?`). Most users will probably just type a regular space, which could result in an unwanted line break just before these punctuation marks.

This simple package provides a `typography` macro for Laravel's `Str` facade and `Stringable` instances (created using `Str::of()` or `str()`) that will take care of these typographic details.

Expand Down Expand Up @@ -46,7 +46,7 @@ Using `Stringable` instances, you can chain `typography` with other helper metho

| Key | Usage | Description |
|:------------------------- |:--------------------------------------------------- |:--------------------------------------------------------------------------------------------- |
| `unbreakable-punctuation` | Remove unwanted line breaks in front of punctuation | Replaces ` !`, ` ?`, ` :`, ` ;` with ` !`, ` ?`, ` :`, ` ;` respectively. |
| `non-breaking-punctuation` | Remove unwanted line breaks in front of punctuation | Replaces ` !`, ` ?`, ` :`, ` ;` with ` !`, ` ?`, ` :`, ` ;` respectively. |
| `hellip` | Use the correct "horizontal ellipsis" HTML entity | Replaces `…`, `…`, `...`, `` with `…`. |

## Registering & removing typographic rules
Expand Down Expand Up @@ -75,14 +75,14 @@ Call a single or a few specific rules:

```blade
<div>{!! str($text)->typography(only: 'hellip') !!}</div>
<div>{!! str($text)->typography(only: ['hellip', 'unbreakable-punctuation']) !!}</div>
<div>{!! str($text)->typography(only: ['hellip', 'non-breaking-punctuation']) !!}</div>
```

Call all rules except a single or a few specific unwanted rules:

```blade
<div>{!! str($text)->typography(except: 'hellip') !!}</div>
<div>{!! str($text)->typography(except: ['hellip', 'unbreakable-punctuation']) !!}</div>
<div>{!! str($text)->typography(except: ['hellip', 'non-breaking-punctuation']) !!}</div>
```

---
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ServiceProvider extends Provider
public function register()
{
Typography::rule(
key: 'unbreakable-punctuation',
key: 'non-breaking-punctuation',
regex: '/(?:(?:&nbsp;)|\s)+([:!?;])/',
callback: fn(array $matches) => '&nbsp;'.$matches[1],
);
Expand Down

0 comments on commit 44f0405

Please sign in to comment.