-
Notifications
You must be signed in to change notification settings - Fork 96
📥 Fix embedding raw code with remove-input
flag
#1937
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f8cb8ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
remove-input
flagremove-input
flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some brief documentation to clarify this for future reference.
This looks fine to merge to me, assuming the logic you're following to detect a notebook cell is correct. My one suggestion would be to add a test to make sure that this is behaving as expected, but I don't think it's strictly required if you are confident that this fixes the bug.
return !( | ||
n.type === 'code' && | ||
parent?.type === 'block' && | ||
parent?.kind === NotebookCell.code | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous logic had a special case for code-nodes that were tagged as outputs. Now, we want to be even stricter --- only code nodes that are children of code-cells and not tagged as outputs.
// should be removed | ||
return !( | ||
n.type === 'code' && | ||
n.data?.type !== 'output' && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fwkoch I don't think I need this test for n.data.type
actually, because reduceOutputs
is always called after this transform runs. Shouldn't this mean we'll never see reduced outputs here?
@@ -35,13 +36,28 @@ function mutateEmbedNode( | |||
const { url, dataUrl, targetFile, sourceFile } = opts ?? {}; | |||
if (targetNode && node['remove-output']) { | |||
targetNode = filter(targetNode, (n: GenericNode) => { | |||
// After reduction, 'output' nodes may be replaced by their children which are then tagged as outputs | |||
return n.type !== 'output' && n.data?.type !== 'output'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See lower comment about reduceOutputs
"exports": [ | ||
{ | ||
"format": "md", | ||
"filename": "index.md", | ||
"url": "/index-52e2bc751b3bb2cb9ed25191a3951cf9.md" | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auxiliary test changes
69f24df
to
f8cb8ec
Compare
@fwkoch I am not 100% clear on the When you get a moment, could you take this over the line and add in-line comments to explain for future reference? |
Fixes #1932