Skip to content

add raw_mimetype metadata to raw cells#4306

Merged
Carreau merged 15 commits into
ipython:masterfrom
minrk:raw-cell-metadata
Dec 7, 2013
Merged

add raw_mimetype metadata to raw cells#4306
Carreau merged 15 commits into
ipython:masterfrom
minrk:raw-cell-metadata

Conversation

@minrk
Copy link
Copy Markdown
Member

@minrk minrk commented Sep 30, 2013

allows exclusion in nbconvert based on format. If no format is specified, a raw cell is included by default (matches current master behavior).

and adds Raw Cell cell toolbar

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, at the time of writing this, I did not notice to write it inherited from HTMLExporter instead of a more basic one... less code to maintain 👍

@damianavila
Copy link
Copy Markdown
Member

@minrk a general question... do we have plans to make the metadata of raw cells available to the user in a simpler way? Currently it is exposed through the CellToolBar, but not easy to modified for final user... or this PR is related to the change of the notebook format (I did not read yet)? Or, I am missing some things, which is the most probably ;-)

@minrk
Copy link
Copy Markdown
Member Author

minrk commented Sep 30, 2013

@damianavila I think raw cells should get their own toolbar for setting the raw format type, I will be looking into that today.

@damianavila
Copy link
Copy Markdown
Member

ok, thanks for the info!

@Carreau
Copy link
Copy Markdown
Member

Carreau commented Oct 3, 2013

+1

@Carreau
Copy link
Copy Markdown
Member

Carreau commented Oct 4, 2013

As discussed yesterday, do you want to use mimetype instead of 'html','python',... ?

@minrk
Copy link
Copy Markdown
Member Author

minrk commented Oct 4, 2013

As discussed yesterday, do you want to use mimetype instead of 'html','python',... ?

I'm not entirely sure - mimetype is better for machines, but humans don't really want to type them, and the only way to specify format right now is to edit raw metadata, which means typing it all out. I'll look into a toolbar for raw cells that might alleviate that.

@Carreau
Copy link
Copy Markdown
Member

Carreau commented Oct 6, 2013

isn't the raw_format/raw_formats a little too much ? I guess it's for convenience, but I'm worried it willl be too complicated for user. why not just stick with raw_formats ?

@minrk
Copy link
Copy Markdown
Member Author

minrk commented Oct 6, 2013

raw_format is used for the default value. I guess I could replace that with raw_formats[0], but that would raise if anyone does raw_formats = [] to exclude any raw format. I'll see if I can remove it cleanly.

Comment thread IPython/html/templates/notebook.html Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the strong connotation of the work "output" in the context of the notebook (to mean the output of running code), I don't think this word change makes sense. What is the problem with "Raw Text"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have proof that "Raw Text" is confusing to people, perhaps because it is simply not accurate.
A raw cell is always raw nbconvert output (html, rst, latex, etc. - it is never plain text).

Many people interpret 'Raw Text' as 'Unformatted Text', aka <pre>, which is totally sensible based on the label. But this is not what Raw Cells are. Raw Cells are, by definition, raw nbconvert output.

Obviously, there is some ambiguity between Code Cell output and nbconvert output, but I think Raw Output is less confusing than Raw Text. Do you have a better alternative? Should we be extremely explicit and label them raw nbconvert output, since that is what they are?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that "Raw Text" is confusing.

A good fraction of notebook users never touch nbconvert. For those users,
the phrase "nbconvert output" means little, if anything. Even in the
context of nbconvert, calling this output is confusing. It is really input
from a user that nbconvert passes through unmodified to its output.

In the notebook UI, it is in fact plain, unformatted, unrendered text.

What about the following. In the Notebook UI, we refer to these in a way
that reflects their usage in the Notebook UI - maybe Unrendered Text? If
we want to stick with the output idea, I do think that "Raw nbconvert
output" is better though.

This also makes me think that one of the metadata values for these cells,
in addition to html, rst, latex, should be verbatim/pre. In that case it
would simply dump the content of the cell into a pre if html or verbatim if
latex. But maybe that violates the pass-through aspect of these cells.

On Wed, Oct 9, 2013 at 3:07 PM, Min RK notifications@github.com wrote:

In IPython/html/templates/notebook.html:

@@ -126,7 +126,7 @@


  • Code

  • Markdown
    •                  <li id="to_raw"><a href="#">Raw Text</a></li>
      
    •                  <li id="to_raw"><a href="#">Raw Output</a></li>
      

We have proof that "Raw Text" is confusing to people, perhaps because it
is simply not accurate.
A raw cell is always raw nbconvert output (html, rst, latex, etc. - it
is never plain text).

Many people interpret 'Raw Text' as 'Unformatted Text', aka

, which
is totally sensible based on the label. But this is not what Raw Cells are.
Raw Cells are, by definition, raw nbconvert output.

Obviously, there is some ambiguity between Code Cell output and nbconvert
output, but I think Raw Output is less confusing than Raw Text. Do you have
a better alternative? Should we be extremely explicit and label them raw
nbconvert output, since that is what they are?


Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/pull/4306/files#r6872554
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like 'raw inclusion'?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like 'raw inclusion'?

I like that...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or "nbconvert passthrough"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer raw inclusion, but at the end, any of the last ones will work, I think...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like us to find a name that reflects how these are handled in the
notebook UI, not just nbconvert.

On Fri, Oct 11, 2013 at 8:43 AM, Damián Avila notifications@github.comwrote:

In IPython/html/templates/notebook.html:

@@ -126,7 +126,7 @@


  • Code

  • Markdown
    •                  <li id="to_raw"><a href="#">Raw Text</a></li>
      
    •                  <li id="to_raw"><a href="#">Raw Output</a></li>
      

I prefer raw inclusion, but at the end, any of the last one will work, I
think...


Reply to this email directly or view it on GitHubhttps://github.com//pull/4306/files#r6918597
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems odd to me. Their role in the notebook UI doesn't seem important, given that the entire point of the cell is a place to dump nbconvert output. For instance, totally hidden (maybe toggle on/off) raw cells makes perfect sense from a UI perspective, since they are guaranteed to not have any function in the live notebook.

@Carreau
Copy link
Copy Markdown
Member

Carreau commented Nov 5, 2013

FYI, need rebase.

@minrk
Copy link
Copy Markdown
Member Author

minrk commented Nov 5, 2013

Yes, and I need to cleanup the cell toolbar code, so I can get a toolbar on just one type of cell.

@minrk
Copy link
Copy Markdown
Member Author

minrk commented Nov 6, 2013

inching closer on this one. I have the raw format cell toolbar mostly working.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty branch in one condition ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't written the dialog yet, still need to do that.

@Carreau
Copy link
Copy Markdown
Member

Carreau commented Nov 11, 2013

Except one comment the js/css part seem ok. haven't read the rest though.
This will conflict with css-cleaning, but I can rebase.
This can also have small conflict with Brian modal UI I think.

@Carreau
Copy link
Copy Markdown
Member

Carreau commented Nov 13, 2013

This need a rebase ... Sorry.

minrk added 12 commits November 20, 2013 14:47
select based on raw_format metadata key if defined.
Default behavior is to include raw cells of unspecified format (consistent with existing behavior).
sets their values in resources
make hierarchical rather than either/or.  Also, don't use the same class name for the outer and inner css classes.
and make sure cell_type is defined *before* calling TextCell.apply
- in toJSON
- don't clobber existing value in Cell constructor
@minrk
Copy link
Copy Markdown
Member Author

minrk commented Nov 21, 2013

rebased, and the toolbar now only displays on the raw cells. The metadata key is raw_mimetype, and the values are mime types ('text/latex', 'application/x-python', etc.).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "restructuredText" I would use "reST"... so the dropdown menu would be narrowed.

@damianavila
Copy link
Copy Markdown
Member

I tested a little bit and I like... again 👍

I just added some minor comments.

@Carreau
Copy link
Copy Markdown
Member

Carreau commented Dec 5, 2013

@minrk would you like to respond to @damianavila comment ? Or should we modify that in later PRs ?

@minrk
Copy link
Copy Markdown
Member Author

minrk commented Dec 5, 2013

I'll tweak it to be more generic. The way the code works, I don't think it would be worth the effort to make placeholder support variation.

@minrk
Copy link
Copy Markdown
Member Author

minrk commented Dec 5, 2013

restructuredtext->rST in selector so it can be narrower.

@damianavila
Copy link
Copy Markdown
Member

Great! Thanks for addressing the comments

Carreau added a commit that referenced this pull request Dec 7, 2013
add raw_mimetype metadata to raw cells
@Carreau Carreau merged commit 8c37384 into ipython:master Dec 7, 2013
@Carreau
Copy link
Copy Markdown
Member

Carreau commented Dec 7, 2013

Great ! Thanks !

@minrk minrk deleted the raw-cell-metadata branch March 31, 2014 23:36
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
add raw_mimetype metadata to raw cells
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants