Commit 69441cfd authored by Tobias ferrari's avatar Tobias ferrari

checkboxes in html are now read-only

parent 259ba226
from docutils import nodes
from docutils.parsers.rst import Directive
from .output_mode import get_output_mode
class RSTCheckBox(Directive):
......@@ -12,11 +13,30 @@ class RSTCheckBox(Directive):
def run(self):
content = u"\n".join(self.content)
lines = content.split("\n")
html = "<ul>"
for line in lines:
if "- [ ]" in line:
html += "<li>" + line[6:] + "</li>"
elif "- [x]" in line:
html += "<li>" + line[6:] + "</li>"
html += "</ul>"
return [nodes.raw("", html, format="html")]
is_output_mode_html = get_output_mode() == "html"
if is_output_mode_html:
html = "<ul>\n"
for line in lines:
if "- [ ]" in line:
html += (
'<li style="list-style:none;margin: 0.31em 0 0.2em -1.3em;"><input type="checkbox" class="task-list-item-checkbox " onclick=\"return false;\">'
+ line[6:]
+ "</li>\n"
)
elif "- [x]" in line:
html += (
'<li style ="list-style:none;margin: 0.31em 0 0.2em -1.3em;"><input type="checkbox" class="task-list-item-checkbox " checked onclick=\"return false;\">'
+ line[6:]
+ "</li>\n"
)
html += "</ul>"
return [nodes.raw("", html, format="html")]
else:
latex = "\\begin{itemize}\n"
for line in lines:
if "- [ ]" in line:
latex += "\\item" + line[6:] + "\n"
elif "- [x]" in line:
latex += "\\item" + line[6:] + "\n"
latex += "\\end{itemize}"
return [nodes.raw("", latex, format="latex")]
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