本文整理汇总了Python中yattag.Doc.text方法的典型用法代码示例。如果您正苦于以下问题:Python Doc.text方法的具体用法?Python Doc.text怎么用?Python Doc.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yattag.Doc
的用法示例。
在下文中一共展示了Doc.text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import text [as 别名]
def to_html(self):
"""Method for producing and html string document from presentation object."""
doc, tag, text = Doc().tagtext()
doc.asis('<!DOCTYPE html>')
with tag('html'):
doc.attr(title = self.metadata.data.data['title'][0])
with tag('head'):
doc.stag('meta',charset='utf-8')
doc.stag('meta',author=' and '.join(self.metadata.data.data['authors'][0]))
with tag('title'):
text(self.metadata.data.data['title'][0])
doc.stag('meta',subtitle=self.metadata.data.data['subtitle'][0])
doc.stag('link',rel='stylesheet', href='css/normalize.css')
if __config__.highlight:
doc.stag('link',rel='stylesheet', href='js/highlight/styles/'+__config__.highlight_style)
doc.stag('link',rel='stylesheet', href='css/theme.css')
with tag('body',onload="resetCountdown("+self.metadata.data.data['max_time'][0]+");"):
with tag('div',id='impress'):
if self.titlepage.found:
html = self.titlepage.to_html(position = self.pos, theme = self.theme.slide)
html = self.metadata.parse(html)
html = self.toc.parse(html)
doc.asis(html)
for section in self.sections:
for subsection in section.subsections:
for slide in subsection.slides:
html = slide.to_html(position = self.pos, theme = self.theme.slide)
html = self.metadata.parse(html)
html = self.toc.parse(html,current=[int(slide.data['sectionnumber']),int(slide.data['subsectionnumber']),slide.number])
doc.asis(html)
with tag('script'):
doc.attr(src='js/countDown.js')
with tag('script'):
doc.attr(src='js/impress.js')
with tag('script'):
doc.asis('impress().init();')
if __config__.online_mathjax:
with tag('script'):
doc.attr(('type','text/javascript'))
doc.attr(src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML')
else:
with tag('script'):
doc.attr(('type','text/x-mathjax-config'))
doc.text("""
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},
"HTML-CSS": { availableFonts: ["Neo-Euler"] }
});
""")
with tag('script'):
doc.attr(('type','text/javascript'))
doc.attr(src='js/MathJax/MathJax.js')
if __config__.highlight:
with tag('script'):
doc.attr(src='js/highlight/highlight.pack.js')
with tag('script'):
doc.text("""hljs.initHighlightingOnLoad();""")
if __config__.indented:
return indent(doc.getvalue())
else:
return doc.getvalue()