, , , . , , - . , , "" ( , ), .
:
:
class TextWrapperDeux(TextWrapper):
_wordsep_re = re.compile(
r'((?<!`)\s+(?!`)|'
r'(?<=\s)(?::[a-z-]+:)`\S+|'
r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|'
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')
@property
def wordsep_re(self):
return self._wordsep_re
def char_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Describe a character given by unicode name.
e.g., :char:`SPACE` -> "char:` `(U+00020 SPACE)"
"""
try:
character = nodes.unicodedata.lookup(text)
except KeyError:
msg = inliner.reporter.error(
':char: argument %s must be valid unicode name at line %d' % (text, lineno))
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
app = inliner.document.settings.env.app
describe_char = "(U+%05X %s)" % (ord(character), text)
char = nodes.inline("char:", "char:", nodes.literal(character, character))
char += nodes.inline(describe_char, describe_char)
return [char], []
def setup(app):
app.add_role('char', char_role)
- , TextWrapper, .. , ; , .
: Starting character is the :char:`SPACE` which has the value 0.
: Starting character is the char:` `(U+00020 SPACE) which has the value 0.
HTML : Starting character is the <span>char:<code class="docutils literal"> </code><span>(U+00020 SPACE)</span></span> which has the value 0.
HTML : - char: (U + 00020 SPACE), 0.