parse logseq markdown text with easy access to properties, hierarchy, TODO etc
Project description
LogseqMarkdownParser
a simple python script to load a markdown file and easily access the properties of each block etc. You can also parse it as json, handy when using jq. toml output is also supported.
Notes to reader
- Why make this? I wanted a script that reads a logseq page, extracts every "DONE" tasks and append it to another file. So I made this little parser. The resulting script can be found in
examples/done_mover.py
. If you need anything just create an issue. - How stable is it? Probably not very, I use it for specific things so things might go south. Please open an issue if you found a bug.
- note that the github version might be more up to date than the PyPI version
- Does it take into account the logbook (i.e. what's added to the block when clicking on 'DOING')? I didn't think about that initially. I think it should be parsed as normal block content and not as a property.
Features
- Implements classes
LogseqPage
andLogseqBlock
- access block properties as a dictionary
- easily save to a path
- parse as json:
LogseqMarkdownParser some_file.md --out_format='json' |jq
- parse as toml:
LogseqMarkdownParser some_file.md --out_format='toml' > output.toml
- supports stdin:
cat some_file.md | LogseqMarkdownParser --out_format='json' | jq
- shell completion:
eval "$(LogseqMarkdownParser -- --completion)"
oreval "$(cat completion.zsh)"
Usage
- Install with
python -m pip install LogseqMarkdownParser
- load file with
parsed = LogseqMarkdownParser.parse_file(file_content, verbose=True)
- get the first block with
parsed.blocks[0]
- get its properties with
parsed.blocks[0].properties
- add a property to a block with
parsed.blocks[0].set_property(key, value)
- save to path with
parsed.export_to("some/path.md")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
logseqmarkdownparser-2.12.tar.gz
(21.5 kB
view hashes)
Built Distribution
Close
Hashes for logseqmarkdownparser-2.12.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfad58447bcc1c0cf53a904c2a9c83d1f99cf0524afafe55b6924d1495f54082 |
|
MD5 | 47c71d3d82a098b2bf7e03190bf0ac7d |
|
BLAKE2b-256 | d5d5b33479922b5c830a8762207926349bea70fe96d576fafefddf33ad4454d4 |
Close
Hashes for LogseqMarkdownParser-2.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7fa2374446a86a8b705250c27774de815c2e0cd4f41d1312fe10a526e841ba9 |
|
MD5 | 29b5f1edc8d65ebc952f415c26f131bb |
|
BLAKE2b-256 | 8ec2074d979458cd190e349dca383765c5d7730e6265ccc34962b04ebb533026 |