Skip to content

Conversation

@fivetentaylor
Copy link

Problem

The calculation of replaceText produces truncated lists sometimes. For example

Numbered lists

The existing approach for numbered lists with . in it

"1. Respond to the user to acnowledge their request. Be friendly, supportive, and concise.".split('. ').splice(1, 1).join('')
> 'Respond to the user to acnowledge their request'

While the new approach returns

"1. Respond to the user to acnowledge their request. Be friendly, supportive, and concise.".replace(/^\s*\d+\. /, "")
> 'Respond to the user to acnowledge their request. Be friendly, supportive, and concise.'

Bullet lists

The existing approach if a - is in the list

offsetText = "    - my bullet list with a - in it"
offsetText.split('- ').length > 1 ? offsetText.split('- ').splice(1, 1).join('') : offsetText
> 'my bullet list with a '

The updated approach

"    - my bullet list with a - in it".replace(/^\s*- /, "");
> 'my bullet list with a - in it'

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