diff options
author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-03-26 16:21:28 +0000 |
---|---|---|
committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-03-26 16:21:28 +0000 |
commit | 9dbc2adead008935245a396eab10bb7bcb11b226 (patch) | |
tree | bd50e907b4e88e09d6c63e02d7172720d5576b52 /docutils/parsers/rst | |
parent | 4df9fad485c1e12e850f9d7ff225d51c538af3dc (diff) | |
download | docutils-9dbc2adead008935245a396eab10bb7bcb11b226.tar.gz |
merged rev. 3094:3101 and 3102:HEAD from branches/multiple-ids to trunk
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3129 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/parsers/rst')
-rw-r--r-- | docutils/parsers/rst/directives/images.py | 4 | ||||
-rw-r--r-- | docutils/parsers/rst/directives/misc.py | 3 | ||||
-rw-r--r-- | docutils/parsers/rst/directives/parts.py | 4 | ||||
-rw-r--r-- | docutils/parsers/rst/roles.py | 18 | ||||
-rw-r--r-- | docutils/parsers/rst/states.py | 19 |
5 files changed, 31 insertions, 17 deletions
diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index d6ac5a0c9..76d0d75eb 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -39,8 +39,8 @@ def image(name, arguments, options, content, lineno, if target_type == 'refuri': reference_node = nodes.reference(refuri=data) elif target_type == 'refname': - reference_node = nodes.reference( - refname=data, name=whitespace_normalize_name(options['target'])) + reference_node = nodes.reference(refname=data, + name=whitespace_normalize_name(options['target'])) state.document.note_refname(reference_node) else: # malformed target messages.append(data) # data is a system message diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 1a6cbc17c..7bae832d2 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -188,8 +188,7 @@ def replace(name, arguments, options, content, lineno, messages = [] for node in element: if isinstance(node, nodes.system_message): - if node.has_key('backrefs'): - del node['backrefs'] + node['backrefs'] = [] messages.append(node) error = state_machine.reporter.error( 'Error in "%s" directive: may contain a single paragraph ' diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index c182ad0fd..217def5b6 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -41,7 +41,7 @@ def contents(name, arguments, options, content, lineno, else: title = nodes.title('', language.labels['contents']) - topic = nodes.topic(CLASS='contents') + topic = nodes.topic(classes=['contents']) cls = options.get('class') if cls: @@ -55,7 +55,7 @@ def contents(name, arguments, options, content, lineno, name = nodes.fully_normalize_name(name) if not document.has_name(name): - topic['name'] = name + topic['names'].append(name) document.note_implicit_target(topic) pending = nodes.pending(parts.Contents, rawsource=block_text) diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index 2f3ab11a5..cf6d5a971 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -174,7 +174,7 @@ def set_implicit_options(role_fn): if not hasattr(role_fn, 'options') or role_fn.options is None: role_fn.options = {'class': directives.class_option} elif not role_fn.options.has_key('class'): - role_fn.options['class'] = directives.class_option + role_fn.options['class'] = directives.class_option def register_generic_role(canonical_name, node_class): """For roles which simply wrap a given `node_class` around the text.""" @@ -195,6 +195,7 @@ class GenericRole: def __call__(self, role, rawtext, text, lineno, inliner, options={}, content=[]): + set_classes(options) return [self.node_class(rawtext, utils.unescape(text), **options)], [] @@ -233,6 +234,7 @@ def generic_custom_role(role, rawtext, text, lineno, inliner, """""" # Once nested inline markup is implemented, this and other methods should # recursively call inliner.nested_parse(). + set_classes(options) return [nodes.inline(rawtext, utils.unescape(text), **options)], [] generic_custom_role.options = {'class': directives.class_option} @@ -265,6 +267,7 @@ def pep_reference_role(role, rawtext, text, lineno, inliner, return [prb], [msg] # Base URL mainly used by inliner.pep_reference; so this is correct: ref = inliner.document.settings.pep_base_url + inliner.pep_url % pepnum + set_classes(options) return [nodes.reference(rawtext, 'PEP ' + utils.unescape(text), refuri=ref, **options)], [] @@ -284,6 +287,7 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner, return [prb], [msg] # Base URL mainly used by inliner.rfc_reference, so this is correct: ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum + set_classes(options) node = nodes.reference(rawtext, 'RFC ' + utils.unescape(text), refuri=ref, **options) return [node], [] @@ -299,6 +303,7 @@ def raw_role(role, rawtext, text, lineno, inliner, options={}, content=[]): 'an associated format.' % role, line=lineno) prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] + set_classes(options) node = nodes.raw(rawtext, utils.unescape(text, 1), **options) return [node], [] @@ -329,3 +334,14 @@ register_canonical_role('target', unimplemented_role) # This should remain unimplemented, for testing purposes: register_canonical_role('restructuredtext-unimplemented-role', unimplemented_role) + + +def set_classes(options): + """ + Auxiliary function to set options['classes'] and delete + options['class']. + """ + if options.has_key('class'): + assert not options.has_key('classes') + options['classes'] = options['class'].split() + del options['class'] diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index ddf47df7f..a44f47027 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -365,7 +365,7 @@ class RSTState(StateWS): textnodes, title_messages = self.inline_text(title, lineno) titlenode = nodes.title(title, '', *textnodes) name = normalize_name(titlenode.astext()) - section_node['name'] = name + section_node['names'].append(name) section_node += titlenode section_node += messages section_node += title_messages @@ -787,7 +787,7 @@ class Inliner: else: if target: reference['refuri'] = uri - target['name'] = refname + target['names'].append(refname) self.document.note_external_target(target) self.document.note_explicit_target(target, self.parent) node_list.append(target) @@ -829,7 +829,7 @@ class Inliner: assert len(inlines) == 1 target = inlines[0] name = normalize_name(target.astext()) - target['name'] = name + target['names'].append(name) self.document.note_explicit_target(target, self.parent) return before, inlines, remaining, sysmessages @@ -1751,7 +1751,7 @@ class Body(RSTState): name = name[1:] # autonumber label footnote['auto'] = 1 if name: - footnote['name'] = name + footnote['names'].append(name) self.document.note_autofootnote(footnote) elif name == '*': # auto-symbol name = '' @@ -1759,7 +1759,7 @@ class Body(RSTState): self.document.note_symbol_footnote(footnote) else: # manually numbered footnote += nodes.label('', label) - footnote['name'] = name + footnote['names'].append(name) self.document.note_footnote(footnote) if name: self.document.note_explicit_target(footnote, footnote) @@ -1778,7 +1778,7 @@ class Body(RSTState): citation = nodes.citation('\n'.join(indented)) citation.line = lineno citation += nodes.label('', label) - citation['name'] = name + citation['names'].append(name) self.document.note_citation(citation) self.document.note_explicit_target(citation, citation) if indented: @@ -1814,7 +1814,6 @@ class Body(RSTState): target_type, data = self.parse_target(block, block_text, lineno) if target_type == 'refname': target = nodes.target(block_text, '', refname=normalize_name(data)) - target.indirect_reference_name = data self.add_target(target_name, '', target, lineno) self.document.note_indirect_target(target) return target @@ -1854,7 +1853,7 @@ class Body(RSTState): target.line = lineno if targetname: name = normalize_name(unescape(targetname)) - target['name'] = name + target['names'].append(name) if refuri: uri = self.inliner.adjust_uri(refuri) if uri: @@ -2259,7 +2258,7 @@ class RFC2822Body(Body): def rfc2822(self, match, context, next_state): """RFC2822-style field list item.""" - fieldlist = nodes.field_list(CLASS='rfc2822') + fieldlist = nodes.field_list(classes=['rfc2822']) self.parent += fieldlist field, blank_finish = self.rfc2822_field(match) fieldlist += field @@ -2497,7 +2496,7 @@ class SubstitutionDef(Body): def embedded_directive(self, match, context, next_state): nodelist, blank_finish = self.directive(match, - alt=self.parent['name']) + alt=self.parent['names'][0]) self.parent += nodelist if not self.state_machine.at_eof(): self.blank_finish = blank_finish |