From 0d53e4b7d7e2571530b811e0d6a17aa0376531de Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Sun, 13 Feb 2022 18:53:29 +0100 Subject: [PATCH] Fix caching for `franklin_output` (#71) --- src/build.jl | 3 +++ test/cache.jl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/build.jl b/src/build.jl index d4effca7..b5cce0da 100644 --- a/src/build.jl +++ b/src/build.jl @@ -169,6 +169,9 @@ end function _outcome2text(session, prev::Previous, in_path::String, bopts, hopts)::String text = prev.text + if bopts.output_format == franklin_output + text = "~~~\n$(text)\n~~~" + end _write_main_output(in_path, text, bopts, hopts) return text end diff --git a/test/cache.jl b/test/cache.jl index af0f8ce8..4de8eba4 100644 --- a/test/cache.jl +++ b/test/cache.jl @@ -126,3 +126,35 @@ end end end +@testset "franklin_markdown_cache_output" begin + # Test whether the Franklin Markdown copied from the cache is correct. + dir = mktempdir() + + cd(dir) do + path = joinpath(dir, "notebook.jl") + code = pluto_notebook_content(""" + md\"\"\" + +++ + title = \"foo\" + +++ + \"\"\" + """) + write(path, code) + + output_format = franklin_output + use_distributed = false + bo = BuildOptions(dir; output_format, use_distributed) + parallel_build(bo) + + output_path = joinpath(dir, "notebook.md") + output = read(output_path, String) + + previous_dir = dir + bo = BuildOptions(dir; output_format, use_distributed, previous_dir) + parallel_build(bo) + + output2 = read(output_path, String) + + @test output == output2 + end +end