mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-12 14:36:20 +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)
|
|> build_md(ast)
|
||||||
end
|
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
|
defp build_md(iodata, [{"p", _, content, %{}} | ast]) do
|
||||||
render_paragraph(content)
|
render_paragraph(content)
|
||||||
|> append_block(iodata)
|
|> append_block(iodata)
|
||||||
|
@ -225,6 +231,8 @@ defmodule Livebook.LiveMarkdown.MarkdownHelpers do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp render_line_break(), do: "\\\n"
|
||||||
|
|
||||||
defp render_paragraph(content), do: markdown_from_ast(content)
|
defp render_paragraph(content), do: markdown_from_ast(content)
|
||||||
|
|
||||||
defp render_heading(n, content) do
|
defp render_heading(n, content) do
|
||||||
|
|
|
@ -98,6 +98,9 @@ defmodule Livebook.LiveMarkdown.ImportTest do
|
||||||
|
|
||||||
## Section 1
|
## Section 1
|
||||||
|
|
||||||
|
Line 1.\s\s
|
||||||
|
Line 2.
|
||||||
|
|
||||||
|State|Abbrev|Capital|
|
|State|Abbrev|Capital|
|
||||||
| --: | :-: | --- |
|
| --: | :-: | --- |
|
||||||
| Texas | TX | Austin |
|
| Texas | TX | Austin |
|
||||||
|
@ -117,6 +120,9 @@ defmodule Livebook.LiveMarkdown.ImportTest do
|
||||||
type: :markdown,
|
type: :markdown,
|
||||||
metadata: %{},
|
metadata: %{},
|
||||||
source: """
|
source: """
|
||||||
|
Line 1.\\
|
||||||
|
Line 2.
|
||||||
|
|
||||||
| State | Abbrev | Capital |
|
| State | Abbrev | Capital |
|
||||||
| ----: | :----: | ------- |
|
| ----: | :----: | ------- |
|
||||||
| Texas | TX | Austin |
|
| Texas | TX | Austin |
|
||||||
|
|
Loading…
Add table
Reference in a new issue