dedent_notebook = notebook({
interpolated_lines,
get_identation,
tweak_first_and_last_line,
concat_lines
})`
template_function = null
strings = null
values = null
lines = interpolated_lines(strings, ...values);
indentation = get_identation(lines);
lines_trimmed = tweak_first_and_last_line(lines_without_identation, indentation);
lines_without_identation = lines.map(
([first_string, ...rest]) => {
return [first_string.slice(indentation), ...rest];
}
);
elements = concat_lines(lines_trimmed);
result = {
let new_strings = [];
let new_values = [];
for (let [string, value] of _.chunk(elements, 2)) {
new_strings.push(string);
if (value) {
new_values.push(value);
}
}
new_strings.raw = new_strings;
return template_function(new_strings, ...new_values);
}
`