# Path: terminaltables/github_table.py
# class GithubFlavoredMarkdownTable(AsciiTable):
#     """Github flavored markdown table.
# 
#     https://help.github.com/articles/github-flavored-markdown/#tables
# 
#     :ivar iter table_data: List (empty or list of lists of strings) representing the table.
#     :ivar dict justify_columns: Horizontal justification. Keys are column indexes (int). Values are right/left/center.
#     """
# 
#     def __init__(self, table_data):
#         """Constructor.
# 
#         :param iter table_data: List (empty or list of lists of strings) representing the table.
#         """
#         # Github flavored markdown table won't support title.
#         super(GithubFlavoredMarkdownTable, self).__init__(table_data)
# 
#     def horizontal_border(self, _, outer_widths):
#         """Handle the GitHub heading border.
# 
#         E.g.:
#         |:---|:---:|---:|----|
# 
#         :param _: Unused.
#         :param iter outer_widths: List of widths (with padding) for each column.
# 
#         :return: Prepared border strings in a generator.
#         :rtype: iter
#         """
#         horizontal = str(self.CHAR_INNER_HORIZONTAL)
#         left = self.CHAR_OUTER_LEFT_VERTICAL
#         intersect = self.CHAR_INNER_VERTICAL
#         right = self.CHAR_OUTER_RIGHT_VERTICAL
# 
#         columns = list()
#         for i, width in enumerate(outer_widths):
#             justify = self.justify_columns.get(i)
#             width = max(3, width)  # Width should be at least 3 so justification can be applied.
#             if justify == 'left':
#                 columns.append(':' + horizontal * (width - 1))
#             elif justify == 'right':
#                 columns.append(horizontal * (width - 1) + ':')
#             elif justify == 'center':
#                 columns.append(':' + horizontal * (width - 2) + ':')
#             else:
#                 columns.append(horizontal * width)
# 
#         return combine(columns, left, intersect, right)
# 
#     def gen_table(self, inner_widths, inner_heights, outer_widths):
#         """Combine everything and yield every line of the entire table with borders.
# 
#         :param iter inner_widths: List of widths (no padding) for each column.
#         :param iter inner_heights: List of heights (no padding) for each row.
#         :param iter outer_widths: List of widths (with padding) for each column.
#         :return:
#         """
#         for i, row in enumerate(self.table_data):
#             # Yield the row line by line (e.g. multi-line rows).
#             for line in self.gen_row_lines(row, 'row', inner_widths, inner_heights[i]):
#                 yield line
#             # Yield heading separator.
#             if i == 0:
#                 yield self.horizontal_border(None, outer_widths)


from terminaltables import GithubFlavoredMarkdownTable
        ['Lettuce', 'green', 'vegetable'],
        ['Watermelon', 'green'],
        [],
    ]
    table = GithubFlavoredMarkdownTable(table_data)
    table.inner_footing_row_border = True
    table.justify_columns[0] = 'left'
    table.justify_columns[1] = 'center'
    table.justify_columns[2] = 'right'
    actual = table.table

    expected = (
        '| Name       | Color |      Type |\n'
        '|:-----------|:-----:|----------:|\n'
        '| Avocado    | green |       nut |\n'
        '| Tomato     |  red  |     fruit |\n'
        '| Lettuce    | green | vegetable |\n'
        '| Watermelon | green |           |\n'
        '|            |       |           |'
    )
    assert actual == expected


def test_multi_line():
    """Test multi-lined cells."""
    table_data = [
        ['Show', 'Characters'],
        ['Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'],
        ['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
    ]

# Path: terminaltables/github_table.py
# class GithubFlavoredMarkdownTable(AsciiTable):
#     """Github flavored markdown table.
# 
#     https://help.github.com/articles/github-flavored-markdown/#tables
# 
#     :ivar iter table_data: List (empty or list of lists of strings) representing the table.
#     :ivar dict justify_columns: Horizontal justification. Keys are column indexes (int). Values are right/left/center.
#     """
# 
#     def __init__(self, table_data):
#         """Constructor.
# 
#         :param iter table_data: List (empty or list of lists of strings) representing the table.
#         """
#         # Github flavored markdown table won't support title.
#         super(GithubFlavoredMarkdownTable, self).__init__(table_data)
# 
#     def horizontal_border(self, _, outer_widths):
#         """Handle the GitHub heading border.
# 
#         E.g.:
#         |:---|:---:|---:|----|
# 
#         :param _: Unused.
#         :param iter outer_widths: List of widths (with padding) for each column.
# 
#         :return: Prepared border strings in a generator.
#         :rtype: iter
#         """
#         horizontal = str(self.CHAR_INNER_HORIZONTAL)
#         left = self.CHAR_OUTER_LEFT_VERTICAL
#         intersect = self.CHAR_INNER_VERTICAL
#         right = self.CHAR_OUTER_RIGHT_VERTICAL
# 
#         columns = list()
#         for i, width in enumerate(outer_widths):
#             justify = self.justify_columns.get(i)
#             width = max(3, width)  # Width should be at least 3 so justification can be applied.
#             if justify == 'left':
#                 columns.append(':' + horizontal * (width - 1))
#             elif justify == 'right':
#                 columns.append(horizontal * (width - 1) + ':')
#             elif justify == 'center':
#                 columns.append(':' + horizontal * (width - 2) + ':')
#             else:
#                 columns.append(horizontal * width)
# 
#         return combine(columns, left, intersect, right)
# 
#     def gen_table(self, inner_widths, inner_heights, outer_widths):
#         """Combine everything and yield every line of the entire table with borders.
# 
#         :param iter inner_widths: List of widths (no padding) for each column.
#         :param iter inner_heights: List of heights (no padding) for each row.
#         :param iter outer_widths: List of widths (with padding) for each column.
#         :return:
#         """
#         for i, row in enumerate(self.table_data):
#             # Yield the row line by line (e.g. multi-line rows).
#             for line in self.gen_row_lines(row, 'row', inner_widths, inner_heights[i]):
#                 yield line
#             # Yield heading separator.
#             if i == 0:
#                 yield self.horizontal_border(None, outer_widths)


# Path: tests/test_all_tables_e2e/test_github_table.py
from terminaltables import GithubFlavoredMarkdownTable

        ['Lettuce', 'green', 'vegetable'],
        ['Watermelon', 'green'],
        [],
    ]
    table = GithubFlavoredMarkdownTable(table_data)
    table.inner_footing_row_border = True
    table.justify_columns[0] = 'left'
    table.justify_columns[1] = 'center'
    table.justify_columns[2] = 'right'
    actual = table.table

    expected = (
        '| Name       | Color |      Type |\n'
        '|:-----------|:-----:|----------:|\n'
        '| Avocado    | green |       nut |\n'
        '| Tomato     |  red  |     fruit |\n'
        '| Lettuce    | green | vegetable |\n'
        '| Watermelon | green |           |\n'
        '|            |       |           |'
    )
    assert actual == expected


def test_multi_line():
    """Test multi-lined cells."""
    table_data = [
        ['Show', 'Characters'],
        ['Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'],
        ['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
    ]

    table = GithubFlavoredMarkdownTable(table_data)