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

Wrong result when using multiple italic markdown in a sequence separated by space #72

Closed
maheshkumarsoni opened this issue Dec 28, 2023 · 1 comment · Fixed by #73
Closed

Comments

@maheshkumarsoni
Copy link
Contributor

Problem Statement:

  • The issue is when we have a sequential ‘_' (underscore) character after a space the package will replace the underscore from the only first word!
    Example: ‘Wizard with a gun' -> Wizard with a gun

  • Here 'Wizard’ and 'with’ both are separated by space and have an underscore around them so when we parse the string with the remove-markdown npm package it parses the first word. due to the next word being exactly after a space. Hence, it's not able to identify that word as a Markdown character!

Screenshot 2023-12-28 at 4 32 55 PM

Solution:

  • For now, I've fixed this with a workaround code to break this sequence by manipulating the string to replace the _ _ sequence and fix the markdown below is the example code snippet I tried:

Screenshot 2023-12-28 at 4 50 40 PM

@maheshkumarsoni
Copy link
Contributor Author

maheshkumarsoni commented Dec 28, 2023

I've checked the code and identified that the regex to replace italic markdown (_) does not cover the above issue!
here is the working regex to solve this issue: output.replace(/([_]+)(.*?\S)([_]+)/g, '$2'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant