Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions docs/source/styles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions table2ascii/preset_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ||||-||| ")
46 changes: 46 additions & 0 deletions tests/test_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down