mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-03 18:35:41 +08:00
Fix markdown line breaks rendering (#227)
This commit is contained in:
parent
6b5de9eda5
commit
44eda43d02
2 changed files with 14 additions and 0 deletions
|
@ -99,6 +99,12 @@ defmodule Livebook.LiveMarkdown.MarkdownHelpers do
|
|||
|> build_md(ast)
|
||||
end
|
||||
|
||||
defp build_md(iodata, [{"br", _, [], %{}} | ast]) do
|
||||
render_line_break()
|
||||
|> append_inline(iodata)
|
||||
|> build_md(ast)
|
||||
end
|
||||
|
||||
defp build_md(iodata, [{"p", _, content, %{}} | ast]) do
|
||||
render_paragraph(content)
|
||||
|> append_block(iodata)
|
||||
|
@ -225,6 +231,8 @@ defmodule Livebook.LiveMarkdown.MarkdownHelpers do
|
|||
end
|
||||
end
|
||||
|
||||
defp render_line_break(), do: "\\\n"
|
||||
|
||||
defp render_paragraph(content), do: markdown_from_ast(content)
|
||||
|
||||
defp render_heading(n, content) do
|
||||
|
|
|
@ -98,6 +98,9 @@ defmodule Livebook.LiveMarkdown.ImportTest do
|
|||
|
||||
## Section 1
|
||||
|
||||
Line 1.\s\s
|
||||
Line 2.
|
||||
|
||||
|State|Abbrev|Capital|
|
||||
| --: | :-: | --- |
|
||||
| Texas | TX | Austin |
|
||||
|
@ -117,6 +120,9 @@ defmodule Livebook.LiveMarkdown.ImportTest do
|
|||
type: :markdown,
|
||||
metadata: %{},
|
||||
source: """
|
||||
Line 1.\\
|
||||
Line 2.
|
||||
|
||||
| State | Abbrev | Capital |
|
||||
| ----: | :----: | ------- |
|
||||
| Texas | TX | Austin |
|
||||
|
|
Loading…
Reference in a new issue