|
272 | 272 | | L |
|
273 | 273 | """) == " │ Tables in admonitions\n │\n │ R\n │ –\n │ L"
|
274 | 274 |
|
| 275 | +# Issue #38275 |
| 276 | +function test_list_wrap(str, lenmin, lenmax) |
| 277 | + strs = split(str, '\n') |
| 278 | + l = length.(strs) |
| 279 | + for i = 1:length(l)-1 |
| 280 | + if l[i] != 0 && l[i+1] != 0 # the next line isn't blank, so this line should be "full" |
| 281 | + lenmin <= l[i] <= lenmax || return false |
| 282 | + else |
| 283 | + l[i] <= lenmax || return false # this line isn't too long (but there is no min) |
| 284 | + end |
| 285 | + end |
| 286 | + # Check consistent indentation |
| 287 | + rngs = findfirst.((". ",), strs) |
| 288 | + k = last(rngs[1]) |
| 289 | + rex = Regex('^' * " "^k * "\\w") |
| 290 | + for (i, rng) in enumerate(rngs) |
| 291 | + isa(rng, AbstractRange) && last(rng) == k && continue # every numbered line starts the text at the same position |
| 292 | + rng === nothing && (isempty(strs[i]) || match(rex, strs[i]) !== nothing) && continue # every unnumbered line is indented to text in numbered lines |
| 293 | + return false |
| 294 | + end |
| 295 | + return true |
| 296 | +end |
| 297 | + |
| 298 | +let doc = |
| 299 | + md""" |
| 300 | + 1. a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij |
| 301 | + 2. a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij a bc def ghij |
| 302 | + """ |
| 303 | + str = sprint(term, doc, 50) |
| 304 | + @test test_list_wrap(str, 40, 50) |
| 305 | + str = sprint(term, doc, 60) |
| 306 | + @test test_list_wrap(str, 50, 60) |
| 307 | + str = sprint(term, doc, 80) |
| 308 | + @test test_list_wrap(str, 70, 80) |
| 309 | +end |
| 310 | + |
275 | 311 | # HTML output
|
276 | 312 | @test md"foo *bar* baz" |> html == "<p>foo <em>bar</em> baz</p>\n"
|
277 | 313 | @test md"something ***" |> html == "<p>something ***</p>\n"
|
@@ -340,7 +376,7 @@ table = md"""
|
340 | 376 | # mime output
|
341 | 377 | let out =
|
342 | 378 | @test sprint(show, "text/plain", book) ==
|
343 |
| - " Title\n ≡≡≡≡≡≡≡\n\n Some discussion\n\n │ A quote\n\n Section important\n ===================\n\n Some bolded\n\n • list1\n\n • list2" |
| 379 | + " Title\n ≡≡≡≡≡≡≡\n\n Some discussion\n\n │ A quote\n\n Section important\n ===================\n\n Some bolded\n\n • list1\n\n • list2" |
344 | 380 | @test sprint(show, "text/markdown", book) ==
|
345 | 381 | """
|
346 | 382 | # Title
|
@@ -1177,11 +1213,3 @@ end
|
1177 | 1213 | | $x |
|
1178 | 1214 | """)
|
1179 | 1215 | end
|
1180 |
| - |
1181 |
| -@testset "issue #37232: linebreaks" begin |
1182 |
| - s = @md_str """ |
1183 |
| - Misc:\\ |
1184 |
| - - line\\ |
1185 |
| - """ |
1186 |
| - @test sprint(show, MIME("text/plain"), s) == " Misc:\n - line\n " |
1187 |
| -end |
|
0 commit comments