Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown display of lists is broken on nightly #38275

Closed
pdeffebach opened this issue Nov 2, 2020 · 3 comments · Fixed by #38502
Closed

Markdown display of lists is broken on nightly #38275

pdeffebach opened this issue Nov 2, 2020 · 3 comments · Fixed by #38502
Labels
markdown regression Regression in behavior compared to a previous version
Milestone

Comments

@pdeffebach
Copy link
Contributor

It looks like this on nightly

Screenshot from 2020-11-02 10-01-14

and this on 1.5.0

Screenshot from 2020-11-02 10-01-47

To reproduce,

t = md"""

1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla gravida elit ut consectetur congue. Vivamus vestibulum et orci eu venenatis. Fusce enim mauris, fringilla non enim quis, facilisis efficitur velit. Etiam tempor fringilla dolor nec ornare. Nam dictum magna eu imperdiet fermentum. Morbi nec libero fermentum, placerat erat eu, interdum turpis. Aliquam ornare nisl sit amet nisi imperdiet, ac venenatis mauris posuere.
2. Vestibulum quis nibh at erat faucibus efficitur. Pellentesque finibus elit odio, ac elementum enim laoreet at. Cras ac est vel turpis finibus malesuada et ut nulla. Cras finibus id nulla dictum blandit. Duis tristique tortor nec est fermentum, ac auctor odio egestas. Quisque velit diam, auctor nec dictum non, dapibus sed est. Quisque vel libero vitae ligula euismod tempus sit amet ac augue. Ut feugiat diam a leo feugiat, nec mollis dui placerat. Donec at purus in libero pellentesque auctor id quis dui. Phasellus sodales rutrum porta. In eleifend eleifend ligula, et maximus quam tincidunt sit amet. Suspendisse ut consectetur turpis, non hendrerit nunc. Maecenas pulvinar elementum leo vitae lacinia. Integer auctor nisi non purus pretium posuere. Praesent tempus rutrum justo, vel commodo velit facilisis a.
3. Vivamus eu sodales massa. Nullam est est, dapibus non tristique id, imperdiet a orci. Donec dictum eu lectus nec feugiat. Suspendisse iaculis eu massa sagittis efficitur. Sed gravida, purus vitae blandit rhoncus, arcu nulla semper metus, vitae aliquam elit enim at lorem. Aenean vitae volutpat sapien. Suspendisse bibendum risus sed magna malesuada porttitor. Vivamus faucibus ante felis, a aliquet dui iaculis nec. Donec hendrerit, metus ut vehicula luctus, mauris diam aliquet ligula, a dictum enim libero vitae justo. Phasellus ante orci, viverra non iaculis ac, maximus sed urna. Integer purus erat, interdum a ante id, sollicitudin pellentesque mauris. Maecenas dapibus dictum sem. Phasellus lacinia dui at vestibulum sollicitudin. Nam cursus, est ac eleifend viverra, leo magna pretium dui, vitae pulvinar nisl enim vitae elit.
4. Sed volutpat, risus a pharetra suscipit, urna magna dignissim velit, id posuere mauris erat ut diam. Pellentesque feugiat, sapien ac dignissim consectetur, risus leo accumsan mi, vitae fermentum lacus tellus vel erat. In id metus lectus. Integer et tincidunt libero. Phasellus luctus metus tortor. Phasellus viverra fermentum gravida. Fusce non diam in metus dictum tempus quis vel leo. Vestibulum imperdiet tincidunt arcu a porttitor. Integer pulvinar ultrices orci, a lobortis ligula faucibus vel. Aliquam non velit aliquam, finibus massa ac, pretium libero.
5. Vivamus vel ipsum lacus. Vestibulum congue elit sed ultrices lacinia. Maecenas posuere magna varius libero hendrerit, ut gravida nunc ultricies. Maecenas dignissim in nunc at sagittis. Duis in arcu placerat, posuere tortor nec, varius leo. Donec vulputate ante vel quam ornare, a ornare sapien auctor. Duis consectetur ex ac arcu pulvinar, eget scelerisque lacus ultricies. Vestibulum sollicitudin luctus mauris, et tristique enim tristique in. Nulla vitae felis volutpat, ornare velit id, laoreet nulla. Curabitur viverra hendrerit lacinia. Sed sed eleifend odio. Etiam condimentum auctor neque id consequat. Maecenas suscipit urna massa, at consequat ex scelerisque non. Quisque nisi nulla, laoreet vitae scelerisque vel, congue eget lectus.
"""
@KristofferC
Copy link
Member

#37235 might not have been enough of a fix.

@KristofferC KristofferC added the regression Regression in behavior compared to a previous version label Nov 2, 2020
@KristofferC KristofferC added this to the 1.6 features milestone Nov 2, 2020
@timholy
Copy link
Member

timholy commented Nov 9, 2020

Actually, #37235 made it worse. Here's what you get if you revert that:
image

@timholy
Copy link
Member

timholy commented Nov 9, 2020

Reverting that and then adding this diff:

diff --git a/stdlib/Markdown/src/render/terminal/formatting.jl b/stdlib/Markdown/src/render/terminal/formatting.jl
index 5fa4eae249..4fd1cccedf 100644
--- a/stdlib/Markdown/src/render/terminal/formatting.jl
+++ b/stdlib/Markdown/src/render/terminal/formatting.jl
@@ -13,16 +13,13 @@ function wrapped_lines!(lines, io::IO, s::AbstractString, width, i)
     ws = words(s)
     for word in ws
         word_length = ansi_length(word)
-        if i + word_length + 1 > width
+        word_length == 0 && continue
+        if isempty(lines) || i + word_length + 1 > width
             i = word_length
             push!(lines, word)
         else
             i += word_length + 1
-            if isempty(lines)
-                push!(lines, word)
-            else
-                lines[end] *= " " * word   # this could be more efficient
-            end
+            lines[end] *= " " * word   # this could be more efficient
         end
     end
     return i

Almost gets you there (off by one space):

image

But from the screenshot above it looks like 1.5 is off by one space on the first line.

timholy added a commit that referenced this issue Nov 19, 2020
This changes one test, but IMO the extra spaces in the test result are
not actually desirable. The alignment on Julia 1.5 is also off-by-one,
whereas this seems well-aligned.
dkarrasch pushed a commit that referenced this issue Dec 2, 2020
* Revert "fix markdown rendering (#37235)"

This reverts commit 36505aa.

* Fix Markdown word-wrap (fixes #38275)

This changes one test, but IMO the extra spaces in the test result are
not actually desirable. The alignment on Julia 1.5 is also off-by-one,
whereas this seems well-aligned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
markdown regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants