Converts notes from one application to another
Project description
convertnotes
This tool converts your notes from one format/application to another. Currently, the only supported conversion is from Logseq to Roam.
Installation
$ pip install convertnotes
Roam Upload
Roam does not provide a convenient way to upload images, however it does allow you to run somewhat arbitrary Javascript which can do the trick.
To do this, first you need to enable "user code" in your User settings:
Then copy the following snippet and paste it anywhere in your Roam notes:
- {{[[roam/js]]}}
-
</code></pre> </li> </ul> </li> </ul> <p>async function convertNotesUploader() { var batchSize = 4;</p> <p>// helper functions var downloadJSON = (blob, filename) => { // Create a link element const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename; document.body.appendChild(a); a.click();</p> <pre><code>// Clean up by revoking the Object URL and removing the link element URL.revokeObjectURL(url); a.remove();
}
function batchArray(arr, size) { let result = []; for (let i = 0; i < arr.length; i += size) { let batch = arr.slice(i, i + size); result.push(batch); } return result; }
// create upload command await window.roamAlphaAPI.ui.commandPalette.addCommand({ label: "Upload images for ConvertNotes", callback: () => { var fileInput = document.createElement('input'); fileInput.type = 'file'; fileInput.id = 'filePicker'; fileInput.multiple = 'multiple'; fileInput.display = 'none'; document.body.appendChild(fileInput);
fileInput.addEventListener('change', async function (event) { var files = event.target.files; var batches = batchArray(Array.from(files), batchSize); var metadataList = []; // upload files in batches for (var batch of batches) { var batchMetadata = await Promise.all(batch.map(async file => { var markdownLink = await roamAlphaAPI.file.upload({ file: file }) return { name: file.name, size: file.size, type: file.type, path: file.path, markdownLink: markdownLink, } })); metadataList.push(batchMetadata) } console.log(metadataList); const jsonBlob = new Blob( [JSON.stringify(metadataList.flat(), null, 2)], { type: 'application/json' } ); downloadJSON(jsonBlob, 'file_metadata.json'); fileInput.remove(); }); fileInput.click(); },
});
console.log("convertnotes loaded"); }
convertNotesUploader();
</details> When you do this, it will give you a warning like this: ![](./assets/warning.png) Click the button that says you know what you are doing and then restart your Roam graph (restart the app, refresh the page, etc) to make sure that the javascript loads. Once it restarts, run the keyboard shortcut `cmd+p` to open the command palette. Now just search for "ConvertNotes" and you should see an option like the following: ![](./assets/convertnotes.png) Hit the `Enter` key. You will now be prompted to select the files you want to upload. If you are coming from logseq, the files you're looking for are in the `assets` directory within your graph folder. Select *all* of the files that you want which are referenced in your notes and wait for them to upload. *Do not navigate or do anything.* It might take a while because the files are uploaded in batches. Once they are done you will be prompted to download a metadata JSON file. Save this. You will need it when running `convertnotes` so that the links in your notes can be updated to reference the new files managed by Roam. ## Usage To export your notes from Logseq and import them into Roam, first export your notes as JSON from within Logseq (see [docs](https://docs.logseq.com/#/page/export)). Once you have the JSON file, navigate to the file in your terminal and execute a command like the following to convert them to Roam JSON: ```sh $ convertnotes -i ./logseq.json -o ./roam.json -p logseqtoroam
-
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for convertnotes-0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a54f6d8c758e58db2512ad43cdd10a7a19b42ef6f96df8a1f01560af3b98e3e9 |
|
MD5 | eccb55bca65756b1fbf3c918d330d235 |
|
BLAKE2b-256 | 2541f4f3e340dd1d3c621c7b1d4ed595f8806837613e4bdb208b7c802d3fd763 |