diff --git a/src/converters/roam/index.ts b/src/converters/roam/index.ts index 1cd81a0..81aefd4 100644 --- a/src/converters/roam/index.ts +++ b/src/converters/roam/index.ts @@ -309,7 +309,7 @@ export class RoamConverter implements IConverter { } let url = undefined; - if (hasImages(nameToUse)) { + if (type !== 'codeblock' && hasImages(nameToUse)) { const allImages = findGroups(nameToUse, '![](', ')'); // only one image, so we can create a single node if (allImages.length === 1 && `![](${allImages[0].content})` === nameToUse) { @@ -361,12 +361,14 @@ export class RoamConverter implements IConverter { } this.summary.totalNodes += 1; - if (isTodo(intermediateNode.name)) { - setNodeAsTodo(intermediateNode); - } + if (type !== 'codeblock') { + if (isTodo(intermediateNode.name)) { + setNodeAsTodo(intermediateNode); + } - if (isDone(intermediateNode.name)) { - setNodeAsDone(intermediateNode); + if (isDone(intermediateNode.name)) { + setNodeAsDone(intermediateNode); + } } // Some dates in Roam do not have the correct date-formatted UID for some reason, so we'll try to fix those @@ -390,7 +392,7 @@ export class RoamConverter implements IConverter { } intermediateNode.refs = refs; - if (hasField(intermediateNode.name)) { + if (intermediateNode.type !== 'codeblock' && hasField(intermediateNode.name)) { this.summary.fields += 1; if (parentNode) { this.convertToField(intermediateNode, parentNode); diff --git a/src/converters/roam/tests/fixtures/codeblocks.json b/src/converters/roam/tests/fixtures/codeblocks.json index e3aae66..951a560 100644 --- a/src/converters/roam/tests/fixtures/codeblocks.json +++ b/src/converters/roam/tests/fixtures/codeblocks.json @@ -50,5 +50,22 @@ ":block/refs": [{ ":block/uid": "XWbzetf5I" }], "title": "<%J:```code here```%>", "create-time": 1588863716938 + }, + { + "edit-time": 1647535641290, + "refs": [], + "uid": "codefieldContainer", + "title": "Codefield", + "create-time": 1588863716938, + "children": [ + { + "edit-time": 1647535641290, + "children": [], + "refs": [], + "uid": "codefield", + "title": "```\ncodefield:: codetest\n```", + "create-time": 1588863716938 + } + ] } ] diff --git a/src/converters/roam/tests/roam.test.ts b/src/converters/roam/tests/roam.test.ts index e675aa8..5b0b899 100644 --- a/src/converters/roam/tests/roam.test.ts +++ b/src/converters/roam/tests/roam.test.ts @@ -238,6 +238,9 @@ test('Code blocks', () => { expect(f('otherCodeBlock')?.name).toBe('code here'); expect(f('otherCodeBlock')?.type).toBe('codeblock'); + + expect(f('codefield')?.type).toBe('codeblock'); + expect(f('codefield')?.children?.map(n=>n.uid)).toEqual([]) }); test('Complex / nested node', () => {