Skip to content
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

Unintended non-breaking-space inserted at last line if it has a number at the end #17

Open
animaux opened this issue Feb 29, 2024 · 7 comments

Comments

@animaux
Copy link

animaux commented Feb 29, 2024

Kirby 4.1.0
hananils/typographer 0.2.0

Using $termin->text()->typographer('block') in a template I get the following results:

**Aula der Parkschule**
Rathenauplatz 4

—>

<p>dgadfgadfg<br>&nbsp;adfgadfgad&nbsp;2</p>

It seems the number at the end is triggering the non-breaking-space at the beginning of the line. When doing multiple paragraphs, it only affects the last one:

**Aula der Parkschule**
Rathenauplatz 4

**Aula der Parkschule**
Rathenauplatz 4

—>

<p><strong>Aula der Parkschule</strong><br>Rathenauplatz 4</p>
<p><strong>Aula der Parkschule</strong><br>&nbsp;Rathenauplatz&nbsp;4</p>
@nilshoerrmann
Copy link
Member

That's an issue with the widont correction which I think is fixed in the upcoming version.
Is there, by any chance, whitespace after the inline break (not necessarily spaces but tabs or line returns)?

@nilshoerrmann
Copy link
Member

In the resulting markup that is, not in the Markdown source.

@animaux
Copy link
Author

animaux commented Feb 29, 2024

Doesn˚t look like there is. Here’s the exact result with indents and the surrounding markup:

                <div>
                    <h4>
                        <span>Jahreshauptversammlung</span>
                    </h4>
                    <p>
                        <strong>Aula der Parkschule</strong>
                        <br>
                         Rathenauplatz 4
                    </p>
                </div>

@nilshoerrmann
Copy link
Member

Well, there is:

grafik

So, yes, this should be fixed in the next version.

@nilshoerrmann
Copy link
Member

As a workaround, you could set custom defaults in your config file and exclude the widont rule there, see https://github.com/hananils/kirby-typographer?tab=readme-ov-file#options.

The options is named hananils.typographer.corrections and accepts an array like this one:

private $corrections = [
'dashes' => '\Hananils\Corrections\Dashes',
'math' => '\Hananils\Corrections\Math',
'quotes' => '\Hananils\Corrections\Quotes',
'apostrophes' => '\Hananils\Corrections\Apostrophes',
'primes' => '\Hananils\Corrections\Primes',
'punctation' => '\Hananils\Corrections\Punctation',
'ellipsis' => '\Hananils\Corrections\Ellipsis',
'trademarks' => '\Hananils\Corrections\Trademarks',
'widont' => '\Hananils\Corrections\Widont',
'abbreviations' => '\Hananils\Corrections\Abbreviations',
'longWords' => '\Hananils\Corrections\LongWords',
'caps' => '\Hananils\Corrections\Caps',
'lists' => '\Hananils\Corrections\Lists'
];

@animaux
Copy link
Author

animaux commented Feb 29, 2024

Thanks Nils!

I was expecting kirby-htmldoc to get rid of all the whitespace, after all. Will have to look into that.

@nilshoerrmann
Copy link
Member

nilshoerrmann commented Feb 29, 2024

The next version of Typographer will collapse and trim whitespace where appropriate when applying the widont rule so this should not longer be an issue 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants