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

Updated inline grammar regexes for strong and em #1315

Merged
merged 4 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])\*\*(?!\*)/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe

em: /^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*][\s\S]*?[^\s])\*(?!\*)/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe

code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,
br: /^( {2,}|\\)\n(?!\s*$)/,
del: noop,
Expand Down
7 changes: 7 additions & 0 deletions test/new/cm_strong_and_em.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>So <em>a</em> single <em>word</em> followed <em>b</em>y <em>a</em>nother</p>

<p>So <strong>a</strong> single <strong>word</strong> followed <strong>b</strong>y <strong>a</strong>nother</p>

<p>So <em>a</em> single <em>word</em> followed <em>b</em>y <em>a</em>nother</p>

<p>So <strong>a</strong> single <strong>word</strong> followed <strong>b</strong>y <strong>a</strong>nother</p>
7 changes: 7 additions & 0 deletions test/new/cm_strong_and_em.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
So *a* single *word* followed *b*y *a*nother

So **a** single **word** followed **b**y **a**nother

So _a_ single _word_ followed _b_y _a_nother

So __a__ single __word__ followed __b__y __a__nother