mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-23 18:53:36 +02:00
HtmlToMd: Fix conversion of tables
This commit is contained in:
parent
ba2874173d
commit
2e32211a28
12
CliClient/tests/html_to_md/table1.html
Normal file
12
CliClient/tests/html_to_md/table1.html
Normal file
@ -0,0 +1,12 @@
|
||||
<table style="font-size: 1em; font-weight: normal; font-style: normal; color: black;width:2420px;" width="100%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td style="padding: 0em; vertical-align: top;width:100%;">
|
||||
<div style="font-size: 1em; padding: 0;"><span style="color: black; font-family: 'Consolas', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important;">$ sudo ethtool --set-priv-flags p2p1 mlx4_rss_xor_hash_function on</span></div>
|
||||
<div style="font-size: 1em; padding: 0;"><span style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;"># Three empty lines follow</span></div>
|
||||
<div style="font-size: 1em; padding: 0;"><span style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;"><br/></span></div>
|
||||
<div style="font-size: 1em; padding: 0;"><span style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;"><br/></span></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Some text
|
5
CliClient/tests/html_to_md/table1.md
Normal file
5
CliClient/tests/html_to_md/table1.md
Normal file
@ -0,0 +1,5 @@
|
||||
| |
|
||||
| --- |
|
||||
| $ sudo ethtool --set-priv-flags p2p1 mlx4_rss_xor_hash_function on<br># Three empty lines follow<br> |
|
||||
|
||||
Some text
|
@ -377,7 +377,7 @@ function processMdArrayNewLines(md, isTable = false) {
|
||||
// on various rules.
|
||||
|
||||
const isHeading = function(line) {
|
||||
return !!line.match(/#+\s/);
|
||||
return !!line.match(/^#+\s/);
|
||||
}
|
||||
|
||||
const isListItem = function(line) {
|
||||
@ -389,7 +389,7 @@ function processMdArrayNewLines(md, isTable = false) {
|
||||
}
|
||||
|
||||
const isTableLine = function(line) {
|
||||
return line.indexOf('|') === 0;
|
||||
return line.indexOf('| ') === 0;
|
||||
}
|
||||
|
||||
const isPlainParagraph = function(line) {
|
||||
@ -433,6 +433,12 @@ function formatMdLayout(lines) {
|
||||
|
||||
} else if (!isCodeLine(line) && isCodeLine(previous)) {
|
||||
newLines.push('');
|
||||
|
||||
} else if (isTableLine(line) && !isTableLine(previous)) {
|
||||
newLines.push('');
|
||||
|
||||
} else if (!isTableLine(line) && isTableLine(previous)) {
|
||||
newLines.push('');
|
||||
|
||||
// Add a new line at beginning of paragraph
|
||||
} else if (isPlainParagraph(line) && previous) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user