Skip to content

fix: prevent spurious spaces before attaching punctuation#694

Merged
daveallie merged 4 commits intocrosspoint-reader:masterfrom
jdk2pq:fix/style-change-introduces-spurious-spaces
Feb 5, 2026
Merged

fix: prevent spurious spaces before attaching punctuation#694
daveallie merged 4 commits intocrosspoint-reader:masterfrom
jdk2pq:fix/style-change-introduces-spurious-spaces

Conversation

@jdk2pq
Copy link
Contributor

@jdk2pq jdk2pq commented Feb 5, 2026

Fixes issue #182

Summary

What is the goal of this PR?
When inline styles change mid-paragraph, words like periods, commas, and quotes could end up as separate tokens. The justified text algorithm was treating these as regular words, adding space before them.

What changes are included?

Now tracks which words are "attaching punctuation" (., , ! ? ; : " ' and smart quotes) and excludes them from gap counting. These punctuation marks attach directly to the preceding word without spacing.

Additional Context

This is split out from code in #411 to address this comment #411 (comment)


AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? YES, Claude Code

When inline styles change mid-paragraph, words like periods, commas, and
quotes could end up as separate tokens. The justified text algorithm was
treating these as regular words, adding space before them.

Now tracks which words are "attaching punctuation" (., , ! ? ; : " ' and
smart quotes) and excludes them from gap counting. These punctuation marks
attach directly to the preceding word without spacing.

Fixes issue crosspoint-reader#182
@lukestein
Copy link
Contributor

Testing this on device, and the extraneous spaces all seem to be gone. Thank you!🎉

Before and after (in a spot with terrible justified spacing either way, but highlights the fix):

IMG_3201

IMG_3202

* master:
  feat: add shift lock to KeyboardEntryActivity (crosspoint-reader#513)
  feat: rename and move in file manager (crosspoint-reader#630)
  feat: Implement fix for sunlight fading issue (crosspoint-reader#603)
  chore: Add PR title check on sync (crosspoint-reader#698)
  feat: Go To Position for epubs (crosspoint-reader#666)
  feat: Calibre Web Automated (CWA) koreader sync server support (crosspoint-reader#594)
  chore: Add CI check job to consolidate status (crosspoint-reader#696)
  chore: CI Build Summary - firmware stats, firmware artifact (crosspoint-reader#601)
  feat: quick rotate option in epub reader menu (crosspoint-reader#685)
  feat(settings): add "Cover + Custom" sleep screen mode (crosspoint-reader#582)
  fix: Artifacts on Thumb on Home Screen (crosspoint-reader#662)
  feat: holding back button while booting, boots to home screen as a mean of escaping boot loop (crosspoint-reader#587)
  docs: Add small SCOPE.md and GOVERNANCE.md documents (crosspoint-reader#640)
  feat: front button remapper (crosspoint-reader#664)
  feat: UI themes, Lyra (crosspoint-reader#528)
  feat: Add CSS parsing and CSS support in EPUBs (crosspoint-reader#411)
  fix: move http upload state to heap (crosspoint-reader#657)
Copy link
Member

@daveallie daveallie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, this is a nice workaround fix.

A more complete fix honouring inline HTML elements should still be included in the future which would hopefully remove the need for specific word checking.

@daveallie daveallie merged commit cb4d86f into crosspoint-reader:master Feb 5, 2026
5 checks passed
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 5, 2026
…-reader#694)

Fixes issue crosspoint-reader#182

## Summary

**What is the goal of this PR?** 
When inline styles change mid-paragraph, words like periods, commas, and
quotes could end up as separate tokens. The justified text algorithm was
treating these as regular words, adding space before them.

**What changes are included?**

Now tracks which words are "attaching punctuation" (., , ! ? ; : " ' and
smart quotes) and excludes them from gap counting. These punctuation
marks attach directly to the preceding word without spacing.

## Additional Context

This is split out from code in crosspoint-reader#411 to address this comment
crosspoint-reader#411 (comment)

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 5, 2026
…-reader#694)

Fixes issue crosspoint-reader#182

## Summary

**What is the goal of this PR?** 
When inline styles change mid-paragraph, words like periods, commas, and
quotes could end up as separate tokens. The justified text algorithm was
treating these as regular words, adding space before them.

**What changes are included?**

Now tracks which words are "attaching punctuation" (., , ! ? ; : " ' and
smart quotes) and excludes them from gap counting. These punctuation
marks attach directly to the preceding word without spacing.

## Additional Context

This is split out from code in crosspoint-reader#411 to address this comment
crosspoint-reader#411 (comment)

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 5, 2026
…-reader#694)

Fixes issue crosspoint-reader#182

## Summary

**What is the goal of this PR?** 
When inline styles change mid-paragraph, words like periods, commas, and
quotes could end up as separate tokens. The justified text algorithm was
treating these as regular words, adding space before them.

**What changes are included?**

Now tracks which words are "attaching punctuation" (., , ! ? ; : " ' and
smart quotes) and excludes them from gap counting. These punctuation
marks attach directly to the preceding word without spacing.

## Additional Context

This is split out from code in crosspoint-reader#411 to address this comment
crosspoint-reader#411 (comment)

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 5, 2026
…-reader#694)

Fixes issue crosspoint-reader#182

## Summary

**What is the goal of this PR?** 
When inline styles change mid-paragraph, words like periods, commas, and
quotes could end up as separate tokens. The justified text algorithm was
treating these as regular words, adding space before them.

**What changes are included?**

Now tracks which words are "attaching punctuation" (., , ! ? ; : " ' and
smart quotes) and excludes them from gap counting. These punctuation
marks attach directly to the preceding word without spacing.

## Additional Context

This is split out from code in crosspoint-reader#411 to address this comment
crosspoint-reader#411 (comment)

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
daveallie pushed a commit that referenced this pull request Feb 6, 2026
Closes #182. Closes #710. Closes #711.

## Summary

**What is the goal of this PR?**
- A longer-term, more robust fix for the issue with spurious spaces
appearing after style changes. Replaces solution from #694.

**What changes are included?**
- Add continuation flags to determine if to add a space after a word or
if the word connects to the previous word. Replaces simple solution that
only considered ending punctuation.
- Fixed an issue with greedy line-breaking algorithm where punctuation
could appear on the next line, separated from the word, if there was a
style change between the word and punctuation

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
daveallie pushed a commit that referenced this pull request Feb 6, 2026
Closes #182. Closes #710. Closes #711.

## Summary

**What is the goal of this PR?**
- A longer-term, more robust fix for the issue with spurious spaces
appearing after style changes. Replaces solution from #694.

**What changes are included?**
- Add continuation flags to determine if to add a space after a word or
if the word connects to the previous word. Replaces simple solution that
only considered ending punctuation.
- Fixed an issue with greedy line-breaking algorithm where punctuation
could appear on the next line, separated from the word, if there was a
style change between the word and punctuation

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
Marma92 pushed a commit to Marma92/crosspoint-reader that referenced this pull request Feb 10, 2026
Closes crosspoint-reader#182. Closes crosspoint-reader#710. Closes crosspoint-reader#711.

## Summary

**What is the goal of this PR?**
- A longer-term, more robust fix for the issue with spurious spaces
appearing after style changes. Replaces solution from crosspoint-reader#694.

**What changes are included?**
- Add continuation flags to determine if to add a space after a word or
if the word connects to the previous word. Replaces simple solution that
only considered ending punctuation.
- Fixed an issue with greedy line-breaking algorithm where punctuation
could appear on the next line, separated from the word, if there was a
style change between the word and punctuation

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
…-reader#694)

Fixes issue crosspoint-reader#182

## Summary

**What is the goal of this PR?** 
When inline styles change mid-paragraph, words like periods, commas, and
quotes could end up as separate tokens. The justified text algorithm was
treating these as regular words, adding space before them.

**What changes are included?**

Now tracks which words are "attaching punctuation" (., , ! ? ; : " ' and
smart quotes) and excludes them from gap counting. These punctuation
marks attach directly to the preceding word without spacing.

## Additional Context

This is split out from code in crosspoint-reader#411 to address this comment
crosspoint-reader#411 (comment)

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
Closes crosspoint-reader#182. Closes crosspoint-reader#710. Closes crosspoint-reader#711.

## Summary

**What is the goal of this PR?**
- A longer-term, more robust fix for the issue with spurious spaces
appearing after style changes. Replaces solution from crosspoint-reader#694.

**What changes are included?**
- Add continuation flags to determine if to add a space after a word or
if the word connects to the previous word. Replaces simple solution that
only considered ending punctuation.
- Fixed an issue with greedy line-breaking algorithm where punctuation
could appear on the next line, separated from the word, if there was a
style change between the word and punctuation

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
Closes crosspoint-reader#182. Closes crosspoint-reader#710. Closes crosspoint-reader#711.

## Summary

**What is the goal of this PR?**
- A longer-term, more robust fix for the issue with spurious spaces
appearing after style changes. Replaces solution from crosspoint-reader#694.

**What changes are included?**
- Add continuation flags to determine if to add a space after a word or
if the word connects to the previous word. Replaces simple solution that
only considered ending punctuation.
- Fixed an issue with greedy line-breaking algorithm where punctuation
could appear on the next line, separated from the word, if there was a
style change between the word and punctuation

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**YES**_, Claude Code
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.

3 participants