Commit graph

8 commits

Author SHA1 Message Date
John MacFarlane
51142c6803 Ipynb reader & writer: properly handle cell "id".
This is passed through if it exists (in Nb4); otherwise
the writer will add a random one so that cells all have
an "id".

Closes #7728.
2021-12-06 23:40:51 -08:00
John MacFarlane
0bdcf415e4 Switch from pretty-simple to pretty-show for native output.
Update tests.

Reason:  it turns out that the native output generated by
pretty-simple isn't always readable by the native reader.
According to https://github.com/cdepillabout/pretty-simple/issues/99
it is not a design goal of the library that the rendered values
be readable using 'read'.  This makes it unsuitable for our
purposes.

pretty-show is a bit slower and it uses 4-space indents
(non-configurable), but it doesn't have this serious drawback.
2021-09-28 21:17:53 -07:00
John MacFarlane
c266734448 Use pretty-simple to format native output.
Previously we used our own homespun formatting.  But this
produces over-long lines that aren't ideal for diffs in tests.
Easier to use something off-the-shelf and standard.

Closes #7580.

Performance is slower by about a factor of 10, but this isn't
really a problem because native isn't suitable as a serialization
format. (For serialization you should use json, because the reader
is so much faster than native.)
2021-09-21 12:37:42 -07:00
John MacFarlane
804e8eeed2 Revert "Ipnyb: allow lossless round-tripping of markdown cell content."
This reverts commit efbc205031.
2020-07-02 09:03:56 -07:00
John MacFarlane
efbc205031 Ipnyb: allow lossless round-tripping of markdown cell content.
The reader now parses the contents of the markdown cell to a Pandoc
structure, but *also* stores the raw markdown in a `source`
attribute on the cell Div.  When we convert back to markdown,
this attribute is stripped off and the original source is used.
When we convert to other formats, the attribute is usually
ignored (though it will come through in HTML as a `data-source`
attribute, not unhelpfully).

I'll note some potential drawbacks of this approach:

- It makes it impossible to use pandoc to clean up or
  change the contents of markdown cells, e.g.
  going from `+smart` to `-smart`.

- There may be formats where the addition of the `source`
  attribute is problematic.  I can't think of any, though.

Closes #5408.
2020-06-30 12:32:44 -07:00
John MacFarlane
e405d7b532 Include execution output in ipynb test. 2019-03-09 16:53:53 -08:00
John MacFarlane
873f342f11 Ipynb reader/writer: better handling of cell metadata.
We now handle even complex cell metadata in the Div's attributes.
Simple metadata fields are rendered as a plain string, and complex ones
as JSON.
2019-03-09 14:27:34 -08:00
John MacFarlane
1cdbb896f6 Added simple ipynb reader/writer tests.
Closes #5274.
2019-02-09 14:53:30 -08:00