-
Notifications
You must be signed in to change notification settings - Fork 391
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
Hide metadata header in markdown #527
Comments
Hello, thank you @sammorley-short ! Yes that's a great idea - we were discussing something like that yesterday at #517. We were thinking of adding a new option, possibly Note that, with the current version of Jupytext, you can make the following choice: include, or not, the notebook metadata. If you want to give that a try, uncheck 'Include metadata' in either the Jupytext Menu (Jupyter Notebook) or the Jupyter commands (Jupyter Labs), or execute
|
My use-case here is that we are actually deprecating the use of jupyter notebooks altogether by converting any we have to markdown. We do this by initially pairing any notebooks that currently exists, then unpairing them and finally deleting the old notebooks. That way, the markdown versions can be version controlled as well as rendered in GUIs such as GitLab, but anyone who wants to run them as notebooks can simply use the jupytext extension to edit and run them as notebooks. Given this workflow, would removing the notebook metadata work? I assumed that this was needed to distinguish between a "jupytext" markdown file and a standard one. If this is not the case, then presumably your solution should work perfectly 🙂. With regards to the way of hiding the metadata, I think the HTML solution would work fine. But out of interest, why would one not simply encapsulate it in a markdown comment? |
Impressive! Yes that is an option now, especially if you don't need the outputs in GitHub/GitLab.
(and if you want to rewrite the full history, have a look at https://jupytext.readthedocs.io/en/latest/faq.html#can-i-re-write-my-git-history-to-use-text-files-instead-of-notebooks ) The header is not required, in the sense that
By HTML comment I mean something like the below. Maybe we are using different names for the same thing? Otherwise I'd be curious to know how you do markdown comments!
|
Ah, apologies. I am not an HTML programmer I had assumed that "HTML comment" meant something encapsulated by HTML tags. But the above comment format would be ideal! Nice! |
@sammorley-short https://discourse.jupyter.org/t/jupyter-and-github-alternative-file-formant/4972/31 in this thread, we're discussing ability to plug format like yours to backend of jupyter and make jupyter itself save and load notebooks from text-readable files. Would that work for your use case? I've made very similar prototype to yours, but I'm wondering if MyST format isn't better in this case as it has yaml blocks in the syntax rather than hacks with html comments, but I understand that this can be rendered with existing tools. |
@choldgraf , @chrisjsewell , I plan to address this issue soon. Starting from Jupytext 1.6.0, the metadata header in Jupytext Markdown notebooks will look like this:
and thus the metadata will be hidden on GitHub and also when the Notebooks that were created with Jupytext < 1.6.0, when opened with Jupytext >= 1.6.0, would get an option Now my question for you, @choldgraf and @chrisjsewell: would you like me to do the same for the MyST-Markdown format? |
eurgh, my intuitive sense is this may break myst 😕 Is there reasons you are doing this other than the discussion in this issue? |
yeah my 2 cents is actually that commenting out the top-level metadata in a markdown file is not a great idea. It's a standard practice across many different communities and technologies. I think a better approach would be to have the default as "shown" and let |
Thanks @choldgraf , that is probably much wiser than what I described in my previous comment 😄 I'll do this way, then.
I was aware of the table-like representation of GitHub for the YAML header, but I had missed the VS Code preview... very nice indeed. Thanks @chrisjsewell |
@inc0 We're actually hosting our code on GitLab, so although it sounds great, this wouldn't be applicable in my case. Either way, if you can configure jupytext to keep the metadata in an HTML comment, then this would solve the issue in a renderer-independent way. This seems like a good alternative solution for renderers that don't do this (yet). |
But gitlab does recognise front matter https://docs.gitlab.com/ee/user/markdown.html#front-matter? |
@chrisjsewell: It recognises it, but it is still displayed as-is. For example, see here: https://gitlab.com/gitlab-org/gitlab/blob/master/doc/README.md. Being able to wrap the data in an HTML comment rather than the other delimiters would hide it from such renderings. |
Hi @sammorley-short , Jupytext 1.6.0 will have an option It will take me a few more weeks to release that version, so if you wish to give a try to the dev version, with
|
Hi @mwouts thanks for your work. But I failed to run jupytext with
My version is |
Oh, I see! It is always a challenge to document how to use these options... Since
If you want this for all the notebooks in a given repository, you can also create a
|
@mwouts Thanks! |
I am using the latest version to date: 1.15.2. Anyway, I have commented the header of a paired markdown file: is this going to be overwritten once the paired notebook is updated? |
Is it possible, or would it be possible to hide the metedata header added when reading and writing to markdown?
For example, this is the header on one markdown document:
Instead, it would be great if this could be put in an inline comment so that it isn't visible when the document is rendered outside of jupyter.
(P.s. thank you very much for your work on this, it is a really excellent plugin you've built here 😄)
The text was updated successfully, but these errors were encountered: