diff --git a/src/FSharp.Formatting.Literate/ParsePynb.fs b/src/FSharp.Formatting.Literate/ParsePynb.fs index 0c5b603b9..90f91859a 100644 --- a/src/FSharp.Formatting.Literate/ParsePynb.fs +++ b/src/FSharp.Formatting.Literate/ParsePynb.fs @@ -3,6 +3,7 @@ namespace FSharp.Formatting.Literate open System.IO open System.Text.Json open FSharp.Formatting.Templating +open FSharp.Formatting.PynbModel module internal ParsePynb = @@ -17,7 +18,7 @@ module internal ParsePynb = match this with | Markdown source -> source | Code code -> - let codeBlock = sprintf $"```{code.lang}\n{code.source}\n```" + let codeBlock = sprintf $"```{code.lang}\n{addLineEnd code.source}```" match code.outputs with | None -> codeBlock @@ -142,7 +143,7 @@ module internal ParsePynb = json.RootElement.GetProperty("cells").EnumerateArray() |> Seq.map (parseCell >> (fun x -> x.ToMarkdown())) - |> String.concat "\n\n" + |> String.concat "\n" let pynbToMarkdown ipynbFile = ipynbFile |> File.ReadAllText |> pynbStringToMarkdown diff --git a/tests/FSharp.Literate.Tests/LiterateTests.fs b/tests/FSharp.Literate.Tests/LiterateTests.fs index 59f9afcd1..7dc34c16c 100644 --- a/tests/FSharp.Literate.Tests/LiterateTests.fs +++ b/tests/FSharp.Literate.Tests/LiterateTests.fs @@ -1465,7 +1465,7 @@ let add a b = a + b |> Literate.ToPynb |> ParsePynb.pynbStringToMarkdown - mdOut |> shouldEqual mdIn + (mdOut.Trim()) |> shouldEqual (mdIn.Trim()) [] let ``Script output is exactly right`` () =