Commit 5958402
committed
Audit code cells for unwrappable lines; fix three offenders + safety net
User-flagged: /examples/testing showed a horizontal scrollbar inside
a walkthrough code cell. Root cause: white-space: pre-wrap wraps at
spaces, but the line
suite = unittest.defaultTestLoader.loadTestsFromTestCase(AddTests)
contains a 58-char run after the first space that pre-wrap can't
break. Same pattern in two other examples.
TDD:
RED — Contract 12 in tests/test_example_content.py
(CellCodeWrappingContract) flags any \\S-run > 50 chars in
walkthrough cell code. Pre-fix output:
logging cell 0 line 6: 68-char run
handler.setFormatter(logging.Formatter("%(levelname)s:%(message)s"))
testing cell 2 line 2: 58-char run
unittest.defaultTestLoader.loadTestsFromTestCase(AddTests)
datetime cell 2 line 1: 51-char run
datetime.fromisoformat("2026-05-04T12:30:00+00:00")
GREEN — introduce intermediate names so each line wraps cleanly:
testing.md
loader = unittest.defaultTestLoader
suite = loader.loadTestsFromTestCase(AddTests)
...
runner = unittest.TextTestRunner(stream=stream, verbosity=0)
result = runner.run(suite)
logging.md
formatter = logging.Formatter("%(levelname)s:%(message)s")
handler.setFormatter(formatter)
datetime.md
iso_text = "2026-05-04T12:30:00+00:00"
parsed = datetime.fromisoformat(iso_text)
Each :::program block and the matching :::cell block updated
together so the runnable code and the walkthrough stay in sync.
CSS safety net (public/site.css): added `overflow-wrap: anywhere`
to `.cell-source pre, .cell-source .shiki-block, .cell-output pre`.
A future long URL, long string literal, or long encoded blob will
break mid-run instead of pushing a horizontal scrollbar onto the
page. Code that's authored to wrap cleanly (the rule above keeps it
authored well) will still wrap at spaces because pre-wrap takes
precedence over overflow-wrap when both apply.
59 tests pass; SEO/cache lint clears 110 pages.1 parent dceb834 commit 5958402
7 files changed
Lines changed: 56 additions & 12 deletions
File tree
- public
- src
- example_sources
- tests
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
114 | | - | |
| 116 | + | |
| 117 | + | |
115 | 118 | | |
116 | | - | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
79 | 115 | | |
80 | 116 | | |
0 commit comments