Skip to content

formatter

This module contains the classes that represent formatters.

Formatters are used to format the content that will be added in notes.

Formatter

Bases: ABC

Base class for all formatters.

format(value: str | list[str]) -> str | list[str] abstractmethod

Format the content.

Parameters:

  • value (str | list[str]) –

    The content to format.

Returns:

  • str | list[str]

    The formatted content.

Source code in pyobsidian/formatter.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@abstractmethod
def format(self: Self, value: str | list[str]) -> str | list[str]:
    """Format the content.

    Parameters
    ----------
    value : str | list[str]
        The content to format.

    Returns
    -------
    str | list[str]
        The formatted content.
    """
    ...

FormatterContentInline

Bases: Formatter

This formatter adds two line breaks at the beginning and end.

FormatterRelatedNoteInline

Bases: Formatter

This formatter adds "[[" and "]]" to each word entered and adds two line breaks at the beginning and end.

FormatterRelatedNoteOpMkHeader

Bases: FormatterRelatedNoteInline

This formatter adds "[[" and "]]" to each word entered and adds two line breaks at the beginning and end.

FormatterRelatedNoteYaml

Bases: Formatter

This formatter adds "[[" and "]]" to each word entered and convert to list.

FormatterTagInline

Bases: Formatter

This formatter adds "#" to each word entered and adds two line breaks at the beginning and end.

FormatterTagOpMkHeader

Bases: FormatterTagInline

This formatter adds "#" to each word entered and adds two line breaks at the beginning and end.

FormatterYaml

Bases: Formatter

This formatter just converts the content to list.