Commit 5b783b7d authored by Tobias ferrari's avatar Tobias ferrari

.

parent ae483706
......@@ -4,7 +4,8 @@ from .jupyter_outbox_directive import JupyterOutbox
from .tikz_directive import Tikz, TikzFigure
from .output_mode import get_output_mode, set_output_mode
from .rst_checkboxes_directive import RSTCheckBox
from .rst_tags_directive import RSTTag
__all__ = ("CodeBlock", "EmbeddedImage", "EmbeddedFigure", "JupyterOutbox", "Tikz", "TikzFigure", "get_output_mode",
"set_output_mode", "RSTCheckBox")
"set_output_mode", "RSTCheckBox", "RSTTag")
from __future__ import unicode_literals
from docutils import nodes
from docutils.parsers.rst import Directive
from .output_mode import get_output_mode
class RSTCheckBox(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)
lines = content.split("\n")
......@@ -32,11 +33,11 @@ class RSTCheckBox(Directive):
html += "</ul>"
return [nodes.raw("", html, format="html")]
else:
latex = "\\begin{todolist}"
latex = "\\begin{itemize}"
for line in lines:
if "- [ ]" in line:
latex += "\\item" + line[6:] + "\n"
latex += "\\item[\u2610]" + line[6:] + "\n"
elif "- [x]" in line:
latex += "\\item[\\checked]" + line[6:] + "\n"
latex += "\\end{todolist}"
latex += "\\item[\u2611]" + line[6:] + "\n"
latex += "\\end{itemize}"
return [nodes.raw("", latex, format="latex")]
......@@ -19,7 +19,7 @@ except:
from docutils.core import publish_cmdline
from docutils.parsers.rst import directives
from ..directives import CodeBlock, EmbeddedImage, EmbeddedFigure, JupyterOutbox, Tikz, TikzFigure, set_output_mode
from ..directives import CodeBlock, EmbeddedImage, EmbeddedFigure, JupyterOutbox, Tikz, TikzFigure, set_output_mode, RSTCheckBox, RSTTag
description = (
......@@ -41,6 +41,8 @@ def main():
directives.register_directive("jupyter-outbox", JupyterOutbox)
directives.register_directive("tikz", Tikz)
directives.register_directive("tikz-figure", TikzFigure)
directives.register_directive("checkboxes", RSTCheckBox)
directives.register_directive("rsttag", RSTTag)
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