-
-
Notifications
You must be signed in to change notification settings - Fork 23
support different languages #340
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -141,19 +141,6 @@ def depart_document(self, node): | |||||
self.output.metadata.celltoolbar = "Slideshow" | ||||||
|
||||||
|
||||||
# Update metadata | ||||||
if self.jupyter_kernels is not None: | ||||||
try: | ||||||
self.output.metadata.kernelspec = \ | ||||||
self.jupyter_kernels[self.lang]["kernelspec"] | ||||||
self.output.metadata["filename"] = self.source_file_name.split("/")[-1] | ||||||
self.output.metadata["title"] = self.title | ||||||
except: | ||||||
self.warn( | ||||||
"Invalid jupyter kernels. " | ||||||
"jupyter_kernels: {}, lang: {}" | ||||||
.format(self.jupyter_kernels, self.lang)) | ||||||
|
||||||
def visit_highlightlang(self, node): | ||||||
lang = node.attributes["lang"].strip() | ||||||
if lang in self.jupyter_kernels: | ||||||
|
@@ -205,14 +192,20 @@ def visit_literal_block(self, node): | |||||
self.in_code_block = True | ||||||
self.code_lines = [] | ||||||
|
||||||
# If the cell being processed contains code written in a language other than the one that | ||||||
# was specified as the default language, do not create a code block for it - turn it into | ||||||
# markup instead. | ||||||
if self.nodelang != self.langTranslator.translate(self.lang): | ||||||
# Update metadata | ||||||
if self.jupyter_kernels is not None and not self.output.metadata: | ||||||
if self.nodelang in self.jupyter_lang_synonyms: | ||||||
pass | ||||||
else: | ||||||
self.output_cell_type = JupyterOutputCellGenerators.MARKDOWN | ||||||
self.nodelang = self.default_lang | ||||||
try: | ||||||
self.output.metadata.kernelspec = \ | ||||||
self.jupyter_kernels[self.nodelang]["kernelspec"] | ||||||
self.output.metadata["filename"] = self.source_file_name.split("/")[-1] | ||||||
self.output.metadata["title"] = self.title | ||||||
except: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a bare
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
self.warn( | ||||||
"Invalid jupyter kernels. " | ||||||
"jupyter_kernels: {}, lang: {}" | ||||||
.format(self.jupyter_kernels, self.nodelang)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modifying Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
|
||||||
def depart_literal_block(self, node): | ||||||
if self.solution and self.jupyter_drop_solutions: | ||||||
|
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 condition
not self.output.metadata
will be false if metadata exists but is empty (e.g., an empty dict). This could prevent kernelspec updates for subsequent code cells. Consider using a more specific check like tracking whether kernelspec has been set.Copilot uses AI. Check for mistakes.