Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Ferrari
doc-utils
Commits
5b783b7d
Commit
5b783b7d
authored
May 03, 2019
by
Tobias ferrari
Browse files
.
parent
ae483706
Changes
3
Hide whitespace changes
Inline
Side-by-side
docutils_extended/directives/__init__.py
View file @
5b783b7d
...
...
@@ -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"
)
docutils_extended/directives/rst_checkboxes_directive.py
View file @
5b783b7d
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"
)]
docutils_extended/writers/rst2latex_extended.py
View file @
5b783b7d
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment