-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Updated inline grammar regexes for strong and em #1315
Conversation
Attempt to match special case single character matches before the more permissive standard regexes
I am aware I need to add/update tests to this PR before it can be merged, but I haven't the time right now to figure them out so I'm creating this PR as a placeholder for me. If there's somewhere that describes the dev setup and testing folders (which look many and varied!) please let me know, otherwise I'll figure it over the weekend or next week. |
Hi @barrywoolgar thanks for the PR! The contibuting doc has some information (it assumes you have node.js installed) so that should get you going with running the test suit. The good news is, you didn't break any existing tests so that means all that we need is a test case for each issue you linked to 👍 |
If you fix a current spec test that is failing then all you need to do is remove it from marked/test/specs/commonmark/commonmark-spec.js Lines 333 to 346 in 7f311d7
|
That's great, thanks. Will have a look when I get home in a few then!
…On Thu, 2 Aug 2018, 20:07 Tony Brix, ***@***.***> wrote:
If you fix a current spec test that is failing then all you need to do is
remove it from shouldPassButFails
https://github.com/markedjs/marked/blob/7f311d761bebbfb203833f50c5255511d2923736/test/specs/commonmark/commonmark-spec.js#L333-L346
https://spec.commonmark.org/0.28/#example-333
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1315 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AF9WSZU1Mb6pMNzNIa86VmkPIkQHQUkaks5uM03bgaJpZM4Vswmc>
.
|
Hi, thanks for the pointers. I've got the test suite running and I can't find an existing I assume I shouldn't be making changes to the commonmark spec, as that seems to reference external examples. InsteadI've added some examples (matching those reported in the issues) to Is this sufficient? Thanks |
I confirmed this does fix the two issues and the new test looks good. I'm a little surprised that it didn't pass test
Given that this fixes some bugs, I think it's still worth merging as-is. |
@@ -540,8 +540,8 @@ var inline = { | |||
link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/, | |||
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/, | |||
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/, | |||
strong: /^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)|^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)/, | |||
em: /^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*][\s\S]*?[^\s])\*(?!\*)|^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)/, | |||
strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe
lib/marked.js
Outdated
strong: /^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)|^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)/, | ||
em: /^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*][\s\S]*?[^\s])\*(?!\*)|^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)/, | ||
strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/, | ||
em: /^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*][\s\S]*?[^\s])\*(?!\*)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe
The regexes are safe. If the tests don't break then I'm happy. |
I've been rather taken by investigating the |
If you are willing to fix some of the tests we can wait on merging the PR (best solution IMO). Or if you want we can merge this PR and you can submit a new PR with the improvements |
Adding |
Thanks, apologies to the reviewers who will presumably need to do it all again when I'm done. |
+1 |
lib/marked.js
Outdated
strong: /^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)|^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)/, | ||
em: /^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*][\s\S]*?[^\s])\*(?!\*)|^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)/, | ||
strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/, | ||
// em: /^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*][\s\S]*?[^\s])\*(?!\*)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this before acceptance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, sorry about that. Suddenly very busy at work but will tidy up and push my progress asap.
Are we just waiting on removing a comment in this PR? @joshbruce I think this should be in 0.5.0 too |
Sorry for the delay, work and personal life have got in the way a bit here. I've fixed the commented line, and pushed another commit that fixes the disabled tests for 333, 450, 452, 505, and 535. I was making some progress on some others but I'll have to submit those under a new PR as I doubt they'll be done anytime soon now. I have found that trying to read/debug a single regex that covers both the __ and ** formats is quite difficult, so I fell down a bit of a hole trying to separate those before continuing development. |
Updated inline grammar regexes for strong and em
Description
Contributor
Committer
In most cases, this should be a different person than the contributor.