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

Fix list truncate #78

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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.

None yet

1 participant