From 8688a51238e2cb4709c443e9b5d6044951ebe739 Mon Sep 17 00:00:00 2001 From: Pavan <101964196+pavan-uppari@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:37:01 +0000 Subject: [PATCH] fix: used textwrap indent for indentation of child block --- notion2md/convertor/block.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/notion2md/convertor/block.py b/notion2md/convertor/block.py index 9e252c6..49a187c 100644 --- a/notion2md/convertor/block.py +++ b/notion2md/convertor/block.py @@ -3,6 +3,7 @@ import os import urllib.request as request from urllib.parse import urlparse,unquote +from textwrap import indent from cleo.io.io import IO @@ -30,7 +31,6 @@ def convert(self, blocks: dict) -> str: def convert_block( self, block: dict, - depth=0, ): outcome_block: str = "" block_type = block["type"] @@ -56,19 +56,16 @@ def convert_block( pass # create table block elif block_type == "table": - depth += 1 child_blocks = self._client.get_children(block["id"]) outcome_block = self.create_table(cell_blocks=child_blocks) # create indent block else: - depth += 1 child_blocks = self._client.get_children(block["id"]) for block in child_blocks: converted_block = self.convert_block( block, - depth, ) - outcome_block += "\t" * depth + converted_block + outcome_block += indent(converted_block, '\t') except Exception as e: if self._io: self._io.write_line(