Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[MarkdownFixer] Do not escape username with underscores in code or codeblocks #5785
What type of PR is this? (check all applicable)
The underscored username got escaped in code and code blocks. We probably do not want that. The fix is only to escape underscored username if they are not in code or code blocks.
Other possible approaches:
Related Tickets & Documents
Current on dev (2019.01.28, 26e4412)
After this Pull Request (tested against 432885f)
Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?
rhymes left a comment
Thank you @JuanitoFatas, markdown parsing bugs are always complicated to fix, your solution seems very clever!
I left notes about adding comments to the new code as node traversal and regexp aren't usually super intuitive for future new readers.
ps. don't forget to prefix your branches with your name in the future, you can checkout the contributing guide for details.
Thanks for the review. I‘ve added comments and changed the implementation to a less clever one
It only runs when markdown has underscored usernames. Skip escaping underscore when content is in code or codeblock. It works by going through all lines of a markdown content. Find underscored username. Escape if we are not in the codeblock. The (?<!) is negative lookbehind which rules out the case when a underscored username is present in code, e.g., `@_dev_` will not be escaped.