Skip to content

Commit

Permalink
Merge pull request #17 from abbrev/fix-text-width
Browse files Browse the repository at this point in the history
Change maximum text width to 69 characters
  • Loading branch information
michael-lazar authored Jan 22, 2025
2 parents a9ecc45 + 4fe0cf4 commit 9dc1e4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion demo/demo.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ SECRET_KEY = '%dD.AJN89-+isd?b8ycbDA'
GOPHER_SHOW_STACK_TRACE = True

# Maximum line width for gopher menu pages
GOPHER_WIDTH = 70
GOPHER_WIDTH = 69
6 changes: 3 additions & 3 deletions flask_gopher/flask_gopher.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TextFormatter:
Helper methods for applying formatting techniques to gopher menu text.
"""

def __init__(self, default_width=70):
def __init__(self, default_width=69):
self.default_width = default_width

def banner(self, text, ch="=", side="-", width=None):
Expand Down Expand Up @@ -379,7 +379,7 @@ class GopherExtension:
</HTML>
"""

DEFAULT_WIDTH = 70
DEFAULT_WIDTH = 69

def __init__(self, app=None, menu_class=GopherMenu, formatter_class=TextFormatter):
self.show_stack_trace = None
Expand Down Expand Up @@ -754,7 +754,7 @@ def __init__(
view_name,
url_token="filename",
show_timestamp=False,
width=70,
width=69,
):
"""
Args:
Expand Down
18 changes: 9 additions & 9 deletions tests/test_flask_gopher.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ def test_isolated_requests(self):

class TestTextFormatter(unittest.TestCase):
def setUp(self):
self.formatter = TextFormatter(default_width=70)
self.formatter = TextFormatter(default_width=69)

def test_banner_normal(self):
output = self.formatter.banner("BANNER")
lines = output.splitlines()
self.assertEqual(len(lines), 3)
self.assertTrue(all(len(line) == 70 for line in lines))
self.assertTrue(all(len(line) == 69 for line in lines))
self.assertEqual(lines[1][0], "-")
self.assertEqual(lines[1][-1], "-")

Expand All @@ -514,21 +514,21 @@ def test_banner_custom_ch(self):

def test_banner_no_border(self):
output = self.formatter.banner("BANNER", ch="", side="")
self.assertEqual(output, "BANNER".center(70))
self.assertEqual(output, "BANNER".center(69))

def test_wrap(self):
text = "f" * 100 + "\n" + "g" * 100
output = self.formatter.wrap(text, indent="**")
lines = output.splitlines()
self.assertEqual(len(lines), 4)
self.assertEqual(max(len(line) for line in lines), 70)
self.assertEqual(max(len(line) for line in lines), 69)
self.assertTrue(all(line.startswith("**") for line in lines))

def test_center(self):
text = "line 1\nlonger line 2\n"
output = self.formatter.center(text, fillchar="_")
lines = output.splitlines()
self.assertTrue(all(len(line) == 70 for line in lines))
self.assertTrue(all(len(line) == 69 for line in lines))
self.assertTrue(lines[0].startswith("_"))
self.assertTrue(lines[1].startswith("_"))
self.assertTrue(lines[0].endswith("_"))
Expand All @@ -538,7 +538,7 @@ def test_rjust(self):
text = "line 1\nlonger line 2\n"
output = self.formatter.rjust(text, fillchar="_")
lines = output.splitlines()
self.assertTrue(all(len(line) == 70 for line in lines))
self.assertTrue(all(len(line) == 69 for line in lines))
self.assertTrue(lines[0].startswith("_"))
self.assertTrue(lines[1].startswith("_"))
self.assertTrue(lines[0].endswith("_line 1"))
Expand All @@ -548,7 +548,7 @@ def test_ljust(self):
text = "line 1\nlonger line 2\n"
output = self.formatter.ljust(text, fillchar="_")
lines = output.splitlines()
self.assertTrue(all(len(line) == 70 for line in lines))
self.assertTrue(all(len(line) == 69 for line in lines))
self.assertTrue(lines[0].startswith("line 1_"))
self.assertTrue(lines[1].startswith("longer line 2_"))
self.assertTrue(lines[0].endswith("_"))
Expand All @@ -559,7 +559,7 @@ def test_float_right(self):
right = "right line 1"
output = self.formatter.float_right(left, right, fillchar="_")
lines = output.splitlines()
self.assertTrue(all(len(line) == 70 for line in lines))
self.assertTrue(all(len(line) == 69 for line in lines))
self.assertTrue(lines[0].startswith("left line 1_"))
self.assertTrue(lines[1].startswith("left line 2_"))
self.assertTrue(lines[0].endswith("_right line 1"))
Expand All @@ -578,7 +578,7 @@ def test_figlet(self):
output = self.formatter.figlet("foobar", font="alpha")
lines = output.splitlines()
self.assertGreater(len(lines), 1)
self.assertTrue(all(len(line) <= 70 for line in lines))
self.assertTrue(all(len(line) <= 69 for line in lines))

def test_underline(self):
output = self.formatter.underline("Super Duper")
Expand Down

0 comments on commit 9dc1e4e

Please sign in to comment.