|
|
|
@ -994,35 +994,23 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
write(io, "$(flavor.use_cm ? "cm" : "md")\"\"\"\n") |
|
|
|
write(io, "$(flavor.use_cm ? "cm" : "md")\"\"\"\n") |
|
|
|
|
|
|
|
|
|
|
|
str = chunkToMD(chunk) |
|
|
|
str = chunkToMD(chunk) |
|
|
|
|
|
|
|
helperList = [] |
|
|
|
|
|
|
|
helperTestList = [] |
|
|
|
|
|
|
|
|
|
|
|
# Content before the Admonition |
|
|
|
# Content before the Admonition |
|
|
|
################################################################ |
|
|
|
################################################################ |
|
|
|
|
|
|
|
|
|
|
|
mdContent = str.content |
|
|
|
mdContent = str.content |
|
|
|
admoIndex = 1 |
|
|
|
for item in mdContent |
|
|
|
for (i, item) in enumerate(mdContent) |
|
|
|
if !isa(item, Markdown.Admonition) |
|
|
|
if isa(item, Markdown.Admonition) |
|
|
|
write(io, string(Markdown.MD(item)), '\n') |
|
|
|
admoIndex = i |
|
|
|
elseif isa(item, Markdown.Admonition) |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if admoIndex > 1 |
|
|
|
|
|
|
|
index = 1 |
|
|
|
|
|
|
|
while index < admoIndex |
|
|
|
|
|
|
|
para = string(Markdown.MD(mdContent[index])) |
|
|
|
|
|
|
|
write(io, para, '\n') |
|
|
|
|
|
|
|
index += 1 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# The Admonition |
|
|
|
# The Admonition |
|
|
|
################################################################ |
|
|
|
######################################################## |
|
|
|
|
|
|
|
|
|
|
|
admonition = filter(x -> x isa Markdown.Admonition, str.content) |
|
|
|
admonition = item |
|
|
|
questionName = replace("$(admonition[1].title)" * "$(replace(string(gensym()), "#" => ""))", r"[^\d\w]+" => "") |
|
|
|
questionName = replace("$(admonition.title)" * "$(replace(string(gensym()), "#" => ""))", r"[^\d\w]+" => "") |
|
|
|
questionCategory = admonition[1].category |
|
|
|
questionCategory = admonition.category |
|
|
|
str = string(Markdown.MD(admonition[1])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################################################ |
|
|
|
################################################################ |
|
|
|
# Single-Choice Admonition |
|
|
|
# Single-Choice Admonition |
|
|
|
@ -1032,7 +1020,7 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
answers = [] |
|
|
|
answers = [] |
|
|
|
questionDict = Dict("correct" => "") |
|
|
|
questionDict = Dict("correct" => "") |
|
|
|
|
|
|
|
|
|
|
|
answerList = filter(x -> isa(x, Markdown.List), admonition[1].content) |
|
|
|
answerList = filter(x -> isa(x, Markdown.List), admonition.content) |
|
|
|
answerStr = string(Markdown.MD(answerList[end])) |
|
|
|
answerStr = string(Markdown.MD(answerList[end])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1051,7 +1039,7 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
restList = filter(x -> !isa(x, Markdown.List), admonition[1].content) |
|
|
|
restList = filter(x -> !isa(x, Markdown.List), admonition.content) |
|
|
|
if length(answerList) > 1 |
|
|
|
if length(answerList) > 1 |
|
|
|
push!(restList, answerList[begin:end-1]) |
|
|
|
push!(restList, answerList[begin:end-1]) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1062,29 +1050,12 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
result = writeControlFlow(questionName, restList) |
|
|
|
result = writeControlFlow(questionName, restList) |
|
|
|
write(io, result, '\n') |
|
|
|
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") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Pluto nb helper functions |
|
|
|
# Pluto nb helper functions |
|
|
|
############################################################ |
|
|
|
############################################################ |
|
|
|
|
|
|
|
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
push!(helperList, radioBind) |
|
|
|
|
|
|
|
push!(helperList, logicBind) |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
elseif questionCategory == "mc" |
|
|
|
elseif questionCategory == "mc" |
|
|
|
############################################################ |
|
|
|
############################################################ |
|
|
|
# Multiple-Choice Admonition |
|
|
|
# Multiple-Choice Admonition |
|
|
|
@ -1093,7 +1064,7 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
answers = [] |
|
|
|
answers = [] |
|
|
|
questionDict = Dict("correct" => String[]) |
|
|
|
questionDict = Dict("correct" => String[]) |
|
|
|
|
|
|
|
|
|
|
|
answerList = filter(x -> isa(x, Markdown.List), admonition[1].content) |
|
|
|
answerList = filter(x -> isa(x, Markdown.List), admonition.content) |
|
|
|
answerStr = string(Markdown.MD(answerList[end])) |
|
|
|
answerStr = string(Markdown.MD(answerList[end])) |
|
|
|
|
|
|
|
|
|
|
|
for line in split(answerStr, "\n") |
|
|
|
for line in split(answerStr, "\n") |
|
|
|
@ -1110,7 +1081,7 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
restList = filter(x -> !isa(x, Markdown.List), admonition[1].content) |
|
|
|
restList = filter(x -> !isa(x, Markdown.List), admonition.content) |
|
|
|
if length(answerList) > 1 |
|
|
|
if length(answerList) > 1 |
|
|
|
push!(restList, answerList[begin:end-1]) |
|
|
|
push!(restList, answerList[begin:end-1]) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1121,29 +1092,11 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
result = writeControlFlow(questionName, restList) |
|
|
|
result = writeControlFlow(questionName, restList) |
|
|
|
write(io, result, '\n') |
|
|
|
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") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Pluto nb helper functions |
|
|
|
# Pluto nb helper functions |
|
|
|
############################################################ |
|
|
|
############################################################ |
|
|
|
|
|
|
|
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
push!(helperList, radioBind) |
|
|
|
|
|
|
|
push!(helperList, logicBind) |
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elseif questionCategory == "freecode" |
|
|
|
elseif questionCategory == "freecode" |
|
|
|
############################################################ |
|
|
|
############################################################ |
|
|
|
@ -1152,7 +1105,7 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
|
|
|
|
|
|
|
|
tests = [] |
|
|
|
tests = [] |
|
|
|
|
|
|
|
|
|
|
|
testList = filter(x -> isa(x, Markdown.List), admonition[1].content) |
|
|
|
testList = filter(x -> isa(x, Markdown.List), admonition.content) |
|
|
|
testStr = string(Markdown.MD(testList[end])) |
|
|
|
testStr = string(Markdown.MD(testList[end])) |
|
|
|
|
|
|
|
|
|
|
|
for line in split(testStr, "\n") |
|
|
|
for line in split(testStr, "\n") |
|
|
|
@ -1162,7 +1115,7 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
restList = filter(x -> !isa(x, Markdown.List), admonition[1].content) |
|
|
|
restList = filter(x -> !isa(x, Markdown.List), admonition.content) |
|
|
|
if length(testList) > 1 |
|
|
|
if length(testList) > 1 |
|
|
|
push!(restList, testList[begin:end-1]) |
|
|
|
push!(restList, testList[begin:end-1]) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1173,44 +1126,35 @@ function create_notebook(flavor::PlutoFlavor, chunks, config) |
|
|
|
result = writeControlFlow(questionName, restList) |
|
|
|
result = writeControlFlow(questionName, restList) |
|
|
|
write(io, result, '\n') |
|
|
|
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") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Pluto nb helper functions |
|
|
|
# Pluto nb helper functions |
|
|
|
############################################################ |
|
|
|
############################################################ |
|
|
|
|
|
|
|
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
push!(helperTestList, radioBind) |
|
|
|
|
|
|
|
push!(helperList, logicBind) |
|
|
|
write(io, radioBind, '\n') |
|
|
|
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write(io, logicBind, '\n') |
|
|
|
|
|
|
|
cellCounter = formatCellsEnd(io, ionb, cellCounter, singleChoiceContent, singleChoiceUuids, singleChoiceFolds, fold) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
############################################################ |
|
|
|
############################################################ |
|
|
|
# Normal Admonitions |
|
|
|
# Normal Admonitions |
|
|
|
############################################################ |
|
|
|
############################################################ |
|
|
|
|
|
|
|
|
|
|
|
index = admoIndex |
|
|
|
write(io, string(Markdown.MD(item)), '\n') |
|
|
|
while index <= length(mdContent) |
|
|
|
|
|
|
|
para = string(Markdown.MD(mdContent[index])) |
|
|
|
|
|
|
|
write(io, para, '\n') |
|
|
|
|
|
|
|
index += 1 |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
write(io, "\"\"\"\n") |
|
|
|
write(io, "\"\"\"\n") |
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for item in helperTestList |
|
|
|
|
|
|
|
write(io, item, '\n') |
|
|
|
|
|
|
|
cellCounter = formatCells(io, ionb, cellCounter, uuids, folds, fold) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for item in helperList |
|
|
|
|
|
|
|
write(io, item, '\n') |
|
|
|
|
|
|
|
cellCounter = formatCellsEnd(io, ionb, cellCounter, singleChoiceContent, singleChoiceUuids, singleChoiceFolds, fold) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
################################################################ |
|
|
|
################################################################ |
|
|
|
# Chunk doesnt contain an Admonition |
|
|
|
# Chunk doesnt contain an Admonition |
|
|
|
|