本文整理汇总了Python中docutils.utils.split_escaped_whitespace方法的典型用法代码示例。如果您正苦于以下问题:Python utils.split_escaped_whitespace方法的具体用法?Python utils.split_escaped_whitespace怎么用?Python utils.split_escaped_whitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.utils
的用法示例。
在下文中一共展示了utils.split_escaped_whitespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_target
# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import split_escaped_whitespace [as 别名]
def parse_target(self, block, block_text, lineno):
"""
Determine the type of reference of a target.
:Return: A 2-tuple, one of:
- 'refname' and the indirect reference name
- 'refuri' and the URI
- 'malformed' and a system_message node
"""
if block and block[-1].strip()[-1:] == '_': # possible indirect target
reference = ' '.join([line.strip() for line in block])
refname = self.is_reference(reference)
if refname:
return 'refname', refname
ref_parts = split_escaped_whitespace(' '.join(block))
reference = ' '.join(''.join(unescape(part).split())
for part in ref_parts)
return 'refuri', reference
示例2: uri
# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import split_escaped_whitespace [as 别名]
def uri(argument):
"""
Return the URI argument with unescaped whitespace removed.
(Directive option conversion function.)
Raise ``ValueError`` if no argument is found.
"""
if argument is None:
raise ValueError('argument required but none supplied')
else:
parts = split_escaped_whitespace(escape2null(argument))
uri = ' '.join(''.join(unescape(part).split()) for part in parts)
return uri
示例3: phrase_ref
# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import split_escaped_whitespace [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, []