def from_notebook_node(self, nb, resources=None, **kw): langinfo = nb.metadata.get('language_info', {}) lexer = langinfo.get('pygments_lexer', langinfo.get('name', None)) highlight_code = self.filters.get('highlight_code', Highlight2Latex(pygments_lexer=lexer, parent=self)) self.register_filter('highlight_code', highlight_code) return super(LatexExporter, self).from_notebook_node(nb, resources, **kw)
def from_notebook_node(self, nb, resources=None, **kw): langinfo = nb.metadata.get("language_info", {}) lexer = langinfo.get("pygments_lexer", langinfo.get("name", None)) highlight_code = self.filters.get( "highlight_code", Highlight2Latex(pygments_lexer=lexer, parent=self) ) self.register_filter("highlight_code", highlight_code) return super().from_notebook_node(nb, resources, **kw)
def from_notebook_node(self, nb, resources=None, **kw): # ********************************************** # # From LatexExporter # https://github.com/jupyter/nbconvert/blob/master/nbconvert/exporters/latex.py langinfo = nb.metadata.get("language_info", {}) lexer = langinfo.get("pygments_lexer", langinfo.get("name", None)) highlight_code = self.filters.get( "highlight_code", Highlight2Latex(pygments_lexer=lexer, parent=self) ) self.register_filter("highlight_code", highlight_code) # ********************************************** # # ***************** CUSTOM CODE **************** # # call the overridden from_notebook_node latex, resources = super()._from_notebook_node_override( nb, resources=resources, **kw ) # ********************************************** # # ********************************************** # # From PDFExporter # set texinputs directory, so that local files will be found if resources and resources.get("metadata", {}).get("path"): self.texinputs = resources["metadata"]["path"] else: self.texinputs = getcwd() self._captured_outputs = [] with TemporaryWorkingDirectory(): notebook_name = "notebook" resources["output_extension"] = ".tex" tex_file = self.writer.write(latex, resources, notebook_name=notebook_name) self.log.info("Building PDF") self.run_latex(tex_file) if self.run_bib(tex_file): self.run_latex(tex_file) pdf_file = notebook_name + ".pdf" if not os.path.isfile(pdf_file): raise LatexFailed("\n".join(self._captured_output)) self.log.info("PDF successfully created") with open(pdf_file, "rb") as f: pdf_data = f.read() # convert output extension to pdf # the writer above required it to be tex resources["output_extension"] = ".pdf" # clear figure outputs, extracted by latex export, # so we don't claim to be a multi-file export. resources.pop("outputs", None) return pdf_data, resources
def from_notebook_node(self, nb, resources=None, **kw): # ********************************************** # # From LatexExporter # https://github.com/jupyter/nbconvert/blob/master/nbconvert/exporters/latex.py langinfo = nb.metadata.get("language_info", {}) lexer = langinfo.get("pygments_lexer", langinfo.get("name", None)) highlight_code = self.filters.get( "highlight_code", Highlight2Latex(pygments_lexer=lexer, parent=self)) self.register_filter("highlight_code", highlight_code) # ********************************************** # # ***************** CUSTOM CODE **************** # return super()._from_notebook_node_override(nb, resources, **kw)
def from_notebook_node(self, nb, resources=None, **kw): langinfo = nb.metadata.get('language_info', {}) lexer = langinfo.get('pygments_lexer', langinfo.get('name', None)) self.register_filter('highlight_code', Highlight2Latex(pygments_lexer=lexer, parent=self)) lenvslatexpreprocessor = LenvsLatexPreprocessor() self.register_preprocessor(lenvslatexpreprocessor, enabled=True) self._init_preprocessors() nb, resources = lenvslatexpreprocessor(nb, resources) output, resources = super(LenvsLatexExporter, self).from_notebook_node(nb, resources, **kw) # noqa postout = self.postprocess(output) #print(postout[0:200]) #WORKS return postout, resources