Пример #1
0
 def html_line(self, name, rightSide):
     lhs_html = name
     unofficialNameKindContext = None
     kind = proveItMagic.kind
     if kind in ('axioms', 'theorems', 'common'):
         if kind=='axioms' or kind=='theorems': kind = kind[:-1]
         unofficialNameKindContext = (name, kind, proveItMagic.context)
     rightSideStr, expr = None, None
     if isinstance(rightSide, Expression):
         expr = rightSide
         rightSideStr = rightSide._repr_html_(unofficialNameKindContext=unofficialNameKindContext)
     elif hasattr(rightSide, '_repr_html_'):
         rightSideStr = rightSide._repr_html_()
     if rightSideStr is None:
         rightSideStr = str(rightSide)
     if proveItMagic.kind == 'theorems':
         assert expr is not None, "Expecting an expression for the theorem"
         proof_notebook_relurl = proveItMagic.context.thmProofNotebook(name, expr)
         lhs_html = '<a class="ProveItLink" href="%s">%s</a>'%(proof_notebook_relurl, lhs_html)
     html = '<strong id="%s">%s:</strong> %s<br>'%(name, lhs_html, rightSideStr)
     if self.beginningProof:
         expr_notebook_path = proveItMagic.context.expressionNotebook(expr)
         dependencies_notebook_path = os.path.join(os.path.split(expr_notebook_path)[0], 'dependencies.ipynb')
         html += '(see <a class="ProveItLink" href="%s">dependencies</a>)<br>'%(relurl(dependencies_notebook_path))
     if (kind in ('axiom', 'theorem', 'common')) and len(proveItMagic.expr_names[rightSide])>1:
         prev = proveItMagic.expr_names[rightSide][-2]
         if kind == 'theorem':
             html += '(alternate proof for <a class="ProveItLink" href="#%s">%s</a>)<br>'%(prev, prev)
         elif kind=='axiom':
             print('WARNING: Duplicate of', prev)
     return html
Пример #2
0
 def generateContents(contexts):
     if len(contexts)==0: return ''
     html = '<ul>\n'        
     for context in contexts:
         href = relurl(os.path.join(context.getPath(), '_context_.ipynb'))
         html += '<li><a class="ProveItLink" href="%s">%s</a></li>\n'%(href, context.name)
         html += generateContents(list(context.getSubContexts()))
     return html + '</ul>\n'