Skip to content

fix: incorrect line length detection if markup contained html entities, unexpected spaces#10

Merged
ncpa0cpl merged 1 commit into
masterfrom
fix/html-entities-len-detection
Apr 27, 2026
Merged

fix: incorrect line length detection if markup contained html entities, unexpected spaces#10
ncpa0cpl merged 1 commit into
masterfrom
fix/html-entities-len-detection

Conversation

@ncpa0cpl

Copy link
Copy Markdown
Collaborator

if the formatted text contained html entities like &lt; and &gt; they would be counted as 4 characters even though those are later replaced with < and > characters respectively.

this fixes that by performing replacement earlier, before length detection happens.

Input:

<frame width="12"> &lt;!&gt; </frame>

Old output:

┌──────────┐
│<!> │
└──────────┘

New Output:

┌──────────┐
│<!>       │
└──────────┘

in some cases when an empty inline tag was followed by a whitespace followed by a non empty inline tag starting with whitespace, that line after formatting would start with a single whitespace.

Input:

<span>
  <line>First Line</line>
  <span><span>
  <span>
    <line>Second Line</line>
  </span>
</span>

Old Output:

First Line
 Second Line

New Output:

First Line
Second Line

…s, unexpected spaces

if the formatted text contained html entities like `&lt;` and `&gt;` they would be counted
as 4 characters even though those are later replaced with `<` and `>` characters respectively.

this fixes that by performing replacement earlier, before length detection happens.

Input:
```html
<frame width="12"> &lt;!&gt; </frame>
```

Old output:
```
┌──────────┐
│<!> │
└──────────┘
```

New Output:
```
┌──────────┐
│<!>       │
└──────────┘
```

in some cases when an empty inline tag was followed by a whitespace followed by a non empty inline tag
starting with whitespace, that line after formatting would start with a single whitespace.

Input:
```html
<span>
  <line>First Line</line>
  <span><span>
  <span>
    <line>Second Line</line>
  </span>
</span>
```

Old Output:
```
First Line
 Second Line
```

New Output:
```
First Line
Second Line
```
@ncpa0cpl ncpa0cpl merged commit 04760c6 into master Apr 27, 2026
1 check passed
@ncpa0cpl ncpa0cpl deleted the fix/html-entities-len-detection branch April 27, 2026 16:08
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

Successfully merging this pull request may close these issues.

1 participant