mirror of
https://github.com/natelandau/obsidian-metadata.git
synced 2025-11-17 01:13:39 -05:00
fix(notes): diff now prints values in the form [value]
This commit is contained in:
@@ -7,7 +7,6 @@ from pathlib import Path
|
|||||||
|
|
||||||
import rich.repr
|
import rich.repr
|
||||||
import typer
|
import typer
|
||||||
from rich import print
|
|
||||||
|
|
||||||
from obsidian_metadata._utils import alerts
|
from obsidian_metadata._utils import alerts
|
||||||
from obsidian_metadata._utils.alerts import logger as log
|
from obsidian_metadata._utils.alerts import logger as log
|
||||||
@@ -228,9 +227,9 @@ class Note:
|
|||||||
result = list(diff.compare(a, b))
|
result = list(diff.compare(a, b))
|
||||||
for line in result:
|
for line in result:
|
||||||
if line.startswith("+"):
|
if line.startswith("+"):
|
||||||
print(f"[green]{line}[/]")
|
print(f"\033[92m{line}\033[0m")
|
||||||
elif line.startswith("-"):
|
elif line.startswith("-"):
|
||||||
print(f"[red]{line}[/]")
|
print(f"\033[91m{line}\033[0m")
|
||||||
|
|
||||||
def sub(self, pattern: str, replacement: str, is_regex: bool = False) -> None:
|
def sub(self, pattern: str, replacement: str, is_regex: bool = False) -> None:
|
||||||
"""Substitutes text within the note.
|
"""Substitutes text within the note.
|
||||||
@@ -348,7 +347,8 @@ class Note:
|
|||||||
self.file_content = new_frontmatter + self.file_content
|
self.file_content = new_frontmatter + self.file_content
|
||||||
return
|
return
|
||||||
|
|
||||||
self.sub(current_frontmatter, new_frontmatter)
|
current_frontmatter = re.escape(current_frontmatter)
|
||||||
|
self.sub(current_frontmatter, new_frontmatter, is_regex=True)
|
||||||
|
|
||||||
def write(self, path: Path = None) -> None:
|
def write(self, path: Path = None) -> None:
|
||||||
"""Writes the note's content to disk.
|
"""Writes the note's content to disk.
|
||||||
|
|||||||
Reference in New Issue
Block a user