当前位置: 首页>>代码示例>>Python>>正文


Python E.h1方法代码示例

本文整理汇总了Python中lxml.html.builder.E.h1方法的典型用法代码示例。如果您正苦于以下问题:Python E.h1方法的具体用法?Python E.h1怎么用?Python E.h1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lxml.html.builder.E的用法示例。


在下文中一共展示了E.h1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_content

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import h1 [as 别名]
 def build_content(self):
     assert self.meta.title
     super().build_content()
     self.elements.content.append(E.h1(self.meta.title))
     self.build_title_content()
开发者ID:chfoo,项目名称:wuff,代码行数:7,代码来源:html.py

示例2: main

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import h1 [as 别名]

#.........这里部分代码省略.........
        head.extend(mathjax(standalone=standalone))

        # ----------------------------------------------------------------------
        info("Add Font Awesome support")
        head.extend(font_awesome(standalone=standalone))

        # ----------------------------------------------------------------------
        info("Add artdoc css & js files")
        head.extend(artdoc())

        # ----------------------------------------------------------------------
        info("Setting language to english (required for hyphens)")
        html.set("lang", "en") 

        # ----------------------------------------------------------------------
        info("Ensure ids uniqueness")
        id_count = {}
        for elt in html.iter():
          _id = elt.get("id")
          if _id is not None:
             count = id_count.get(_id, 0)
             if count > 0:
                 elt.set("id", _id + "-" + str(count))
             id_count[_id] = count + 1

        # ----------------------------------------------------------------------
        info("Turning headers into self-links")
        sections = html.cssselect("section")
        for section in sections:
            id_ = section.get("id")
            heading = None
            if len(section):
                first = section[0]
                if first.tag in "h1 h2 h3 h4 h5 h6".split():
                    heading = first
            if id_ and heading is not None:
                contents = [heading.text or ""] + heading[:]
                heading.text, heading[:] = None, []
                href = {"href": "#" + id_}
                link = HTML.a(href, *contents)
                heading.insert(0, link)

        # ----------------------------------------------------------------------


        # TODO: deal with metadata & insert a document header with:
        #   - title, 
        #   - date (format: Month Day, Year), autoformat, autogen ? 
        #   - author(s) (with mail & affiliation when available ?).
        #     Assume custom metadata or parse the author field ?
        #     Representation of multiple authors ? MMm eLIFEsciences use
        #     popup for author info. Ex: http://elifesciences.org/content/4/e06356 !
        #     here, use hints from http://dtd.nlm.nih.gov/book/tag-library/:
        #
        #       - name (don't be more precise)
        #       - affiliation (concatenate)
        #       - address ???
        #       - email  --> Font Awesome Icon
        #       - url / uri ?
        #       - form of ID ? (like HAL ? or ZBlatt ?)



        # TODO: look at the rendering of
        #       http://kieranhealy.org/blog/archives/2014/01/23/plain-text/:
        #         - small grey date on top, bold title, bold author name,
开发者ID:boisgera,项目名称:artdoc,代码行数:70,代码来源:__init__.py


注:本文中的lxml.html.builder.E.h1方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。