From 1213abeea70f1e3b1bcfe5474120435e7485aa14 Mon Sep 17 00:00:00 2001 From: Sogari Date: Sat, 25 Mar 2023 00:25:48 +0100 Subject: [PATCH] Add text before the Admonition --- src/Literate.jl | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Literate.jl b/src/Literate.jl index e2bc9bd..5078eb0 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -914,15 +914,52 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) # write(io, line.second, '\n') # Skip indent # end # write(io, "\"\"\"\n") + if containsAdmonition(chunk) write(io, "$(flavor.use_cm ? "cm" : "md")\"\"\"\n") + buffer = IOBuffer() for line in chunk.lines write(buffer, line.first * line.second, '\n') - #println("$(line.first)" * "$(line.second)") end seek(buffer, 0) str = Markdown.parse(read(buffer, String)) + + ############################################################ + #Content before the Admonition + ############################################################ + + mdContent = str.content + admoIndex = 1 + for (i, item) in enumerate(mdContent) + if isa(item, Markdown.Admonition) + admoIndex = i + end + end + + if admoIndex > 1 + index = 1 + while index < admoIndex + para = string(Markdown.MD(mdContent[index])) + write(io, para, '\n') + index += 1 + end + # write(io, "\"\"\"\n") + # write(io, '\n') + + # content = String(take!(io)) + # uuid = uuid4(content, cellCounter) + # cellCounter += 1 + # push!(uuids, uuid) + # push!(folds, fold) + # print(ionb, "# ╔═╡ ", uuid, '\n') + # write(ionb, content, '\n') + end + + ############################################################ + #The Admonition + ############################################################ + admonition = filter(x -> x isa Markdown.Admonition, str.content) questionName = "$(admonition[1].title)" * "$(replace(string(gensym()), "#" => ""))" str = string(Markdown.MD(admonition[1]))