mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Desktop, Cli: Fixes #4965: Handle special type of code block when importing ENEX files
This commit is contained in:
parent
118a2f9f25
commit
0019bd147a
1
packages/app-cli/tests/enex_to_md/code5.html
Normal file
1
packages/app-cli/tests/enex_to_md/code5.html
Normal file
@ -0,0 +1 @@
|
||||
<div><br /></div><div style="--en-codeblock:true;box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial;"><div>public class SwapIntegerWithoutTemp {</div><div><br /></div><div> public void swapAddition() {</div><div> int a = 3;</div><div> int b = 5;</div><div><br /></div><div> a = a + b; // a=8, b=5</div><div> b = a - b; // a=8, b=3</div><div> a = a - b; // a=5, b=3</div><div> }</div><div>}</div></div><div><br /></div>
|
13
packages/app-cli/tests/enex_to_md/code5.md
Normal file
13
packages/app-cli/tests/enex_to_md/code5.md
Normal file
@ -0,0 +1,13 @@
|
||||
```
|
||||
public class SwapIntegerWithoutTemp {
|
||||
|
||||
public void swapAddition() {
|
||||
int a = 3;
|
||||
int b = 5;
|
||||
|
||||
a = a + b; // a=8, b=5
|
||||
b = a - b; // a=8, b=3
|
||||
a = a - b; // a=5, b=3
|
||||
}
|
||||
}
|
||||
```
|
@ -503,31 +503,15 @@ function isCodeBlock(context: any, nodeName: string, attributes: any) {
|
||||
if (nodeName === 'code') return true;
|
||||
|
||||
if (attributes && attributes.style) {
|
||||
const enCodeBlock = cssValue(context, attributes.style, '-en-codeblock');
|
||||
// Yes, this property sometimes appears as -en-codeblock, sometimes as
|
||||
// --en-codeblock. Would be too easy to import ENEX data otherwise.
|
||||
// https://github.com/laurent22/joplin/issues/4965
|
||||
const enCodeBlock = cssValue(context, attributes.style, '-en-codeblock') || cssValue(context, attributes.style, '--en-codeblock');
|
||||
if (enCodeBlock && enCodeBlock.toLowerCase() === 'true') return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// function removeSectionParent(section:Section | string) {
|
||||
// if (typeof section === 'string') return section;
|
||||
|
||||
// section = { ...section };
|
||||
// delete section.parent;
|
||||
|
||||
// section.lines = section.lines.slice();
|
||||
|
||||
// for (let i = 0; i < section.lines.length; i++) {
|
||||
// section.lines[i] = removeSectionParent(section.lines[i]);
|
||||
// }
|
||||
|
||||
// return section;
|
||||
// }
|
||||
|
||||
// function printSection(section:Section) {
|
||||
// console.info(JSON.stringify(removeSectionParent(section), null, 4));
|
||||
// }
|
||||
|
||||
function enexXmlToMdArray(stream: any, resources: ResourceEntity[]): Promise<EnexXmlToMdArrayResult> {
|
||||
const remainingResources = resources.slice();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user