Browse Source

Add text before the Admonition

pull/214/head
Sogari 3 years ago committed by Simon Christ
parent
commit
1213abeea7
  1. 39
      src/Literate.jl

39
src/Literate.jl

@ -914,15 +914,52 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
# write(io, line.second, '\n') # Skip indent # write(io, line.second, '\n') # Skip indent
# end # end
# write(io, "\"\"\"\n") # write(io, "\"\"\"\n")
if containsAdmonition(chunk) if containsAdmonition(chunk)
write(io, "$(flavor.use_cm ? "cm" : "md")\"\"\"\n") write(io, "$(flavor.use_cm ? "cm" : "md")\"\"\"\n")
buffer = IOBuffer() buffer = IOBuffer()
for line in chunk.lines for line in chunk.lines
write(buffer, line.first * line.second, '\n') write(buffer, line.first * line.second, '\n')
#println("$(line.first)" * "$(line.second)")
end end
seek(buffer, 0) seek(buffer, 0)
str = Markdown.parse(read(buffer, String)) 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) admonition = filter(x -> x isa Markdown.Admonition, str.content)
questionName = "$(admonition[1].title)" * "$(replace(string(gensym()), "#" => ""))" questionName = "$(admonition[1].title)" * "$(replace(string(gensym()), "#" => ""))"
str = string(Markdown.MD(admonition[1])) str = string(Markdown.MD(admonition[1]))

Loading…
Cancel
Save