diff --git a/lib/livebook/live_markdown/export.ex b/lib/livebook/live_markdown/export.ex index 146e75714..557f05278 100644 --- a/lib/livebook/live_markdown/export.ex +++ b/lib/livebook/live_markdown/export.ex @@ -321,7 +321,8 @@ defmodule Livebook.LiveMarkdown.Export do defp add_markdown_annotation_before_elixir_block(ast) do Enum.flat_map(ast, fn - {"pre", _, [{"code", [{"class", "elixir"}], [_source], %{}}], %{}} = ast_node -> + {"pre", _, [{"code", [{"class", language}], [_source], %{}}], %{}} = ast_node + when language in ["elixir", "erlang"] -> [{:comment, [], [~s/livebook:{"force_markdown":true}/], %{comment: true}}, ast_node] ast_node -> diff --git a/test/livebook/live_markdown/export_test.exs b/test/livebook/live_markdown/export_test.exs index ed9a94b40..c7e44ff8e 100644 --- a/test/livebook/live_markdown/export_test.exs +++ b/test/livebook/live_markdown/export_test.exs @@ -232,7 +232,7 @@ defmodule Livebook.LiveMarkdown.ExportTest do assert expected_document == document end - test "keeps non-elixir code snippets" do + test "keeps non-code cell snippets" do notebook = %{ Notebook.new() | name: "My Notebook", @@ -248,8 +248,8 @@ defmodule Livebook.LiveMarkdown.ExportTest do mix deps.get ``` - ```erlang - spawn_link(fun() -> io:format("Hiya") end). + ```json + {"x": 1, "y": 1} ``` """ } @@ -267,8 +267,8 @@ defmodule Livebook.LiveMarkdown.ExportTest do mix deps.get ``` - ```erlang - spawn_link(fun() -> io:format("Hiya") end). + ```json + {"x": 1, "y": 1} ``` """ @@ -277,7 +277,7 @@ defmodule Livebook.LiveMarkdown.ExportTest do assert expected_document == document end - test "marks elixir snippets in markdown cells as such" do + test "marks code cell snippets in markdown cells as such" do notebook = %{ Notebook.new() | name: "My Notebook", @@ -305,8 +305,8 @@ defmodule Livebook.LiveMarkdown.ExportTest do | source: """ Some markdown. - ```elixir - [1, 2, 3] + ```erlang + [1, 2, 3]. ```\ """ } @@ -332,8 +332,8 @@ defmodule Livebook.LiveMarkdown.ExportTest do - ```elixir - [1, 2, 3] + ```erlang + [1, 2, 3]. ``` """ diff --git a/test/livebook/live_markdown/import_test.exs b/test/livebook/live_markdown/import_test.exs index 66f223ddb..9baeaccf4 100644 --- a/test/livebook/live_markdown/import_test.exs +++ b/test/livebook/live_markdown/import_test.exs @@ -373,7 +373,7 @@ defmodule Livebook.LiveMarkdown.ImportTest do assert ["line 3 - closing unclosed backquotes ` at end of input"] == messages end - test "imports non-elixir code snippets as part of markdown cells" do + test "imports non-code cell snippets as part of markdown cells" do markdown = """ # My Notebook @@ -387,10 +387,8 @@ defmodule Livebook.LiveMarkdown.ImportTest do Enum.to_list(1..10) ``` - - - ```erlang - spawn_link(fun() -> io:format("Hiya") end). + ```json + {"x": 1, "y": 1} ``` """ @@ -416,8 +414,8 @@ defmodule Livebook.LiveMarkdown.ImportTest do }, %Cell.Markdown{ source: """ - ```erlang - spawn_link(fun() -> io:format("Hiya") end). + ```json + {"x": 1, "y": 1} ```\ """ } @@ -427,7 +425,7 @@ defmodule Livebook.LiveMarkdown.ImportTest do } = notebook end - test "imports elixir snippets as part of markdown cells if marked as such" do + test "imports code cell snippets as part of markdown cells if marked as such" do markdown = """ # My Notebook @@ -445,8 +443,8 @@ defmodule Livebook.LiveMarkdown.ImportTest do - ```elixir - [1, 2, 3] + ```erlang + [1, 2, 3]. ``` """ @@ -474,8 +472,8 @@ defmodule Livebook.LiveMarkdown.ImportTest do source: """ Some markdown. - ```elixir - [1, 2, 3] + ```erlang + [1, 2, 3]. ```\ """ }