Cson To Markdown
What
Recursively scans given folder for .cson files, extracts the metadata and markdown,
and writes a .md file and a meta/.yml file.
Written specifically for use with Boostnote.
Why?
I write everything in Markdown format because I like the formatting, and my favourite markdown editor so far is Boostnote. Everything is stored in a dedicated git repository and pushed whenever changes occur. This works great!
The problem though, is that Boostnote stores the file in a cson format, without subfolders and without legible note-titles.
I wrote something that extracts this information without disturbing the original files, and writes both the markdown and the metadata somewhere else.
They're created in the subfolder to which they belong in the application, with the note title as filename.
Caution: A new version is in the works and will be announced which might completely break this tool.
How to install
pip install cson-to-markdown
How to use
1. CLI
I use Google's python-fire to create the CLI.
You can run cson_to_markdown --help to get more information on the module.
There's 3 arguments that can be provided; cson_to_markdown $arg1 $arg2 $arg3
- The folder with the
.csonfiles that need to be converted (looks recursive in this path for all compatible files). - Optional target folder for markdown file output. If no value is provided, they will be stored in the same folder as the
.csonfiles. - Optional folder containing the
boostnote.jsonfile. This contains the key-name pairs of the folders defined in the Boostnote aplication itself.
# Call module directly
cson_to_markdown ~/folder/with/notes ~/output/folder ~/settings/dir
# Through python
python -m cson_to_markdown ~/folder/with/notes ~/output/folder ~/settings/dir
2. Python:
from cson_to_markdown import FileConverter
converter = FileConverter("folder/with/cson", "optional/target/folder", "optional/boostnote/settings/dir")
converter.convert()
3. Git hooks
You can leverage the usefulness of git hooks, to make use of this module. Based off of this StackOverflow answer, I implemented the following: Note: This is not a clean way to do this, think before you copy paste this.
- Create pre-commit hook in notes repository:
vim .git/hooks/pre-commit
#!/bin/bash
echo
touch .commit
exit
- Create post-commit hook to create and add new files to the commit:
vim .git/hooks/post-commit
#!/bin/bash
cson_to_markdown $INSERT_NOTES_FOLDER $OPTIONAL_MARKDOWN_OUTPUT_FOLDER $OPTIONAL_BOOSTNOTE_SETTINGS_FOLDER
if [ -a .commit ]
then
rm .commit
git add .
git commit --amend -C HEAD --no-verify
fi
exit
- Make both executable:
chmod u+x .git/hooks/pre-commit .git/hooks/post-commit
How to configure
There are a few settings that can be configured through environment variables, defined in cson_to_markdown/config.py.
We will by default first look at an appropriately named environemnt variable, and fall back to the defaults if none were found.
These are the current settings, which work for the Boostnote use-case specifically.
_config = {
"MARKDOWN_START": "content: '''",
"MARKDOWN_END": "'''",
"TITLE_INDICATOR": 'title: "',
"FOLDER_INDICATOR": 'folder: "',
"YAML_STRING_INDICATOR": '"',
"CSON_EXTENSION": ".cson",
"MARKDOWN_EXTENSION": ".md",
"METADATA_EXTENSION": ".yml",
"METADATA_FOLDER": "meta",
"BNOTE_SETTINGS_FILE": "boostnote.json",
}
To overwrite, simply set a new environment variable in your terminal, or add it to your .bashrc file:
export MARKDOWN_START="new start delimiter"
Metadata
Release files for cson-to-markdown 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cson-to-markdown-0.1.3.tar.gz | 6.6 kB | Without provenance | Details for cson-to-markdown-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cson_to_markdown-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for cson_to_markdown-0.1.3-py3-none-any.whl |
Total release size: 14.0 kB
Release files / cson-to-markdown-0.1.3.tar.gz
| Download URL | cson-to-markdown-0.1.3.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1aeb81269e7374845d4e178fa0531b3dba78dead44de5c262e88f08156c4593
|
|
BLAKE2b-256 checksum How to use checksums |
e6ef13174fc4a0f70bb68fd17256e684fa3193ab0dc9e876054cb3465578fec7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.1 Linux/5.4.17-1-MANJARO
|
Release files / cson_to_markdown-0.1.3-py3-none-any.whl
| Download URL | cson_to_markdown-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36ef0d249b5d4e125687841904f7af0d02e74add52055f78dba51bf14c612aa3
|
|
BLAKE2b-256 checksum How to use checksums |
6055722e1b8f54ff9ff7f5101dc8ef502be2bc9c3e3ac45f82e3f4c7f2d3afc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.1 Linux/5.4.17-1-MANJARO
|
Security for cson-to-markdown 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.