{"id":23092037,"url":"https://github.com/thiswillbeyourgithub/logseqmarkdownparser","last_synced_at":"2025-08-16T09:30:53.798Z","repository":{"id":192088986,"uuid":"686330794","full_name":"thiswillbeyourgithub/LogseqMarkdownParser","owner":"thiswillbeyourgithub","description":"simple python script to load a markdown file and easily access the properties of each block etc.","archived":false,"fork":false,"pushed_at":"2024-11-26T16:10:57.000Z","size":260,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-26T17:23:52.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiswillbeyourgithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-02T12:34:08.000Z","updated_at":"2024-11-26T16:11:01.000Z","dependencies_parsed_at":"2024-02-23T22:26:36.614Z","dependency_job_id":"f893a644-2587-415b-afde-595fb92bb41f","html_url":"https://github.com/thiswillbeyourgithub/LogseqMarkdownParser","commit_stats":null,"previous_names":["thiswillbeyourgithub/logseqmarkdownparser"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2FLogseqMarkdownParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2FLogseqMarkdownParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2FLogseqMarkdownParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2FLogseqMarkdownParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiswillbeyourgithub","download_url":"https://codeload.github.com/thiswillbeyourgithub/LogseqMarkdownParser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230027917,"owners_count":18161837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-16T21:26:53.336Z","updated_at":"2024-12-16T21:26:54.384Z","avatar_url":"https://github.com/thiswillbeyourgithub.png","language":"Python","readme":"# LogseqMarkdownParser\na 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](https://github.com/jqlang/jq). toml output is also supported. You can use it as a cli tol or as a python library.\n\n# Notes to reader\n* **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.\n* **How stable is it?** Probably okay, I use it for specific things so things might go south in edge cases. Please open an issue if you found a bug.\n* Note that the github version might be more up to date than the PyPI version\n* **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.\n* **What's the deal with properties?** page.page_properties is a python dict, you can edit it freely as it's only appended to the top of the page when exporting. But page.blocks[0].properties is an ImmutableDict because the properties are stored inside the text content using Logseq format. To edit a block property, use the `del_property` and `set_property` method.\n\n## Features\n* Implements classes `LogseqPage` and `LogseqBlock`\n* read pages, page properties, block and block properties as a regular python dictionary\n* easily save to a path as a Logseq-ready markdown file with `page.export_to`\n* Static typing with [beartype](https://beartype.readthedocs.io/) if you have it installed (otherwise no typechecking).\n* parse for the cli as json: `LogseqMarkdownParser some_file.md --out_format='json' |jq`\n* parse for the cli as toml: `LogseqMarkdownParser some_file.md --out_format='toml' \u003e output.toml`\n* supports stdin: `cat some_file.md | LogseqMarkdownParser --out_format='json' | jq`\n* shell completion: `eval \"$(LogseqMarkdownParser -- --completion)\"` or `eval \"$(cat completion.zsh)\"`\n\n## How to\n* Install with `python -m pip install LogseqMarkdownParser`\n\n### Usage\n\nHere's an example that use `LogseqMarkdownParser`:\n- https://github.com/thiswillbeyourgithub/wdoc/tree/main/scripts/TheFiche\n- https://github.com/thiswillbeyourgithub/MdXLogseqTODOSync\n- If you do use it, tell me so that I can link it here!\n\nHere's a script example:\n``` python\nimport LogseqMarkdownParser\n\n# loading:\n# load file\npage = LogseqMarkdownParser.parse_file(file_content, verbose=True)\n# load a string\npage = LogseqMarkdownParser.parse_text(content=my_string, verbose=True)\n# load a string as page manually\npage = LogseqMarkdownParser.LogseqPage(content=my_string, verbose=True)\n\n# get page properties\npage.page_properties\n\n# access the blocks as a list\npage.blocks\n\n# get a block's properties\npage.blocks[0].properties\n# You can't edit them directly though, only page_properties can be directly edited at this time, see note below\n\n# edit block properties\npage.blocks[0].set_property(key, value)\npage.blocks[0].del_property(key)\n\n# inspect a page or block as a dict\npage.dict()  # this include the page properties, each block and their properties\npage.blocks[0].dict()\n\n# Save as Logseq ready md file\npage.export_to(\"some/path.md\")\n\n# format as another format\nprint(page.format('json'))  # also toml\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiswillbeyourgithub%2Flogseqmarkdownparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiswillbeyourgithub%2Flogseqmarkdownparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiswillbeyourgithub%2Flogseqmarkdownparser/lists"}