mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop, Cli: Fixed importing certain code blocks from ENEX
Ref: https://discourse.joplinapp.org/t/13113
This commit is contained in:
parent
33c5037816
commit
f53a7d3a8a
@ -44,14 +44,18 @@ describe('EnexToMd', function() {
|
||||
}
|
||||
|
||||
if (actualMd !== expectedMd) {
|
||||
console.info('');
|
||||
console.info(`Error converting file: ${htmlFilename}`);
|
||||
console.info('--------------------------------- Got:');
|
||||
console.info(actualMd.split('\n'));
|
||||
console.info('--------------------------------- Expected:');
|
||||
console.info(expectedMd.split('\n'));
|
||||
console.info('--------------------------------------------');
|
||||
console.info('');
|
||||
const result = [];
|
||||
|
||||
result.push('');
|
||||
result.push(`Error converting file: ${htmlFilename}`);
|
||||
result.push('--------------------------------- Got:');
|
||||
result.push(actualMd.split('\n').map((l: string) => `"${l}"`).join('\n'));
|
||||
result.push('--------------------------------- Expected:');
|
||||
result.push(expectedMd.split('\n').map((l: string) => `"${l}"`).join('\n'));
|
||||
result.push('--------------------------------------------');
|
||||
result.push('');
|
||||
|
||||
console.info(result.join('\n'));
|
||||
|
||||
expect(false).toBe(true);
|
||||
// return;
|
||||
|
2
packages/app-cli/tests/enex_to_md/code3.html
Normal file
2
packages/app-cli/tests/enex_to_md/code3.html
Normal file
@ -0,0 +1,2 @@
|
||||
<pre style="font-family: monospace;"><code><div>jq -r <span>'.[]|[.index, .name, .section, .award, .industry]|join("\t")'</span> raw.json |pbcopy
|
||||
</div></code></pre>
|
1
packages/app-cli/tests/enex_to_md/code3.md
Normal file
1
packages/app-cli/tests/enex_to_md/code3.md
Normal file
@ -0,0 +1 @@
|
||||
jq -r '.[]|[.index, .name, .section, .award, .industry]|join("\t")' raw.json |pbcopy
|
@ -392,10 +392,8 @@ function isSpanStyleBold(attributes) {
|
||||
if (style.includes('font-weight: bold;')) {
|
||||
return true;
|
||||
} else if (style.search(/font-family:.*,Bold.*;/) != -1) {
|
||||
// console.debug('font-family regex matched');
|
||||
return true;
|
||||
} else {
|
||||
// console.debug('Found unsupported style(s) in span tag: %s', style);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -700,14 +698,14 @@ function enexXmlToMdArray(stream, resources) {
|
||||
}
|
||||
} else if (n == 'span') {
|
||||
if (isSpanWithStyle(nodeAttributes)) {
|
||||
// console.debug('Found style(s) in span tag: %s', nodeAttributes.style);
|
||||
// Found style(s) in span tag
|
||||
state.spanAttributes.push(nodeAttributes);
|
||||
if (isSpanStyleBold(nodeAttributes)) {
|
||||
// console.debug('Applying style found in span tag: bold')
|
||||
// Applying style found in span tag: bold'
|
||||
section.lines.push('**');
|
||||
}
|
||||
if (isSpanStyleItalic(nodeAttributes)) {
|
||||
// console.debug('Applying style found in span tag: italic')
|
||||
// Applying style found in span tag: italic'
|
||||
section.lines.push('*');
|
||||
}
|
||||
}
|
||||
@ -753,7 +751,7 @@ function enexXmlToMdArray(stream, resources) {
|
||||
state.inCode.pop();
|
||||
|
||||
if (!state.inCode.length) {
|
||||
const codeLines = section.lines.join('').split('\n');
|
||||
const codeLines = processMdArrayNewLines(section.lines).split('\n');
|
||||
section.lines = [];
|
||||
if (codeLines.length > 1) {
|
||||
for (let i = 0; i < codeLines.length; i++) {
|
||||
@ -892,11 +890,11 @@ function enexXmlToMdArray(stream, resources) {
|
||||
const attributes = state.spanAttributes.pop();
|
||||
if (isSpanWithStyle(attributes)) {
|
||||
if (isSpanStyleBold(attributes)) {
|
||||
// console.debug('Applying style found in span tag (closing): bold')
|
||||
// Applying style found in span tag (closing): bold'
|
||||
section.lines.push('**');
|
||||
}
|
||||
if (isSpanStyleItalic(attributes)) {
|
||||
// console.debug('Applying style found in span tag (closing): italic')
|
||||
// Applying style found in span tag (closing): italic'
|
||||
section.lines.push('*');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user