|
|
|
|
@ -976,62 +976,75 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
@@ -976,62 +976,75 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
|
|
|
|
|
|
|
|
|
|
admonition = filter(x -> x isa Markdown.Admonition, str.content) |
|
|
|
|
questionName = "$(admonition[1].title)" * "$(replace(string(gensym()), "#" => ""))" |
|
|
|
|
questionCategory = admonition[1].category |
|
|
|
|
str = string(Markdown.MD(admonition[1])) |
|
|
|
|
|
|
|
|
|
answers = [] |
|
|
|
|
questionDict = Dict("correct" => "") |
|
|
|
|
qBuf = IOBuffer() |
|
|
|
|
|
|
|
|
|
for line in split(str, "\n") |
|
|
|
|
if startswith(lstrip(line), r"[1-9]\.") |
|
|
|
|
answer = lstrip(line) |
|
|
|
|
|
|
|
|
|
correct = occursin("<!---correct-->", string(answer)) || occursin("<!–-correct–>", string(answer)) |
|
|
|
|
if correct |
|
|
|
|
|
|
|
|
|
if questionCategory == "sc" |
|
|
|
|
answers = [] |
|
|
|
|
questionDict = Dict("correct" => "") |
|
|
|
|
qBuf = IOBuffer() |
|
|
|
|
|
|
|
|
|
for line in split(str, "\n") |
|
|
|
|
if startswith(lstrip(line), r"[1-9]\.") |
|
|
|
|
answer = lstrip(line) |
|
|
|
|
|
|
|
|
|
correct = occursin("<!---correct-->", string(answer)) || occursin("<!–-correct–>", string(answer)) |
|
|
|
|
if correct |
|
|
|
|
answer = formatAnswer(answer) |
|
|
|
|
questionDict["correct"] = escape_string(string(answer)) |
|
|
|
|
end |
|
|
|
|
answer = formatAnswer(answer) |
|
|
|
|
questionDict["correct"] = escape_string(string(answer)) |
|
|
|
|
end |
|
|
|
|
answer = formatAnswer(answer) |
|
|
|
|
answer = string(answer) |
|
|
|
|
push!(answers, answer) |
|
|
|
|
else |
|
|
|
|
if line != "" && !startswith(line, "!!!") |
|
|
|
|
write(qBuf, lstrip(line), "\n") |
|
|
|
|
answer = string(answer) |
|
|
|
|
push!(answers, answer) |
|
|
|
|
else |
|
|
|
|
if line != "" && !startswith(line, "!!!") |
|
|
|
|
write(qBuf, lstrip(line), "\n") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
radioBind = writeBind(questionName, answers) |
|
|
|
|
logicBind = writeLogic(questionName, questionDict) |
|
|
|
|
|
|
|
|
|
seek(qBuf, 0) |
|
|
|
|
qStr = rstrip(read(qBuf, String)) |
|
|
|
|
radioBind = writeBind(questionName, answers) |
|
|
|
|
logicBind = writeLogic(questionName, questionDict) |
|
|
|
|
|
|
|
|
|
seek(qBuf, 0) |
|
|
|
|
qStr = rstrip(read(qBuf, String)) |
|
|
|
|
|
|
|
|
|
result = writeControlFlow(questionName, qStr) |
|
|
|
|
write(io, result, '\n') |
|
|
|
|
|
|
|
|
|
################################################################ |
|
|
|
|
# Content after the Admonition |
|
|
|
|
################################################################ |
|
|
|
|
|
|
|
|
|
if admoIndex < length(mdContent) |
|
|
|
|
index = admoIndex + 1 |
|
|
|
|
while index <= length(mdContent) |
|
|
|
|
para = string(Markdown.MD(mdContent[index])) |
|
|
|
|
write(io, para, '\n') |
|
|
|
|
index += 1 |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
write(io, "\"\"\"\n") |
|
|
|
|
|
|
|
|
|
result = writeControlFlow(questionName, qStr) |
|
|
|
|
write(io, result, '\n') |
|
|
|
|
# Pluto nb helper functions |
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
|
|
|
|
|
|
################################################################ |
|
|
|
|
# Content after the Admonition |
|
|
|
|
################################################################ |
|
|
|
|
write(io, radioBind, '\n') |
|
|
|
|
cellCounter = formatCellsEnd(io, ionb, cellCounter, singleChoiceContent, singleChoiceUuids, singleChoiceFolds, fold) |
|
|
|
|
|
|
|
|
|
if admoIndex < length(mdContent) |
|
|
|
|
index = admoIndex + 1 |
|
|
|
|
write(io, logicBind, '\n') |
|
|
|
|
cellCounter = formatCellsEnd(io, ionb, cellCounter, singleChoiceContent, singleChoiceUuids, singleChoiceFolds, fold) |
|
|
|
|
else |
|
|
|
|
index = admoIndex |
|
|
|
|
while index <= length(mdContent) |
|
|
|
|
para = string(Markdown.MD(mdContent[index])) |
|
|
|
|
write(io, para, '\n') |
|
|
|
|
index += 1 |
|
|
|
|
end |
|
|
|
|
write(io, "\"\"\"\n") |
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
|
end |
|
|
|
|
write(io, "\"\"\"\n") |
|
|
|
|
|
|
|
|
|
# Pluto nb helper functions |
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
|
|
|
|
|
|
write(io, radioBind, '\n') |
|
|
|
|
cellCounter = formatCellsEnd(io, ionb, cellCounter, singleChoiceContent, singleChoiceUuids, singleChoiceFolds, fold) |
|
|
|
|
|
|
|
|
|
write(io, logicBind, '\n') |
|
|
|
|
cellCounter = formatCellsEnd(io, ionb, cellCounter, singleChoiceContent, singleChoiceUuids, singleChoiceFolds, fold) |
|
|
|
|
else |
|
|
|
|
################################################################ |
|
|
|
|
# If Chunk doesnt contain an Admonition |
|
|
|
|
|