From e768dae9783fead11918358e97144eb0f8b1a041 Mon Sep 17 00:00:00 2001 From: riley Date: Sat, 25 Sep 2021 20:16:08 -0400 Subject: [PATCH] Add \t support to parsing. --- todo/Todo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/todo/Todo.py b/todo/Todo.py index f4239f8..1ab6272 100644 --- a/todo/Todo.py +++ b/todo/Todo.py @@ -15,13 +15,15 @@ logger = logging.getLogger("Todo") logger.addHandler(logging.StreamHandler()) class Todo(TodoObject): - def __init__(self, data_file : Path = Path.home().joinpath("todo.md")): + def __init__(self, data_file : Path = Path.home().joinpath("todo.md"), tab_spacing = 2): """Todo class, reads and parses a todo.md from a file. Default file is 'todo.md' in the home directory. Args: data_file (Path, optional): Location of the markdown file to load from. Defaults to ~/todo.md. + tab_spacing (int, optional): How many levels a tab character should represent. Defaults to 2. """ self.data_file = data_file + self.tab_spacing = tab_spacing super().__init__(-1, "File") self._load_data() @@ -125,6 +127,7 @@ class Todo(TodoObject): """Load categories and tasks from self.data_file.""" with self.data_file.open("r") as f: for line in f: + line = line.replace("\t", self.tab_spacing*" ") line = line.rstrip() if len(line.strip()) == 0: # skip empty lines continue