Some notebooks are not displaying nicely
User @bwsanders reports:
For one, code blocks rendering like code. So, for example, this diff: bwsanders1/notebook_bug!3(viewing side-by-side)
That code block isn't actually readable to me. While it is far superior than reading it in a json file, I can't actually reasonably review that diff inside the webpage. (well, maybe this one comment change, but if there was more code changes I couldn't)
Source of the bug
The notebook shared by @bwsanders (bwsanders1/notebook_bug!3 (eb5c3d90)), while valid, is saved in a non standard format: for the markdown and code sources, instead of each line being an item in an array, it is all one item joined by '\n'. This was causing a bug, which we fixed in 15.2 by escaping the character. While escaping fixes the error, it doesn't really make it readable.
How to fix
The relevant code that needs to be changed is here:
It can be fixed by splitting each line by '\n', and adding the lines to the transformed. The symbol for each line should be the same. Something like
def symbolize_array(symbol, content, &block)
if content.is_a?(Array)
content.map.with_index { |l, idx| _(symbol / idx, block.call(l)) }
else
- _(symbol, content)
+ content.split("\n").map { |c| _(symbol, c) }
end
end
The test case testdata/source_with_linebreakw would then change:
-
expected.md
%% Cell type:markdown id: tags: - > This is a test\n>\n> To see if I can duplicate my bug + > This is a test + + > To see if I can duplicate my bug
-
expected_symbols.txt
.cells.0 .cells.0.source + .cells.0.source + .cells.0.source