Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tivie committed Feb 25, 2022
2 parents b02c1dd + 3e1a815 commit 16ad404
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 18 deletions.
48 changes: 44 additions & 4 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

46 changes: 43 additions & 3 deletions src/subParsers/makehtml/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ showdown.subParser('makehtml.lists', function (text, options, globals) {
return '¨A' + wm2;
});

// SPECIAL CASE: an heading followed by a paragraph of text that is not separated by a double newline
// SPECIAL CASE: a heading followed by a paragraph of text that is not separated by a double newline
// or/nor indented. ex:
//
// - # foo
// bar is great
//
// While this does now follow the spec per se, not allowing for this might cause confusion since
// header blocks don't need double newlines after
// header blocks don't need double-newlines after
if (/^#+.+\n.+/.test(item)) {
item = item.replace(/^(#+.+)$/m, '$1\n');
}
Expand All @@ -103,7 +103,47 @@ showdown.subParser('makehtml.lists', function (text, options, globals) {
// Has a double return (multi paragraph)
if (m1 || (item.search(/\n{2,}/) > -1)) {
item = showdown.subParser('makehtml.githubCodeBlocks')(item, options, globals);
item = showdown.subParser('makehtml.blockGamut')(item, options, globals);
item = showdown.subParser('makehtml.blockQuotes')(item, options, globals);
item = showdown.subParser('makehtml.headers')(item, options, globals);
item = showdown.subParser('makehtml.lists')(item, options, globals);
item = showdown.subParser('makehtml.codeBlocks')(item, options, globals);
item = showdown.subParser('makehtml.tables')(item, options, globals);
item = showdown.subParser('makehtml.hashHTMLBlocks')(item, options, globals);
//item = showdown.subParser('makehtml.paragraphs')(item, options, globals);

// TODO: This is a copy of the paragraph parser
// This is a provisory fix for issue #494
// For a permanente fix we need to rewrite the paragraph parser, passing the unhashify logic outside
// so that we can call the paragraph parser without accidently unashifying previously parsed blocks

// Strip leading and trailing lines:
item = item.replace(/^\n+/g, '');
item = item.replace(/\n+$/g, '');

var grafs = item.split(/\n{2,}/g),
grafsOut = [],
end = grafs.length; // Wrap <p> tags

for (var i = 0; i < end; i++) {
var str = grafs[i];
// if this is an HTML marker, copy it
if (str.search(/¨([KG])(\d+)\1/g) >= 0) {
grafsOut.push(str);

// test for presence of characters to prevent empty lines being parsed
// as paragraphs (resulting in undesired extra empty paragraphs)
} else if (str.search(/\S/) >= 0) {
str = showdown.subParser('makehtml.spanGamut')(str, options, globals);
str = str.replace(/^([ \t]*)/g, '<p>');
str += '</p>';
grafsOut.push(str);
}
}
item = grafsOut.join('\n');
// Strip leading and trailing lines:
item = item.replace(/^\n+/g, '');
item = item.replace(/\n+$/g, '');

} else {

// Recursion for sub-lists:
Expand Down
2 changes: 1 addition & 1 deletion src/subParsers/makemarkdown/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ showdown.subParser('makeMarkdown.table', function (node, globals) {
for (ii = 0; ii < tableArray[i].length; ++ii) {
if (i === 1) {
if (tableArray[i][ii].slice(-1) === ':') {
tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':';
tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(0, -1), cellSpacesCount - 1, '-') + ':';
} else {
tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-');
}
Expand Down
15 changes: 9 additions & 6 deletions test/functional/makehtml/cases/features/underline/fulltext.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,17 @@ <h2 id="lists">Lists</h2>
</code></pre></li>
<li><p>Blue</p></li>
<li><p>Red</p>
<pre><code>* Green<pre><code>Try this code:
<pre><code>* Green

This is an embedded code block.
Try this code:

Then this:
This is an embedded code block.

More code!
</code></pre>* Blue
Then this:

More code!

* Blue
* Red
</code></pre></li>
</ul>
Expand Down Expand Up @@ -365,4 +368,4 @@ <h1 id="horizontalrules">Horizontal Rules</h1>
<hr />
<hr />
<hr />
<hr />
<hr />
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<pre><code>public static void main(String[] args) {

for (int i = 0; i &lt; 10 &amp;&amp; true; i++) {

System.out.println("Hello World");
}

// stuff here is affected as well &lt;&gt;&amp;&amp;%
}
</code></pre>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```
public static void main(String[] args) {
for (int i = 0; i < 10 && true; i++) {
System.out.println("Hello World");
}
// stuff here is affected as well <>&&%
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<ol>
<li><p>Code block as part of list</p>
<pre><code>public static void main(String[] args) {

for (int i = 0; i &lt; 10 &amp;&amp; true; i++) {

System.out.println("Hello World");
}

// stuff here is affected as well &lt;&gt;&amp;&amp;%
}
</code></pre></li>
</ol>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1. Code block as part of list

```
public static void main(String[] args) {
for (int i = 0; i < 10 && true; i++) {
System.out.println("Hello World");
}
// stuff here is affected as well <>&&%
}
```

0 comments on commit 16ad404

Please sign in to comment.