A program that parses journal entries, helps find tags & child blocks in journals and copies/moves them to the actual page
- sample_workspace: A sample Logseq workspace
- script/logseq_tweaker.py: The script that does the work
- Take a backup of your workspace ideally with git. That way you can reset the workspace back to its original state afterwards
- Run once in dry run mode
DRY_RUN=Y
in the .env file
- Clone this repo locally
- Navigate into the 'script' folder
- Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 -
- Install dependencies:
poetry install
- Navigate to the script folder
- Rename the file
example.env
to.env
and tweak it appropriately (ex: specify the path to your workspace) - Run the program
poetry run python ./logseq_tweaker.py
- Logs are recorded to the file:
application.log
- The example below shows sample markdown in a journal
- A note about [[Virtual Topic]]
- 1st Content added to the virtual topic which should be moved to the topic itself
- A duplicate note about [[Virtual Topic]]
- 2nd Content added to the virtual topic which should be moved to the topic itself
- Such entries above will be copied to a new file: "Virtual Topic.md" as below
- [[2024_12_19]]
- 1st Content added to the virtual topic which should be moved to the topic itself
- 2nd Content added to the virtual topic which should be moved to the topic itself
Add any you'd like to see as issues
- Find all references in journals
- List all references which don't exist as files
- List all references which have sub-blocks directly in a journal
- Create files for missing references & copy/move the blocks to the file
- Handle files which already exist
- Handle sub-folders
- Add support to exclude certain tags (ex:
#A
used for prioritisation of tasks) - Add support to ignore certain reference patterns
- Add support to ignore references below a certain length
- Add support to strip characters from references (to handle corrupted mentions like [[[[sample]]]])
- Bug: Add more resiliancy. A File handling error will cause the entire program to terminate
- Dry run mode
- Bug: Indentations are not retained in
CHILD_BLOCK_STRICT_MODE=Y
mode - Handle namespaces
- Install pytest:
pip install pytest-html
- Run all tests:
pytest --html=report.html
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
I wanted to also experiment with python - a language I'm not familiar with so most of the code was generated using ChatGPT & CoPilot on VS Code