Browse Source

Add CommonMark parameter, invis first cell

pull/214/head
Matthias Plochocki 3 years ago
parent
commit
77ad06d737
  1. 18
      src/Literate.jl

18
src/Literate.jl

@ -17,8 +17,9 @@ struct DocumenterFlavor <: AbstractFlavor end
struct CommonMarkFlavor <: AbstractFlavor end struct CommonMarkFlavor <: AbstractFlavor end
struct FranklinFlavor <: AbstractFlavor end struct FranklinFlavor <: AbstractFlavor end
struct JupyterFlavor <: AbstractFlavor end struct JupyterFlavor <: AbstractFlavor end
struct PlutoFlavor <: AbstractFlavor end Base.@kwdef struct PlutoFlavor <: AbstractFlavor
use_cm::Bool = false
end
# # Some simple rules: # # Some simple rules:
# #
# * All lines starting with `# ` are considered markdown, everything else is considered code # * All lines starting with `# ` are considered markdown, everything else is considered code
@ -750,15 +751,14 @@ function execute_notebook(nb; inputfile::String="<unknown>")
return nb return nb
end end
function create_notebook(::PlutoFlavor, chunks, config) function create_notebook(flavor::PlutoFlavor, chunks, config)
ionb = IOBuffer() ionb = IOBuffer()
# Print header # Print header
write(ionb, """ write(ionb, """
### A Pluto.jl notebook ### ### A Pluto.jl notebook ###
# v0.16.0 # v0.16.0
# ╔═╡ a0000000-0000-0000-0000-000000000000
using Markdown using $(flavor.use_cm ? "CommonMark" : "Markdown")
using InteractiveUtils
""") """)
@ -783,9 +783,9 @@ function create_notebook(::PlutoFlavor, chunks, config)
if isa(chunk, MDChunk) if isa(chunk, MDChunk)
if length(chunk.lines) == 1 if length(chunk.lines) == 1
line = escape_string(chunk.lines[1].second, '"') line = escape_string(chunk.lines[1].second, '"')
write(io, "md\"", line, "\"\n") write(io, "$(flavor.use_cm ? "cm" : "md")\"", line, "\"\n")
else else
write(io, "md\"\"\"\n") write(io, "$(flavor.use_cm ? "cm" : "md")\"\"\"\n")
for line in chunk.lines for line in chunk.lines
write(io, line.second, '\n') # Skip indent write(io, line.second, '\n') # Skip indent
end end
@ -820,7 +820,7 @@ function create_notebook(::PlutoFlavor, chunks, config)
end end
# Print cell order # Print cell order
print(ionb, "# ╔═╡ Cell order:\n") print(ionb, "# ╔═╡ Cell order:\n# ╟─a0000000-0000-0000-0000-000000000000\n")
foreach(((x, f),) -> print(ionb, "# $(f ? "╟─" : "╠═")", x, '\n'), zip(uuids, folds)) foreach(((x, f),) -> print(ionb, "# $(f ? "╟─" : "╠═")", x, '\n'), zip(uuids, folds))
# custom post-processing from user # custom post-processing from user

Loading…
Cancel
Save