Fix Markdown formatting of narrow table columns (#1430)

This commit is contained in:
Jonatan Kłosko 2022-09-22 21:10:51 +02:00 committed by GitHub
parent 5ade7f97e1
commit 12f77daa68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -353,6 +353,7 @@ defmodule Livebook.LiveMarkdown.MarkdownHelpers do
cells
|> Enum.map(&IO.iodata_length/1)
|> Enum.max()
|> max(3)
end)
end

View file

@ -205,8 +205,18 @@ defmodule Livebook.LiveMarkdown.MarkdownHelpersTest do
test "table without header" do
markdown = """
| Texas | TX | Austin |
| Maine | ME | Augusta |\
| Texas | TX | Austin |
| Maine | ME | Augusta |\
"""
assert markdown == reformat(markdown)
end
test "table with narrow column" do
markdown = """
| x | y | x and y |
| :-: | --- | ------- |
| 1 | 1 | 0 |\
"""
assert markdown == reformat(markdown)