cornsnake.util_markdown_table

Generating Markdown content. Functions like adding row separators, generating Markdown images, and generating italicized text are included.

Documentation

 1"""
 2Generating Markdown content. Functions like adding row separators, generating Markdown images, and generating italicized text are included.
 3
 4[Documentation](http://docs.mrseanryan.cornsnake.s3-website-eu-west-1.amazonaws.com/cornsnake/util_markdown_table.html)
 5"""
 6
 7MARKDOWN_COLUMN_SEPARATOR = "|"
 8MARKDOWN_COLUMN_INDICATOR = "---"
 9
10
11def add_row_separator(column_count):
12    """
13    Function to add row separators for a Markdown table.
14
15    Args:
16    column_count (int): The number of columns in the table.
17
18    Returns:
19    str: The row separator string for the table.
20    """
21    row = MARKDOWN_COLUMN_SEPARATOR
22    while column_count > 0:
23        row += MARKDOWN_COLUMN_INDICATOR + MARKDOWN_COLUMN_SEPARATOR
24        column_count -= 1
25    return row
26
27
28def generate_markdown_image(path_to_image, caption):
29    """
30    Function to generate Markdown image syntax.
31
32    Args:
33    path_to_image (str): The path to the image file.
34    caption (str): The caption for the image.
35
36    Returns:
37    str: The Markdown image syntax.
38    """
39    return f'![{caption}]({path_to_image} "{caption}" )'
40
41
42def generate_italicised(text):
43    """
44    Function to generate italicized text in Markdown.
45
46    Args:
47    text (str): The text to be italicized.
48
49    Returns:
50    str: The italicized text.
51    """
52    return f"*{text}*"
MARKDOWN_COLUMN_SEPARATOR = '|'
MARKDOWN_COLUMN_INDICATOR = '---'
def add_row_separator(column_count):
12def add_row_separator(column_count):
13    """
14    Function to add row separators for a Markdown table.
15
16    Args:
17    column_count (int): The number of columns in the table.
18
19    Returns:
20    str: The row separator string for the table.
21    """
22    row = MARKDOWN_COLUMN_SEPARATOR
23    while column_count > 0:
24        row += MARKDOWN_COLUMN_INDICATOR + MARKDOWN_COLUMN_SEPARATOR
25        column_count -= 1
26    return row

Function to add row separators for a Markdown table.

Args: column_count (int): The number of columns in the table.

Returns: str: The row separator string for the table.

def generate_markdown_image(path_to_image, caption):
29def generate_markdown_image(path_to_image, caption):
30    """
31    Function to generate Markdown image syntax.
32
33    Args:
34    path_to_image (str): The path to the image file.
35    caption (str): The caption for the image.
36
37    Returns:
38    str: The Markdown image syntax.
39    """
40    return f'![{caption}]({path_to_image} "{caption}" )'

Function to generate Markdown image syntax.

Args: path_to_image (str): The path to the image file. caption (str): The caption for the image.

Returns: str: The Markdown image syntax.

def generate_italicised(text):
43def generate_italicised(text):
44    """
45    Function to generate italicized text in Markdown.
46
47    Args:
48    text (str): The text to be italicized.
49
50    Returns:
51    str: The italicized text.
52    """
53    return f"*{text}*"

Function to generate italicized text in Markdown.

Args: text (str): The text to be italicized.

Returns: str: The italicized text.