Skip to content

remove full-width spaces and duplicated spaces in subtitles#146

Merged
tatsumoto-ren merged 4 commits intoAjatt-Tools:masterfrom
mosaic-roll:remove-full-width-spaces
Aug 29, 2025
Merged

remove full-width spaces and duplicated spaces in subtitles#146
tatsumoto-ren merged 4 commits intoAjatt-Tools:masterfrom
mosaic-roll:remove-full-width-spaces

Conversation

@mosaic-roll
Copy link
Copy Markdown
Contributor

These spaces are anoying...

helpers.lua Outdated
Comment on lines +151 to +159
this.remove_full_width_spaces = function(str)
-- remove so-called Ideographic Spaces
return str:gsub(' +', ' ')
end

this.remove_duplicated_spaces = function(str)
return str:gsub(' +', ' ')
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can merge these two patterns into one.

this.normalize_spaces = function(str)
  -- replace sequences of ASCII spaces or full-width ideographic spaces with a single ASCII space
  return str:gsub('[  ]+', ' ')
end

@tatsumoto-ren
Copy link
Copy Markdown
Member

Also, consider using the nuke_spaces config option. Maybe that's what you need. If so, this PR won't be needed.

@mosaic-roll
Copy link
Copy Markdown
Contributor Author

Also, consider using the nuke_spaces config option. Maybe that's what you need. If so, this PR won't be needed.

The nuke_spaces option is supposed to remove all spaces, which isn't what I want. Also, it doesn't affect full-width ideographic spaces.

@mosaic-roll mosaic-roll force-pushed the remove-full-width-spaces branch from 4e03f61 to 30613fb Compare August 29, 2025 09:40
@mosaic-roll mosaic-roll force-pushed the remove-full-width-spaces branch from 30613fb to c4fba59 Compare August 29, 2025 14:43
@tatsumoto-ren
Copy link
Copy Markdown
Member

The nuke_spaces option is supposed to remove all spaces, which isn't what I want. Also, it doesn't affect full-width ideographic spaces.

I see.

@tatsumoto-ren tatsumoto-ren merged commit 180485b into Ajatt-Tools:master Aug 29, 2025
@mosaic-roll mosaic-roll deleted the remove-full-width-spaces branch August 29, 2025 15:07
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.

2 participants