Commit 8d9f884d authored by Ingo Heimbach's avatar Ingo Heimbach

Added a `jupyter-outbox` directive

parent 86964a94
from .code_directive import CodeBlock
from .embedded_image_directive import EmbeddedImage
from .jupyter_outbox_directive import JupyterOutbox
from .tikz_directive import Tikz, TikzFigure
from .output_mode import get_output_mode, set_output_mode
__all__ = ("CodeBlock", "EmbeddedImage", "Tikz", "TikzFigure", "get_output_mode", "set_output_mode")
__all__ = ("CodeBlock", "EmbeddedImage", "JupyterOutbox", "Tikz", "TikzFigure", "get_output_mode", "set_output_mode")
from docutils import nodes
from docutils.parsers.rst import Directive
class JupyterOutbox(Directive):
required_arguments = 0
optional_arguments = 0
final_argument_whitespace = False
option_spec = {}
has_content = True
def run(self):
content = u"\n".join(self.content)
latex = u"\\begin{{minted}}[bgcolor=white,breakanywhere=true,breaklines=true,linenos=false]{{text}}\n{}\n\\end{{minted}}".format(content)
return [nodes.raw("", latex, format="latex")]
......@@ -18,6 +18,7 @@ except:
from docutils.core import publish_cmdline, default_description
from docutils.parsers.rst import directives
from docutils.parsers.rst.directives.body import ParsedLiteral
from ..directives import EmbeddedImage, Tikz, TikzFigure, set_output_mode
......@@ -27,6 +28,7 @@ description = "Generates (X)HTML documents from standalone reStructuredText " "s
def main():
set_output_mode("html")
directives.register_directive("embedded-image", EmbeddedImage)
directives.register_directive("jupyter-outbox", ParsedLiteral)
directives.register_directive("tikz", Tikz)
directives.register_directive("tikz-figure", TikzFigure)
publish_cmdline(writer_name="html", description=description)
......
......@@ -19,7 +19,7 @@ except:
from docutils.core import publish_cmdline
from docutils.parsers.rst import directives
from ..directives import CodeBlock, EmbeddedImage, Tikz, TikzFigure, set_output_mode
from ..directives import CodeBlock, EmbeddedImage, JupyterOutbox, Tikz, TikzFigure, set_output_mode
description = (
......@@ -37,6 +37,7 @@ def main():
for directive_name in ("code", "code-block"):
directives.register_directive(directive_name, CodeBlock)
directives.register_directive("embedded-image", EmbeddedImage)
directives.register_directive("jupyter-outbox", JupyterOutbox)
directives.register_directive("tikz", Tikz)
directives.register_directive("tikz-figure", TikzFigure)
publish_cmdline(writer_name="latex", description=description)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment