-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cell metadata #38
Comments
How about adopting the jekyll front-matter approach, and use some embedded YAML? I'd love to see a text-forward notebook UI (editor) that maintained nbformat metadata... in fact, this would be far easier than the current metadata UI! An object between I haven't had a chance to dig into the code, but would love to take a whack at throwing this together. ---
slideshow:
cell_type: slide
---
# A Slideshow
---
slideshow:
cell_type: fragment
---
```python
print("Brought to you by ipymd")
\```
===
name: a slideshow
=== |
it would be great to have metadata support with a relatively standard syntax see also http://rmarkdown.rstudio.com/ and https://github.com/chronitis/ipyrmd let me know if you're going to work on the code -- i might have to merge my pending PR first... |
No Intent To Implement yet! Just was reminded of this in another On 06:22, Fri, May 29, 2015 Cyrille Rossant notifications@github.com
|
Here are a few ideas:
This means that
|
Ahhhhh. Looking very promising! aml will do I like the alias as a generalization/realization of the For roundtrip to work, you'd want to also remember that you used an alias, and its arguments... --- SLIDE secretly generates this metadata: {"metadata": {
"ipymd": {"aliased": {"SLIDE": []}}},
"slideshow": {"slide_type": "slide"}
}} the stack of changes for
reversed for
Shortcut/args being space delimited suggests you just get one, which is probably fine... the case where i would want more shortcuts is for slides: could one import
Could just accept that an alias is really a function, and use named params...
...which would then leave space for some kind of query language to pull out cells (in this example, the filter would be wrapped in
Could the alias definition be more namespace-y? Can't have multiple aliases to the same thing, and if someone wants to overload it, it shouldn't require looking through Are document-level aliases are possible? I don't know what they would be... but the metadata regime is totally different, and i wouldn't want to mix them. Combining all of these ideas, it's reasonably compact and standards-compliant, and should provide enough room to grow: ===
ipymd:
alias:
cell:
SLIDE: [{op: add, path: /slideshow/slide_type, value: slide}]
SKIP: [{op: add, path: /slideshow/slide_type, value: skip}]
NOTES: [{op: add, path: /slideshow/slide_type, value: notes}]
SUBSLIDE: [{op: add, path: /slideshow/slide_type, value: subslide}]
FRAGMENT: [{op: add, path: /slideshow/slide_type, value: fragment}]
IMPORT($path): [{op: add, path: /ipymd/import, value: $path}]
=== ping @tonyfast |
agreed
agreed
the Questions:
|
Hopefully we're not creating too much of a monster :)
Had a duh moment: the obvious use case is a kernel name: === KERNEL(python) this would go out and grab the whole kernelspec, which nobody wants to type by hand.
JSON is a strict subset of YAML :) YAML even inherits the duplicate keys problem that ijson intends to fix. Also, the gh rendering only works for the first chunk of meta, a la jekyll, and everything else thinks you're making a heading. gist thinks everything is a heading. If you were to indent everything as code, the rendering is better on gist, but wouldn't work with the gh custom rendering. no big loss, i say. If i was doing a lot of tricky meta editing, I might even choose to explicitly use ticks and declare yml for syntax highlighting and linting... either way, we are proposing some stuff fairly incompatible with editors: We don't want to get into the syntax-highlighting-package-business if we don't have to.
I suppose for reuse, if you want to reuse a little bit, you pull it out of the original file, and import it from both places. much cleaner. but someday...
sure, was just working off the showoff notation. I kinda like it, because it would be easier to search and not get false positives.
hooray! i suppose it wouldn't be insane to actually set the scope of the thing to be the whole cell instead of just the meta... i can think of horrible, dirty things like template execution resulting in markdown, or, horror of horror, code (thanks, @tonyfast, for putting these thoughts in my head). --- JINJA(data=http://foo.bar/data.csv, body_part="brain")
My {{ body_part }} just exploded.
{% for line in data %}
- {{ line.text }}
{% endfor %} Secretly, this would stash the whole template in metadata... and this cell, much like imported cells, would not be editable... or rather, the generated text would be discarded on roundtrip.
Yeah, that's obvious now that you mention it: --- SUBSLIDE IMPORT(slides.md, moreslides.md) I might go a bit more verbose, if you're thinking magic names: def alias_cell_<name>(cell, *args, **kwargs):
def alias_nb_<name>(nb, *args, **kwargs): i wonder, if you would then all notebook meta come along? this would make it hard to overload, for example, a title or a theme (once slides support that). Perhaps the aliases can be used on either the opening or closing Great stuff brewing here that answers the mail on a lot of long-standing issues with the usability of the notebook format itself. My colleagues are certainly excited by notebooks with sane PRs, and even more so for reuse. Wearing my |
I am having a little difficulty parsing all of this. I am going to offer my two cents as far as the choice of markdown and yaml go. Use YAML always if a user will be entering their own keys and values. There are fewer mistakes than JSON. Also, the widespread adoption of things like Jekyll clearing indicate the ability for anyone to write JSON as YAML. As for Markdown, I do not think that language or tool specific markdown flavors scale for the future.
The Ipython notebook's future applications are rapidly growing. Many syntaxes, languages, and kernels can be used in the Ipython notebook. If the notebook is treated as syntax/language agnostic then a conversion to/from markdown should be too. Github Flavored Markdown is a proven language agnostic text document, see all the readmes. Github uses Github Flavored Markdown for syntax highlighting, but as a text document GFM indicates that a block of text that is following has a specific syntax. In this issue y'all mentioned slides, templates, kernels, and metadata. Each feature has a very different application in practice:
Very few users need all of these features. I believe that GFM's success as a language agnostic document should guide any extension of the Ipython notebook. I have been tinkering with converting GFM to Ipython Notebooks. From a readme.md, each block of markdown and code is transformed into an appropriate notebook cell using some Java(Coffee)script to create a readme.ipynb. The fenced code block languages are passed as cell magics. At this point, I believe anything in this issue can be described by GFM markdown.
This bl.ock shows some extensibility of the readme file where a Javascript Template tool passes YAML variables to the Markdown. One could imagine Reveal being used or the YAML being passed to the notebook metadata. |
I have been advocating for notebooks-as-presentations for some time, but the approach has some shortcomings. Slides are where users are knowlingly manipulating at least cell-level metadata. Thus, one of the key drivers here is making slide editing and management really, really approachable, in the style of showoff, ioslides, etc. I think we're in violent agreement that (GF)Markdown is teachable, mostly because it is readable but partially because it is diffable and mergeable to an extent beyond HTML and JSON. Basically, I (and others) have found that a directory of ipynb is not a long-term format for maintaining a family of docs, say a course, or a recurring meeting, or even the documentation for a decent-sized project. A "field reconsitutable" text representation that fully supports all features of the notebook format is the primary goal with the added goal of being more human-centric. It is In this vein of user-centricity, that this whole alias discussion started. I would rather maintain and train:
over
though maybe there is some other GFM-compatible way to do the former...
but each of these has its drawbacks. Anyhow, to the management point: I really, really want to be able to reuse sanely-versionable content and not rely on hacking javascript. The
It becomes more out of control at the notebook level, even assuming we used the just-one-frontmatter approach. I want this:
vs
I don't think that the best long term solution: the source needs to be as far removed from the details of the presentation engine as possible. I suspect at some point another, more modular slide framework will show up that supports most of the same concepts as reveal (heck, throw prezi in, too) but has better modularity, and definitely more stable and flexible archival generation. Further, if using IJavascript or ITorch, it would be difficult to determine the cell fenced blocks from the meta fenced blocks without introducing some other mime type... which would again defeat the editor's attempt to assist us.
That jinja examples was of what a plugin to ipymd could do, given access to the whole cell and not just the metadata. Basically, what could you do with a cell/notebook-level preprocessor that could modify what you see in the Notebook? |
Oh wow, I see where y'all are coming from now. Thanks for that description. I love the idea of the human-centric part. Largely, I have been focused on the ease of adoption and teaching, but you guys are at a much grander scale of interaction than I have been thinking. It'll take a bit to get on this level. Regardless, the example syntaxes like
look mightly similar to explicit and global tags in YAML. I have never applied them before, but they look analogous to some the suggestions above. |
No worries! I didn't even think of all the extra stuff yaml just does. The It looks the tags take uris which in python resolve to callables. Ignoring !!import somefile.md other: dataAnd if it can do round trip, this would just about solve the issue, and Also, i like the ---/... Start and end of a meta block... Much better for On 00:20, Tue, Jun 16, 2015 Tony Fast notifications@github.com wrote:
|
Do the YAML tags and Python types for Names, Classes, and Objects move you in the right direction? There are two examples that look similar
|
Heh, had a look at some of that stuff: ended up with this: We DON'T want to use the python namespace, because it can Do Horrible Things. Registering to the application-specific Otherwise, aside from not fully understanding how to handle missing stuff in JSON Patch, it's certainly looking pretty good! |
closed by #62 |
metadata = {}
which is just a Python dictionaryExamples of use-cases
Skip particular code lines in a given format(better to deal with this directly in a format reader/writer)How it works
ipymd-[a-zA-Z]+
, it defines the cell's metadataipymd-foo
oripymd-foo=bar
metadata fields on the lineipymd-foo
meansmetadata['foo'] = True
ipymd-foo=3
meansmetadata['foo'] = 3
The text was updated successfully, but these errors were encountered: