本文整理汇总了Python中yattag.Doc.tag方法的典型用法代码示例。如果您正苦于以下问题:Python Doc.tag方法的具体用法?Python Doc.tag怎么用?Python Doc.tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yattag.Doc
的用法示例。
在下文中一共展示了Doc.tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Method for inserting box to the html doc."""
doc = Doc()
with doc.tag('div',klass='box'):
if self.style:
doc.attr(style=self.style)
with doc.tag('div',klass='box content'):
if self.ctn_options:
doc.attr(style=self.ctn_options)
doc.asis(self.ctn)
self.put_caption(doc=doc)
return doc.getvalue()
示例2: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Method for inserting box to the html doc."""
doc = Doc()
with doc.tag("div", klass="box"):
if self.style:
doc.attr(style=self.style)
if self.cap_position == "TOP":
self.put_caption(doc=doc)
with doc.tag("div", klass="box content"):
if self.ctn_options:
doc.attr(style=self.ctn_options)
doc.asis(self.ctn)
if self.cap_position is None or self.cap_position == "BOTTOM":
self.put_caption(doc=doc)
return doc.getvalue()
示例3: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self, match, toc_depth=None, max_time=None, current=None):
"""Convert logo metadata to html stream.
Parameters
----------
match: re.match object
max_time: str
max time for presentation
Returns
-------
str:
html stream
"""
if 'toc' in self.name:
return self.toc_to_html(match=match, current=current, depth=int(toc_depth))
if 'logo' in self.name:
return self.logo_to_html(match)
elif 'timer' in self.name:
return self.timer_to_html(match=match, max_time=max_time)
elif 'custom' in self.name:
return self.custom_to_html(match)
else:
doc = Doc()
with doc.tag('span', klass='metadata'):
style = None
if match.group('style'):
style = str(match.group('style'))
if style:
doc.attr(style=style)
if isinstance(self.value, list):
doc.asis(', '.join(self.value))
else:
doc.asis(str(self.value))
return doc.getvalue()
示例4: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Method for inserting box to the html doc."""
doc = Doc()
with doc.tag('div',klass='note'):
if self.style:
doc.attr(style=self.style)
elif Note.theme.data.data['style'][0]:
doc.attr(style=Note.theme.data.data['style'][0])
self.put_caption(doc=doc)
with doc.tag('div',klass='note content'):
if self.ctn_options:
doc.attr(style=self.ctn_options)
elif Note.theme.data.data['content'][0]:
doc.attr(style=Note.theme.data.data['content'][0])
doc.asis(seditor.md_convert(self.ctn))
return doc.getvalue()
示例5: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self, metadata, style=None):
"""Method for producing and html string of selected metadata.
Parameters
----------
metadata : str
metadata key
style : str, optional
css style of metadata tag
Returns
-------
str
html string containing the metadata
>>> source = '---metadata authors = ["S. Zaghi","J. Doe"] ---endmetadata'
>>> meta = Metadata(source)
>>> meta.to_html(metadata='authors')
'<span class="metadata">S. Zaghi and J. Doe</span>'
"""
doc = Doc()
if metadata == 'logo':
self.put_logo(doc=doc,style=style)
else:
with doc.tag('span',klass='metadata'):
if style:
doc.attr(style=style)
doc.asis(self.get_value(metadata))
return doc.getvalue()
示例6: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Convert self data to its html stream."""
doc = Doc()
with doc.tag("div", id="note-" + str(self.number)):
if self.style:
doc.attr(style=self.style)
else:
doc.attr(klass="note")
if self.cap_position is None or self.cap_position.upper() == "TOP":
self.put_caption(doc=doc, klass="note-caption")
with doc.tag("div", klass="note-content"):
if self.ctn_options:
doc.attr(style=self.ctn_options)
doc.asis(markdown2html(self.ctn, no_p=True))
if self.cap_position is not None and self.cap_position.upper() == "BOTTOM":
self.put_caption(doc=doc, klass="note-caption")
return doc.getvalue()
示例7: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Convert self data to its html stream."""
if self.number > 0:
doc = Doc()
with doc.tag('div', klass='columns'):
for col, column in enumerate(self.columns):
with doc.tag('div', klass='column'):
doc.attr(('column-number', str(col + 1)))
style = 'display:block;float:left;'
if column[1]:
style += column[1]
else:
style += 'width:' + str(int(100.0 / self.number)) + '%;'
doc.attr(style=style)
doc.asis(markdown2html(source=column[0]))
return doc.getvalue()
return ''
示例8: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Convert self data to its html stream."""
doc = Doc()
with doc.tag('div', id='table-' + str(self.number)):
if self.style:
doc.attr(style=self.style)
else:
doc.attr(klass='table')
if self.cap_position is None or self.cap_position.upper() == 'TOP':
self.put_caption(doc=doc, klass='table-caption')
with doc.tag('div', klass='table-content'):
if self.ctn_options:
doc.attr(style=self.ctn_options)
doc.asis(markdown2html(self.ctn, no_p=True))
if self.cap_position is not None and self.cap_position.upper() == 'BOTTOM':
self.put_caption(doc=doc, klass='table-caption')
return doc.getvalue()
示例9: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self, config):
"""Generate a html stream of the whole presentation.
Parameters
----------
config : MatisseConfig
MaTiSSe configuration
"""
doc, tag, text = Doc().tagtext()
doc.asis('<!DOCTYPE html>')
with tag('html'):
# doc.attr(title=self.metadata['title'].value)
self.__put_html_tag_head(doc=doc, tag=tag, text=text, config=config)
with tag('body', onload="resetCountdown(" + str(self.metadata['max_time'].value) + ");"):
doc.attr(klass='impress-not-supported')
with tag('div', id='impress'):
# numbering: [local_chap, local_sec, local_subsec, local_slide]
current = [0, 0, 0, 0]
for chapter in self.chapters:
current[0] += 1
current[1] = 0
current[2] = 0
current[3] = 0
self.metadata['chaptertitle'].update_value(value=chapter.title)
self.metadata['chapternumber'].update_value(value=chapter.number)
for section in chapter.sections:
current[1] += 1
current[2] = 0
current[3] = 0
self.metadata['sectiontitle'].update_value(value=section.title)
self.metadata['sectionnumber'].update_value(value=section.number)
for subsection in section.subsections:
current[2] += 1
current[3] = 0
self.metadata['subsectiontitle'].update_value(value=subsection.title)
self.metadata['subsectionnumber'].update_value(value=subsection.number)
for slide in subsection.slides:
current[3] += 1
self.metadata['slidetitle'].update_value(value=slide.title)
self.metadata['slidenumber'].update_value(value=slide.number)
with doc.tag('div'):
chapter.put_html_attributes(doc=doc)
section.put_html_attributes(doc=doc)
subsection.put_html_attributes(doc=doc)
slide.put_html_attributes(doc=doc)
self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='header', current=current, overtheme=slide.overtheme)
# with doc.tag('div'):
# doc.attr(style='clear: both;')
self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='L', current=current, overtheme=slide.overtheme)
slide.to_html(doc=doc, parser=self.parser, metadata=self.metadata, theme=self.theme, current=current)
self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='R', current=current, overtheme=slide.overtheme)
# with doc.tag('div'):
# doc.attr(style='clear: both;')
self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='footer', current=current, overtheme=slide.overtheme)
self.__put_html_tags_scripts(doc=doc, tag=tag, config=config)
# source = re.sub(r"<li>(?P<item>.*)</li>", r"<li><span>\g<item></span></li>", source)
html = indent(doc.getvalue())
return html
示例10: timer_to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def timer_to_html(self, match, max_time):
"""Convert custom metadata to html stream.
Parameters
----------
match: re.match object
max_time: str
Returns
-------
str:
html stream
"""
doc = Doc()
with doc.tag('span', klass='timercontainer'):
style = None
if match.group('style'):
style = str(match.group('style'))
if style:
doc.attr(style=style)
with doc.tag('div', klass='countDown'):
with doc.tag('div'):
doc.attr(klass='timer')
if style:
if 'controls' in style:
with doc.tag('div', klass='timercontrols'):
with doc.tag('input', type='button'):
doc.attr(klass='btn reset', onclick='resetCountdown(' + str(max_time) + ');', value=' ⟳ ', title='reset')
with doc.tag('input', type='button'):
doc.attr(klass='btn stop', onclick='stopCountdown();', value=' ◼ ', title='pause')
with doc.tag('input', type='button'):
doc.attr(klass='btn start', onclick='startCountdown();', value=' ▶ ', title='start')
return doc.getvalue().replace('amp;', '')
示例11: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Convert self data to its html stream."""
doc = Doc()
with doc.tag('div', id='Figure-' + str(self.number)):
if self.style:
doc.attr(style=self.style)
else:
doc.attr(klass='figure')
with doc.tag(self.ctn_type):
if self.cap_position is not None and self.cap_position.upper() == 'TOP':
self.put_caption(doc=doc, klass='figure-caption')
if self.ctn_options:
doc.stag('img', src=self.ctn, klass='figure-content', style=self.ctn_options, alt='Figure-' + self.ctn)
else:
doc.stag('img', src=self.ctn, klass='figure-content', style='width:100%;', alt='Figure-' + self.ctn)
if self.cap_position is None or self.cap_position.upper() == 'BOTTOM':
self.put_caption(doc=doc, klass='figure-caption')
return doc.getvalue()
示例12: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Method for inserting box to the html doc."""
doc = Doc()
with doc.tag('div',klass='figure'):
doc.attr(('id','Figure-'+str(self.number)))
if self.style:
doc.attr(style=self.style)
elif Figure.theme.data.data['style'][0]:
doc.attr(style=Figure.theme.data.data['style'][0])
with doc.tag(self.ctn_type):
if self.ctn_options:
doc.stag('img',src=self.ctn,klass='image',style=self.ctn_options,alt='Figure-'+self.ctn)
elif Figure.theme.data.data['content'][0]:
doc.stag('img',src=self.ctn,klass='image',style=Figure.theme.data.data['content'][0],alt='Figure-'+self.ctn)
else:
doc.stag('img',src=self.ctn,klass='image',style='width:100%;',alt='Figure-'+self.ctn)
self.put_caption(doc=doc)
return doc.getvalue()
示例13: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Convert self data to its html stream."""
doc = Doc()
with doc.tag('div', id='video-' + str(self.number)):
if self.style:
doc.attr(style=self.style)
else:
doc.attr(klass='video')
if self.cap_position is not None and self.cap_position.upper() == 'TOP':
self.put_caption(doc=doc, klass='video-caption')
with doc.tag('video', klass='video-content', controls=''):
if self.ctn_options:
doc.attr(style=self.ctn_options)
else:
doc.attr(style='width:100%;')
doc.stag('source', src=self.ctn)
if self.cap_position is None or self.cap_position.upper() == 'BOTTOM':
self.put_caption(doc=doc, klass='video-caption')
return doc.getvalue()
示例14: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Method for inserting columns to the html doc."""
if self.number > 0:
doc = Doc()
with doc.tag('div',klass='columns'):
for col,column in enumerate(self.columns):
with doc.tag('div',klass='column'):
doc.attr(('column-number',str(col+1)))
style = 'display:block;float:left;'
if column[1]:
style += column[1]
else:
style += 'width:'+str(int(100.0/self.number))+'%;'
doc.attr(style=style)
content = box_parse(column[0])
content = figure_parse(content)
content = table_parse(content)
content = note_parse(content)
doc.asis(seditor.md_convert(content))
return doc.getvalue()
return ''
示例15: to_html
# 需要导入模块: from yattag import Doc [as 别名]
# 或者: from yattag.Doc import tag [as 别名]
def to_html(self):
"""Method for inserting columns to the html doc."""
if self.number > 0:
doc = Doc()
with doc.tag("div", klass="columns"):
for col, column in enumerate(self.columns):
with doc.tag("div", klass="column"):
doc.attr(("column-number", str(col + 1)))
style = "display:block;float:left;"
if column[1]:
style += column[1]
else:
style += "width:" + str(int(100.0 / self.number)) + "%;"
doc.attr(style=style)
content = box_parse(column[0])
content = figure_parse(content)
content = table_parse(content)
content = note_parse(content)
doc.asis(seditor.md_convert(content))
return doc.getvalue()
return ""