From: David G. <go...@py...> - 2005-09-29 22:14:33
|
> David Goodger wrote: >> So, given the definition above, how would the following usage be >> represented in the doctree? >> >> colored :red:`text` [Mark Nodine] > The problem really is trying to get communication between the > role's definition and the use of the role, which is impeded > by the fact that the role directive has no representation in > the doctree. No, the problem is getting you to show us a concrete example of what you mean! .. role:: red :html: font :color: red .. role:: green :html: font :color: green :latex: \color{green} :red:`text` :green:`Green text.` Forget about the code & syntax details; just show us what should be in the doctree after the parser is finished with the above, but before the transforms are applied. > Just as a substitution_definition has a representation in the > doctree, perhaps we should add a role_definition type of object Substitutions are based on text from the document, so it makes sense to store the definition in the doctree. Roles are callable code; they should not be in the doctree. Most roles are built-in. Roles created by the "role" directive are based on built-in roles; they're just aliases for built-in roles, with a bit of data. Their definitions are stored in instances of docutils.parsers.rst.roles.CustomRole, whose __call__ method calls the base role. IOW, dirctive-created roles are functionally identical to built-in roles: they're just callable code with a specific API. > whose name is in its names attribute and attach a role attribute to > inline for defined roles. I'm not following you here. Examples, please! Are you under the impression that all directive-created roles use the "inline" element? They don't! .. role:: custom(strong) :custom:`text` results in: <paragraph> <strong classes="custom"> text -- David Goodger <http://python.net/~goodger> |