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


Python nodes.whitespace_normalize_name方法代码示例

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


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

示例1: reference

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import whitespace_normalize_name [as 别名]
def reference(self, match, lineno, anonymous=False):
        referencename = match.group('refname')
        refname = normalize_name(referencename)
        referencenode = nodes.reference(
            referencename + match.group('refend'), referencename,
            name=whitespace_normalize_name(referencename))
        referencenode[0].rawsource = referencename
        if anonymous:
            referencenode['anonymous'] = 1
        else:
            referencenode['refname'] = refname
            self.document.note_refname(referencenode)
        string = match.string
        matchstart = match.start('whole')
        matchend = match.end('whole')
        return (string[:matchstart], [referencenode], string[matchend:], []) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:18,代码来源:states.py

示例2: reference

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import whitespace_normalize_name [as 别名]
def reference(self, match, lineno, anonymous=False):
        referencename = match.group('refname')
        refname = normalize_name(referencename)
        referencenode = nodes.reference(
            referencename + match.group('refend'), referencename,
            name=whitespace_normalize_name(referencename))
        if anonymous:
            referencenode['anonymous'] = 1
        else:
            referencenode['refname'] = refname
            self.document.note_refname(referencenode)
        string = match.string
        matchstart = match.start('whole')
        matchend = match.end('whole')
        return (string[:matchstart], [referencenode], string[matchend:], []) 
开发者ID:skarlekar,项目名称:faces,代码行数:17,代码来源:states.py

示例3: is_reference

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import whitespace_normalize_name [as 别名]
def is_reference(self, reference):
        match = self.explicit.patterns.reference.match(
            whitespace_normalize_name(reference))
        if not match:
            return None
        return unescape(match.group('simple') or match.group('phrase')) 
开发者ID:skarlekar,项目名称:faces,代码行数:8,代码来源:states.py

示例4: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import whitespace_normalize_name [as 别名]
def run(self):
        if 'align' in self.options:
            if isinstance(self.state, states.SubstitutionDef):
                # Check for align_v_values.
                if self.options['align'] not in self.align_v_values:
                    raise self.error(
                        'Error in "%s" directive: "%s" is not a valid value '
                        'for the "align" option within a substitution '
                        'definition.  Valid values for "align" are: "%s".'
                        % (self.name, self.options['align'],
                           '", "'.join(self.align_v_values)))
            elif self.options['align'] not in self.align_h_values:
                raise self.error(
                    'Error in "%s" directive: "%s" is not a valid value for '
                    'the "align" option.  Valid values for "align" are: "%s".'
                    % (self.name, self.options['align'],
                       '", "'.join(self.align_h_values)))
        messages = []
        reference = directives.uri(self.arguments[0])
        self.options['uri'] = reference
        reference_node = None
        if 'target' in self.options:
            block = states.escape2null(
                self.options['target']).splitlines()
            block = [line for line in block]
            target_type, data = self.state.parse_target(
                block, self.block_text, self.lineno)
            if target_type == 'refuri':
                reference_node = nodes.reference(refuri=data)
            elif target_type == 'refname':
                reference_node = nodes.reference(
                    refname=fully_normalize_name(data),
                    name=whitespace_normalize_name(data))
                reference_node.indirect_reference_name = data
                self.state.document.note_refname(reference_node)
            else:                           # malformed target
                messages.append(data)       # data is a system message
            del self.options['target']
        set_classes(self.options)
        image_node = nodes.image(self.block_text, **self.options)
        self.add_name(image_node)
        if reference_node:
            reference_node += image_node
            return messages + [reference_node]
        else:
            return messages + [image_node] 
开发者ID:skarlekar,项目名称:faces,代码行数:48,代码来源:images.py

示例5: phrase_ref

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import whitespace_normalize_name [as 别名]
def phrase_ref(self, before, after, rawsource, escaped, text):
        match = self.patterns.embedded_link.search(escaped)
        if match: # embedded <URI> or <alias_>
            text = unescape(escaped[:match.start(0)])
            aliastext = match.group(2)
            underscore_escaped = aliastext.endswith('\x00_')
            aliastext = unescape(aliastext)
            if aliastext.endswith('_') and not (underscore_escaped
                                        or self.patterns.uri.match(aliastext)):
                aliastype = 'name'
                alias = normalize_name(aliastext[:-1])
                target = nodes.target(match.group(1), refname=alias)
                target.indirect_reference_name = aliastext[:-1]
            else:
                aliastype = 'uri'
                alias = ''.join(aliastext.split())
                alias = self.adjust_uri(alias)
                if alias.endswith(r'\_'):
                    alias = alias[:-2] + '_'
                target = nodes.target(match.group(1), refuri=alias)
                target.referenced = 1
            if not aliastext:
                raise ApplicationError('problem with embedded link: %r'
                                       % aliastext)
            if not text:
                text = alias
        else:
            target = None

        refname = normalize_name(text)
        reference = nodes.reference(rawsource, text,
                                    name=whitespace_normalize_name(text))
        node_list = [reference]

        if rawsource[-2:] == '__':
            if  target and (aliastype == 'name'):
                reference['refname'] = alias
                self.document.note_refname(reference)
                # self.document.note_indirect_target(target) # required?
            elif target and (aliastype == 'uri'):
                reference['refuri'] = alias
            else:
                reference['anonymous'] = 1
        else:
            if target:
                target['names'].append(refname)
                if aliastype == 'name':
                    reference['refname'] = alias
                    self.document.note_indirect_target(target)
                    self.document.note_refname(reference)
                else:
                    reference['refuri'] = alias
                    self.document.note_explicit_target(target, self.parent)
                # target.note_referenced_by(name=refname)
                node_list.append(target)
            else:
                reference['refname'] = refname
                self.document.note_refname(reference)
        return before, node_list, after, [] 
开发者ID:skarlekar,项目名称:faces,代码行数:61,代码来源:states.py

示例6: phrase_ref

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import whitespace_normalize_name [as 别名]
def phrase_ref(self, before, after, rawsource, escaped, text):
        match = self.patterns.embedded_link.search(escaped)
        if match: # embedded <URI> or <alias_>
            text = unescape(escaped[:match.start(0)])
            aliastext = match.group(2)
            underscore_escaped = aliastext.endswith('\x00_')
            aliastext = unescape(aliastext)
            if aliastext.endswith('_') and not (underscore_escaped
                                        or self.patterns.uri.match(aliastext)):
                aliastype = 'name'
                alias = normalize_name(aliastext[:-1])
                target = nodes.target(match.group(1), refname=alias)
                target.indirect_reference_name = aliastext[:-1]
            else:
                aliastype = 'uri'
                alias_parts = split_escaped_whitespace(match.group(2))
                alias = ' '.join(''.join(unescape(part).split())
                                 for part in alias_parts)
                alias = self.adjust_uri(alias)
                if alias.endswith(r'\_'):
                    alias = alias[:-2] + '_'
                target = nodes.target(match.group(1), refuri=alias)
                target.referenced = 1
            if not aliastext:
                raise ApplicationError('problem with embedded link: %r'
                                       % aliastext)
            if not text:
                text = alias
        else:
            target = None

        refname = normalize_name(text)
        reference = nodes.reference(rawsource, text,
                                    name=whitespace_normalize_name(text))
        node_list = [reference]

        if rawsource[-2:] == '__':
            if  target and (aliastype == 'name'):
                reference['refname'] = alias
                self.document.note_refname(reference)
                # self.document.note_indirect_target(target) # required?
            elif target and (aliastype == 'uri'):
                reference['refuri'] = alias
            else:
                reference['anonymous'] = 1
        else:
            if target:
                target['names'].append(refname)
                if aliastype == 'name':
                    reference['refname'] = alias
                    self.document.note_indirect_target(target)
                    self.document.note_refname(reference)
                else:
                    reference['refuri'] = alias
                    self.document.note_explicit_target(target, self.parent)
                # target.note_referenced_by(name=refname)
                node_list.append(target)
            else:
                reference['refname'] = refname
                self.document.note_refname(reference)
        return before, node_list, after, [] 
开发者ID:QData,项目名称:deepWordBug,代码行数:63,代码来源:states.py


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