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


Python pandocfilters.Span方法代码示例

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


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

示例1: join_strings

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import Span [as 别名]
def join_strings(key, value, fmt=None, meta=None):
    """Joins adjacent Str elements found in `value`."""
    if key in ['Para', 'Plain']:
        _join_strings(value)
    elif key == 'Span':
        _join_strings(value, 1)
    elif key == 'Image':
        _join_strings(value[-2])
    elif key == 'Table':
        _join_strings(value[-5])


# repair_refs() -------------------------------------------------------------

# Reference pattern.  This splits a reference into three components: the
# prefix, label and suffix.  e.g.:
# >>> _REF.match('xxx{+@fig:1}xxx').groups()
# ('xxx{+', 'fig:1', '}xxx'). 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:20,代码来源:core.py

示例2: insert_secnos_factory

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import Span [as 别名]
def insert_secnos_factory(f):
    """Returns insert_secnos(key, value, fmt, meta) action that inserts
    section numbers into the attributes of elements of type `f`.
    """

    # Get the name and standard length
    name = f.__closure__[0].cell_contents
    n = f.__closure__[1].cell_contents

    def insert_secnos(key, value, fmt, meta):  # pylint: disable=unused-argument
        """Inserts section numbers into elements attributes."""

        global _sec  # pylint: disable=global-statement

        if key == 'Header':
            if 'unnumbered' in value[1][1]:
                return
            if value[0] == 1:
                _sec += 1
        if key == name:

            # Only insert if attributes are attached.  Images always have
            # attributes for pandoc >= 1.16. Same for Spans.
            assert len(value) <= n+1
            if (name == 'Image' and len(value) == 3) or name == 'Div' or \
                name == 'Span' or len(value) == n+1:
                # Make sure value[0] represents attributes
                assert isinstance(value[0][0], STRTYPES)
                assert isinstance(value[0][1], list)
                assert isinstance(value[0][2], list)

                # Insert the section number into the attributes
                value[0][2].insert(0, ['secno', _sec])

    return insert_secnos


# delete_secnos_factory() ---------------------------------------------------- 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:40,代码来源:core.py

示例3: delete_secnos_factory

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import Span [as 别名]
def delete_secnos_factory(f):
    """Returns delete_secnos(key, value, fmt, meta) action that deletes
    section numbers from the attributes of elements of type `f`.
    """

    # Get the name and standard length
    name = f.__closure__[0].cell_contents
    n = f.__closure__[1].cell_contents

    def delete_secnos(key, value, fmt, meta):  # pylint: disable=unused-argument
        """Deletes section numbers from elements attributes."""

        # Only delete if attributes are attached.   Images always have
        # attributes for pandoc >= 1.16. Same for Spans.
        if key == name:
            assert len(value) <= n+1
            if (name == 'Image' and len(value) == 3) or name == 'Div' or \
                name == 'Span' or len(value) == n+1:

                # Make sure value[0] represents attributes
                assert isinstance(value[0][0], STRTYPES)
                assert isinstance(value[0][1], list)
                assert isinstance(value[0][2], list)

                # Remove the secno attribute
                if value[0][2] and value[0][2][0][0] == 'secno':
                    del value[0][2][0]

    return delete_secnos


# install_rawblock_factory() ------------------------------------------------- 
开发者ID:tomduck,项目名称:pandoc-xnos,代码行数:34,代码来源:core.py

示例4: metavars

# 需要导入模块: import pandocfilters [as 别名]
# 或者: from pandocfilters import Span [as 别名]
def metavars(key, value, format, meta):
    if key == 'Str':
        m = pattern.match(value)
        if m:
            field = m.group(1)
            result = meta.get(field, {})
            if 'MetaInlines' in result['t']:
                return Span(attributes({'class': 'interpolated',
                                        'field': field}),
                            result['c'])
            elif 'MetaString' in result[t]:
                return Str(result['c']) 
开发者ID:sergiocorreia,项目名称:panflute,代码行数:14,代码来源:metavars.py


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