diff --git a/pyomd/note.py b/pyomd/note.py index be0d37d..b647af9 100644 --- a/pyomd/note.py +++ b/pyomd/note.py @@ -30,7 +30,7 @@ def __init__(self, path: Union[Path, str]): """ self.path: Path = Path(path) try: - with open(self.path, "r") as f: + with open(self.path, "r", encoding="utf-8", newline='\n') as f: self.content: str = f.read() except Exception as e: raise NoteCreationError(path=path, exception=e) from e @@ -73,7 +73,7 @@ def sub(self, pattern: str, replace: str, is_regex: bool = False): """ if not is_regex: pattern = re.escape(pattern) - self.content = re.sub(pattern, replace, self.content) + self.content = re.sub(pattern, replace, self.content, flags=re.MULTILINE) def update_content( self, @@ -130,7 +130,7 @@ def write(self, path: Union[Path, None] = None): path to the note. If None, overwrites the current note content. """ p = self.path if path is None else path - with open(p, "w") as f: + with open(p, "w", encoding="utf-8", newline='\n') as f: f.write(self.content) @staticmethod