in editor/common/parseBlocks.js [206:278]
function addBlocks(parentCommand) {
for (const command of parentCommand.children) {
if ((command instanceof UseCommand) || (command instanceof ImportCommand)) {
closeTextBlock();
outBlocks.push({
type: 'use',
target: command.name.trim(),
args: command.args ? parseArgs(command.args) : [],
// use command can't be used inline
inline: false
});
}
else if (command instanceof TextNode) {
textBlockText += command.value;
}
else if (command instanceof IfCommand) {
if ((command instanceof ElseCommand) && (command.children[0] instanceof ElifCommand)) {
// There is always an ElseCommand inserted between IfCommand and ElifCommand
return addBlocks(command);
}
// // DONT parse inline if block in the content
if (isInlineCommand() || !detailed) {
textBlockText += compositeIfCommand(command);
}
else {
closeTextBlock();
const type = command instanceof ElseCommand
? 'else' : command instanceof ElifCommand ? 'elif' : 'if';
outBlocks.push({
type,
inline: false,
expr: command.value && formatExpr(command.value)
});
addBlocks(command);
const isCloseNeedsToInline = isInlineCommand();
closeTextBlock();
if (type === 'if') {
outBlocks.push({
type: 'endif',
inline: isCloseNeedsToInline
});
}
}
}
else if (command instanceof ForCommand) {
if (isInlineCommand() || !detailed) {
textBlockText += compositeForCommand(command);
}
else {
closeTextBlock();
outBlocks.push({
type: 'for',
inline: false,
expr: formatExpr(command.value)
});
addBlocks(command);
const isCloseNeedsToInline = isInlineCommand();
closeTextBlock();
outBlocks.push({
type: 'endfor',
inline: isCloseNeedsToInline
});
}
}
else {
throw new Error(`Unkown block ${command.toString()}`);
}
}
}