diff --git a/docs/source/styles.rst b/docs/source/styles.rst index 449703a..eb2df1f 100644 --- a/docs/source/styles.rst +++ b/docs/source/styles.rst @@ -135,6 +135,52 @@ Preset styles 2 | 30 40 35 30 ----------------------- +.. _PresetStyle.ascii_rounded: + +`ascii_rounded` +~~~~~~~~~~~~~~~ + +.. code-block:: none + + /=============================\ + | # | G H R S | + |=====|=======================| + | 1 | 30 40 35 30 | + |-----|-----------------------| + | 2 | 30 40 35 30 | + |=====|=======================| + | SUM | 130 140 135 130 | + \=====|=======================/ + + /=======================\ + | 1 | 30 40 35 30 | + |---|-------------------| + | 2 | 30 40 35 30 | + \===|===================/ + +.. _PresetStyle.ascii_rounded_box: + +`ascii_rounded_box` +~~~~~~~~~~~~~~~~~~~ + +.. code-block:: none + + /=============================\ + | # | G | H | R | S | + |=====|=====|=====|=====|=====| + | 1 | 30 | 40 | 35 | 30 | + |-----|-----|-----|-----|-----| + | 2 | 30 | 40 | 35 | 30 | + |=====|=====|=====|=====|=====| + | SUM | 130 | 140 | 135 | 130 | + \=====|=====|=====|=====|=====/ + + /=======================\ + | 1 | 30 | 40 | 35 | 30 | + |---|----|----|----|----| + | 2 | 30 | 40 | 35 | 30 | + \===|====|====|====|====/ + .. _PresetStyle.ascii_simple: `ascii_simple` diff --git a/table2ascii/preset_style.py b/table2ascii/preset_style.py index dcfdcc1..929b11c 100644 --- a/table2ascii/preset_style.py +++ b/table2ascii/preset_style.py @@ -43,4 +43,6 @@ class PresetStyle: ascii_minimalist = TableStyle.from_string(" --- | === --- -- ") ascii_borderless = TableStyle.from_string(" | - ") ascii_simple = TableStyle.from_string(" = | = ") + ascii_rounded = TableStyle.from_string("/===\|| |=|=||-|-|\|=/") + ascii_rounded_box = TableStyle.from_string("/===\||||=||||-|||\||/") markdown = TableStyle.from_string(" ||||-||| ") diff --git a/tests/test_styles.py b/tests/test_styles.py index 5c7464d..30e1670 100644 --- a/tests/test_styles.py +++ b/tests/test_styles.py @@ -563,6 +563,52 @@ def test_ascii_borderless(): assert text == expected +def test_ascii_rounded(): + text = t2a( + header=["#", "G", "H", "R", "S"], + body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]], + footer=["SUM", "130", "140", "135", "130"], + first_col_heading=True, + last_col_heading=False, + style=PresetStyle.ascii_rounded, + ) + expected = ( + "/=============================\\\n" + "| # | G H R S |\n" + "|=====|=======================|\n" + "| 1 | 30 40 35 30 |\n" + "|-----|-----------------------|\n" + "| 2 | 30 40 35 30 |\n" + "|=====|=======================|\n" + "| SUM | 130 140 135 130 |\n" + "\\=====|=======================/" + ) + assert text == expected + + +def test_ascii_rounded_box(): + text = t2a( + header=["#", "G", "H", "R", "S"], + body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]], + footer=["SUM", "130", "140", "135", "130"], + first_col_heading=True, + last_col_heading=False, + style=PresetStyle.ascii_rounded_box, + ) + expected = ( + "/=============================\\\n" + "| # | G | H | R | S |\n" + "|=====|=====|=====|=====|=====|\n" + "| 1 | 30 | 40 | 35 | 30 |\n" + "|-----|-----|-----|-----|-----|\n" + "| 2 | 30 | 40 | 35 | 30 |\n" + "|=====|=====|=====|=====|=====|\n" + "| SUM | 130 | 140 | 135 | 130 |\n" + "\\=====|=====|=====|=====|=====/" + ) + assert text == expected + + def test_ascii_simple(): text = t2a( header=["#", "G", "H", "R", "S"],