Skip to content

Commit

Permalink
Merge branch 'master' into render-inline-html
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle authored Feb 12, 2020
2 parents 11656f8 + a20e2f7 commit 4956bd3
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .nowignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!docs
!docs/**
4 changes: 2 additions & 2 deletions bin/marked
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ function help() {
stdio: 'inherit'
};

spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
spawn('man', [path.resolve(__dirname, '../man/marked.1')], options)
.on('error', function() {
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
fs.readFile(path.resolve(__dirname, '../man/marked.1.txt'), 'utf8', function(err, data) {
if (err) throw err;
console.log(data);
});
Expand Down
6 changes: 3 additions & 3 deletions lib/marked.esm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* marked - a markdown parser
* Copyright (c) 2011-2019, Christopher Jeffrey. (MIT Licensed)
* Copyright (c) 2011-2020, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked
*/

Expand Down Expand Up @@ -305,7 +305,7 @@ const {
const block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
Expand Down Expand Up @@ -367,7 +367,7 @@ block.paragraph = edit$1(block._paragraph)
.replace('heading', ' {0,3}#{1,6} +')
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
.replace('blockquote', ' {0,3}>')
.replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
Expand Down
6 changes: 3 additions & 3 deletions lib/marked.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* marked - a markdown parser
* Copyright (c) 2011-2019, Christopher Jeffrey. (MIT Licensed)
* Copyright (c) 2011-2020, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked
*/

Expand Down Expand Up @@ -352,7 +352,7 @@
var block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
Expand Down Expand Up @@ -387,7 +387,7 @@
block._comment = /<!--(?!-?>)[\s\S]*?-->/;
block.html = edit$1(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
block.paragraph = edit$1(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} +').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
.getRegex();
block.blockquote = edit$1(block.blockquote).replace('paragraph', block.paragraph).getRegex();
Expand Down
4 changes: 2 additions & 2 deletions marked.min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions now.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"name": "markedjs",
"scope": "markedjs",
"alias": "markedjs.now.sh",
"version": 2,
"regions": ["all"],
"builds": [
{ "src": "docs/**", "use": "@now/static" }
],
Expand Down
4 changes: 2 additions & 2 deletions src/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
const block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
Expand Down Expand Up @@ -72,7 +72,7 @@ block.paragraph = edit(block._paragraph)
.replace('heading', ' {0,3}#{1,6} +')
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
.replace('blockquote', ' {0,3}>')
.replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
Expand Down
3 changes: 1 addition & 2 deletions test/specs/commonmark/commonmark.0.29.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,7 @@
"example": 116,
"start_line": 1996,
"end_line": 2003,
"section": "Fenced code blocks",
"shouldFail": true
"section": "Fenced code blocks"
},
{
"markdown": "```\n``` aaa\n```\n",
Expand Down
3 changes: 1 addition & 2 deletions test/specs/gfm/commonmark.0.29.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,7 @@
"example": 116,
"start_line": 1996,
"end_line": 2003,
"section": "Fenced code blocks",
"shouldFail": true
"section": "Fenced code blocks"
},
{
"markdown": "```\n``` aaa\n```\n",
Expand Down
14 changes: 14 additions & 0 deletions test/specs/new/fences_breaking_paragraphs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p>A paragraph</p>
<pre><code class="language-A">Here is code in
backtick fences</code></pre>
<p>B paragraph</p>
<pre><code class="language-B">Here is code in
tilde fences</code></pre>
<p>C paragraph</p>
<pre><code class="language-`C~">Alternative
tilde fences</code></pre>
<p>D paragraph ```~D` Invalid use of backtick fences</p>
<pre><code>
This will be read as
part of a codeblock
that ends with the file</code></pre>
27 changes: 27 additions & 0 deletions test/specs/new/fences_breaking_paragraphs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
A paragraph
```A
Here is code in
backtick fences
```

B paragraph
~~~B
Here is code in
tilde fences
~~~

C paragraph
~~~`C~
Alternative
tilde fences
~~~

D paragraph
```~D`
Invalid use of
backtick fences
```
This will be read as
part of a codeblock
that ends with the file

0 comments on commit 4956bd3

Please sign in to comment.