Skip to content
Snippets Groups Projects
Commit 1209fe8b authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

KG1: from_lesson isslanted

parent 7ef014e7
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ from formatitko.util import parse_string ...@@ -5,6 +5,7 @@ from formatitko.util import parse_string
from formatitko.context import Context from formatitko.context import Context
from formatitko.command import Command from formatitko.command import Command
from panflute import Element from panflute import Element
from formatitko.elements import Slanted
url = "https://kam.mff.cuni.cz/~jirikalvoda/vyuka/24z/kg1" url = "https://kam.mff.cuni.cz/~jirikalvoda/vyuka/24z/kg1"
...@@ -17,3 +18,21 @@ def head(element, context, proc): ...@@ -17,3 +18,21 @@ def head(element, context, proc):
def cmt(element, context, proc): def cmt(element, context, proc):
return [] return []
def make_emph(*elements, wrap_class=pf.Emph):
out = []
for e in elements:
if isinstance(e, pf.Para) or isinstance(e, pf.Plain):
out.append(type(e)(wrap_class(*e.content)))
elif isinstance(e, pf.BulletList) or isinstance(e, pf.OrderedList):
out.append(type(e)(*(pf.ListItem(*make_emph(*i.content, wrap_class=wrap_class)) for i in e.content)))
else:
print(e, type(e))
raise NotImplemented()
return out
def from_lesson(element, context, proc):
out = proc.transform(element.content)
return make_emph(*out, wrap_class=Slanted)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment