Пример #1
0
 def parse(cls, root: OrgNode, chap: str, sect: str) -> 'CardType':
     key, page = cls.keytitle(root)
     q, a = root.content
     assert q.heading.strip() == 'Question', q.heading
     assert a.heading.strip() == 'Solution', a.heading
     return Exercise(q=Tree.from_str(q.content),
                     a=Tree.from_str(a.content),
                     chap=chap,
                     sect=sect,
                     key=key,
                     page=page)
Пример #2
0
 def parse(cls, root: OrgNode, chap: str, sect: str,
           part: str) -> 'CardType':
     key, page = cls.keytitle(root)
     pp, pf = root.content
     assert pp.heading.strip() == 'Proposition'
     assert pf.heading.strip() == 'Proof'
     return Prop(prop=Tree.from_str(pp.content),
                 proof=Tree.from_str(pf.content),
                 chap=chap,
                 sect=sect,
                 part=part,
                 key=key,
                 page=page)
Пример #3
0
 def parse(cls, root: OrgNode, chap: str, sect: str,
           part: str) -> 'CardType':
     key, page = cls.keytitle(root)
     term, def_ = root.content
     assert term.heading.strip() == 'Term', term.heading
     assert def_.heading.strip() == 'Def', def_.heading
     return Def(term=Tree.from_str(term.content),
                def_=Tree.from_str(def_.content),
                chap=chap,
                sect=sect,
                part=part,
                key=key,
                page=page)
Пример #4
0
 def parse(root: OrgNode, chap: str, sect: str, part: str) -> 'CardType':
     key = root.heading.replace('<', '').replace('>', '').strip()
     return Example(x=Tree.from_str(root.content),
                    chap=chap,
                    sect=sect,
                    part=part,
                    key=key)