Skip to content

markdown_formatter

appimage_updater.ui.output.markdown_formatter

Markdown output formatter implementation with GitHub-compatible syntax.

LATEX_SPECIAL_CHARS = {'&': '\\&', '%': '\\%', '$': '\\$', '#': '\\#', '_': '\\_', '{': '\\{', '}': '\\}', '~': '\\textasciitilde{}', '^': '\\textasciicircum{}', '\\': '\\textbackslash{}'} module-attribute

MarkdownOutputFormatter(**_kwargs)

Markdown output formatter for GitHub-compatible markdown output.

This formatter provides markdown output with GitHub-compatible syntax, including support for tables, colored text using \(\(\color{color-name}{}\)\), and proper markdown formatting.

Parameters:

Name Type Description Default
**_kwargs Any

Additional arguments (ignored for compatibility)

{}
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def __init__(self, **_kwargs: Any):
    """Initialize the markdown formatter.

    Args:
        **_kwargs: Additional arguments (ignored for compatibility)
    """
    self._current_section: str | None = None
    self._output_lines: list[str] = []

end_section()

End the current output section.

Source code in src/appimage_updater/ui/output/markdown_formatter.py
def end_section(self) -> None:
    """End the current output section."""
    if self._current_section:
        print()
        self._output_lines.append("")
        self._current_section = None

finalize()

Finalize markdown output and return complete content.

Returns:

Type Description
str | None

Complete markdown document as string

Source code in src/appimage_updater/ui/output/markdown_formatter.py
def finalize(self) -> str | None:
    """Finalize markdown output and return complete content.

    Returns:
        Complete markdown document as string
    """
    return "\n".join(self._output_lines) if self._output_lines else None

print_application_details(app_details)

Display application details in structured format (matching Rich panels).

Parameters:

Name Type Description Default
app_details dict[str, Any]

Dictionary containing application details

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_application_details(self, app_details: dict[str, Any]) -> None:
    """Display application details in structured format (matching Rich panels).

    Args:
        app_details: Dictionary containing application details
    """
    app_name = app_details.get("name", "Unknown")
    self._print_app_title(app_name)
    self._print_config_section(app_details, app_name)
    self._print_files_section(app_details)
    self._print_symlinks_section(app_details)

print_application_list(applications)

Display application list as markdown table.

Parameters:

Name Type Description Default
applications list[dict[str, Any]]

List of application dictionaries

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_application_list(self, applications: list[dict[str, Any]]) -> None:
    """Display application list as markdown table.

    Args:
        applications: List of application dictionaries
    """
    # Use custom headers to match Rich format
    headers = ["Application", "Status", "Source", "Download Directory"]
    self.print_table(applications, title="Configured Applications", headers=headers)

print_check_results(results)

Display check results as markdown table.

Parameters:

Name Type Description Default
results list[dict[str, Any]]

List of check result dictionaries

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_check_results(self, results: list[dict[str, Any]]) -> None:
    """Display check results as markdown table.

    Args:
        results: List of check result dictionaries
    """
    self.print_table(results, title="Update Check Results")

print_config_settings(settings)

Display configuration settings as markdown.

Parameters:

Name Type Description Default
settings dict[str, Any]

Dictionary of configuration settings

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_config_settings(self, settings: dict[str, Any]) -> None:
    """Display configuration settings as markdown.

    Args:
        settings: Dictionary of configuration settings
    """
    title = "\n## Configuration Settings\n"
    print(title)
    self._output_lines.append(title)

    for key, value in settings.items():
        # Check if key contains display name and setting name separated by |
        if "|" in key:
            display_name, setting_name = key.split("|", 1)
            line = f"- **{display_name}** *({setting_name})*: {value}"
        else:
            line = f"- **{key}:** {value}"
        print(line)
        self._output_lines.append(line)

    print()
    self._output_lines.append("")

print_error(message)

Display error message with red color.

Parameters:

Name Type Description Default
message str

Error message to display

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_error(self, message: str) -> None:
    """Display error message with red color.

    Args:
        message: Error message to display
    """
    formatted = f"$$\\color{{red}}{{✗ ERROR: {self._escape_latex(message)}}}$$"
    print(formatted)
    self._output_lines.append(formatted)

print_info(message)

Display info message with cyan color (matching Rich formatter).

Parameters:

Name Type Description Default
message str

Info message to display

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_info(self, message: str) -> None:
    """Display info message with cyan color (matching Rich formatter).

    Args:
        message: Info message to display
    """
    formatted = f"$$\\color{{cyan}}\\text{{{self._escape_latex(message)}}}$$"
    print(formatted)
    self._output_lines.append(formatted)

print_message(message, **kwargs)

Write a message as markdown text.

Parameters:

Name Type Description Default
message str

The message to write

required
**kwargs Any

Additional options (color, bold, etc.)

{}
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_message(self, message: str, **kwargs: Any) -> None:
    """Write a message as markdown text.

    Args:
        message: The message to write
        **kwargs: Additional options (color, bold, etc.)
    """
    formatted_message = self._format_text(message, **kwargs)
    print(formatted_message)
    self._output_lines.append(formatted_message)

print_progress(current, total, description='')

Display progress information as markdown.

Parameters:

Name Type Description Default
current int

Current progress value

required
total int

Total progress value

required
description str

Optional progress description

''
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_progress(self, current: int, total: int, description: str = "") -> None:
    """Display progress information as markdown.

    Args:
        current: Current progress value
        total: Total progress value
        description: Optional progress description
    """
    percentage = (current / total * 100) if total > 0 else 0
    # Format as list items for markdown
    progress_text = f"[{current}/{total}] ({percentage:.1f}%)"
    if description:
        progress_text = f"{description}: {progress_text}"
    # Add list item prefix
    formatted = f"- {progress_text}"
    print(formatted)
    self._output_lines.append(formatted)

print_success(message)

Display success message with green color.

Parameters:

Name Type Description Default
message str

Success message to display

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_success(self, message: str) -> None:
    """Display success message with green color.

    Args:
        message: Success message to display
    """
    formatted = f"$$\\color{{green}}{{{self._escape_latex(message)}}}$$"
    print(formatted)
    self._output_lines.append(formatted)

print_table(data, title='', headers=None)

Display tabular data as markdown table with colored columns.

Parameters:

Name Type Description Default
data list[dict[str, Any]]

List of dictionaries representing table rows

required
title str

Optional table title

''
headers list[str] | None

Optional custom headers

None
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_table(self, data: list[dict[str, Any]], title: str = "", headers: list[str] | None = None) -> None:
    """Display tabular data as markdown table with colored columns.

    Args:
        data: List of dictionaries representing table rows
        title: Optional table title
        headers: Optional custom headers
    """
    if not data:
        return

    # Display title
    self._print_table_title(title)

    # Determine headers
    table_headers = headers or list(data[0].keys())
    if not table_headers:
        return

    # Build and print header rows
    header_row, separator_row = self._build_table_headers(table_headers)
    print(header_row)
    print(separator_row)
    self._output_lines.append(header_row)
    self._output_lines.append(separator_row)

    # Add data rows
    for row in data:
        row_line = self._build_table_row(row, table_headers)
        print(row_line)
        self._output_lines.append(row_line)

    # Add blank line after table
    print()
    self._output_lines.append("")

print_warning(message)

Display warning message with yellow color (matching Rich formatter).

Parameters:

Name Type Description Default
message str

Warning message to display

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def print_warning(self, message: str) -> None:
    """Display warning message with yellow color (matching Rich formatter).

    Args:
        message: Warning message to display
    """
    formatted = f"$$\\color{{yellow}}\\text{{{self._escape_latex(message)}}}$$"
    print(formatted)
    self._output_lines.append(formatted)

start_section(title)

Start a new output section with markdown heading.

Parameters:

Name Type Description Default
title str

Section title

required
Source code in src/appimage_updater/ui/output/markdown_formatter.py
def start_section(self, title: str) -> None:
    """Start a new output section with markdown heading.

    Args:
        title: Section title
    """
    self._current_section = title
    section_line = f"\n### {title}\n"
    print(section_line)
    self._output_lines.append(section_line)