mirror of
https://github.com/natelandau/obsidian-metadata.git
synced 2025-11-17 09:23:40 -05:00
feat: add new inline metadata (#15)
* feat: add new inline metadata to notes * fix: prepend note content after frontmatter * refactor: cleanup search patterns * feat(regex): find top of note * test: add headers * fix: insert to specified location * test: improve test coverage * docs: add inline metadata
This commit is contained in:
committed by
Nathaniel Landau
parent
13513b2a14
commit
17985615b3
@@ -12,7 +12,7 @@ from typing import Any
|
||||
import questionary
|
||||
import typer
|
||||
|
||||
from obsidian_metadata.models.enums import MetadataType
|
||||
from obsidian_metadata.models.enums import InsertLocation, MetadataType
|
||||
from obsidian_metadata.models.patterns import Patterns
|
||||
from obsidian_metadata.models.vault import Vault
|
||||
|
||||
@@ -76,6 +76,7 @@ class Questions:
|
||||
("qmark", "bold"),
|
||||
("question", "bold"),
|
||||
("separator", "fg:#808080"),
|
||||
("answer", "fg:#FF9D00 bold"),
|
||||
("instruction", "fg:#808080"),
|
||||
("highlighted", "bold underline"),
|
||||
("text", ""),
|
||||
@@ -405,6 +406,23 @@ class Questions:
|
||||
qmark="INPUT |",
|
||||
).ask()
|
||||
|
||||
def ask_metadata_location(
|
||||
self, question: str = "Where in a note should we add metadata"
|
||||
) -> InsertLocation: # pragma: no cover
|
||||
"""Ask the user for the location within a note to place new metadata.
|
||||
|
||||
Returns:
|
||||
InsertLocation: The location within a note to place new metadata.
|
||||
"""
|
||||
choices = []
|
||||
for metadata_location in InsertLocation:
|
||||
choices.append({"name": metadata_location.value, "value": metadata_location})
|
||||
|
||||
return self.ask_selection(
|
||||
choices=choices,
|
||||
question="Select the location for the metadata",
|
||||
)
|
||||
|
||||
def ask_new_key(self, question: str = "New key name") -> str: # pragma: no cover
|
||||
"""Ask the user for a new metadata key.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user