mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
This commit is contained in:
parent
02232c0ca3
commit
c623d98bda
31
packages/app-cli/tests/html_to_md/table_with_code_3.html
Normal file
31
packages/app-cli/tests/html_to_md/table_with_code_3.html
Normal file
@ -0,0 +1,31 @@
|
||||
<div id="rendered-md">
|
||||
<table class="jop-noMdConv">
|
||||
<thead class="jop-noMdConv">
|
||||
<tr class="jop-noMdConv">
|
||||
<th class="jop-noMdConv">Code</th>
|
||||
<th class="jop-noMdConv">Description</th>
|
||||
</tr>
|
||||
<tr class="jop-noMdConv">
|
||||
<td class="jop-noMdConv">
|
||||
<pre class="jop-noMdConv"><code class="jop-noMdConv">const test = "hello";
|
||||
|
||||
// Another line
|
||||
console.log('Test...');
|
||||
|
||||
// Blank lines
|
||||
|
||||
|
||||
|
||||
// Should not break things.</code></pre>
|
||||
</td>
|
||||
<td class="jop-noMdConv">abcda</td>
|
||||
</tr>
|
||||
<tr class="jop-noMdConv">
|
||||
<td class="jop-noMdConv">
|
||||
<pre class="jop-noMdConv"><code class="jop-noMdConv">const test = "hello";</code></pre>
|
||||
</td>
|
||||
<td class="jop-noMdConv">abcd</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
10
packages/app-cli/tests/html_to_md/table_with_code_3.md
Normal file
10
packages/app-cli/tests/html_to_md/table_with_code_3.md
Normal file
@ -0,0 +1,10 @@
|
||||
<table class="jop-noMdConv"><thead class="jop-noMdConv"><tr class="jop-noMdConv"><th class="jop-noMdConv">Code</th><th class="jop-noMdConv">Description</th></tr><tr class="jop-noMdConv"><td class="jop-noMdConv"><pre class="jop-noMdConv"><code class="">const test = "hello";
|
||||
<!-- -->
|
||||
// Another line
|
||||
console.log('Test...');
|
||||
<!-- -->
|
||||
// Blank lines
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
// Should not break things.</code></pre></td><td class="jop-noMdConv">abcda</td></tr><tr class="jop-noMdConv"><td class="jop-noMdConv"><pre class="jop-noMdConv"><code class="">const test = "hello";</code></pre></td><td class="jop-noMdConv">abcd</td></tr></thead></table>
|
@ -44,7 +44,21 @@ export default function TurndownService (options) {
|
||||
return node.isBlock ? '\n\n' : ''
|
||||
},
|
||||
keepReplacement: function (content, node) {
|
||||
return node.isBlock ? '\n\n' + node.outerHTML + '\n\n' : node.outerHTML
|
||||
// In markdown, multiple blank lines end an HTML block. We thus
|
||||
// include an HTML comment to make otherwise blank lines not blank.
|
||||
const mutliBlankLineRegex = /\n([ \t\r]*)\n/g;
|
||||
|
||||
// We run the replacement multiple times to handle multiple blank
|
||||
// lines in a row.
|
||||
//
|
||||
// For example, "Foo\n\n\nBar" becomes "Foo\n<!-- -->\n\nBar" after the
|
||||
// first replacement.
|
||||
let html = node.outerHTML;
|
||||
while (html.match(mutliBlankLineRegex)) {
|
||||
html = html.replace(mutliBlankLineRegex, '\n<!-- -->$1\n');
|
||||
}
|
||||
|
||||
return node.isBlock ? '\n\n' + html + '\n\n' : html
|
||||
},
|
||||
defaultReplacement: function (content, node) {
|
||||
return node.isBlock ? '\n\n' + content + '\n\n' : content
|
||||
|
Loading…
Reference in New Issue
Block a user