Skip to content

Commit

Permalink
Fix caching for franklin_output (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikhuijzer authored Feb 13, 2022
1 parent 6f9c4a3 commit 0d53e4b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions test/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0d53e4b

Please sign in to comment.