From: David G. <go...@py...> - 2009-06-03 14:46:09
|
On Wed, Jun 3, 2009 at 10:28, Guenter Milde <mi...@us...> wrote: > On 2009-06-02, David Goodger wrote: >> On Tue, Jun 2, 2009 at 06:57, Guenter Milde <mi...@us...> wrote: > >>> The following snipped from the functional test's standard.txt :: > >>> .. _Another Target: > >>> Targets >>> ------- > >>> is converted to the following pseudo-xml:: > >>> <target refid="another-target"> >>> <section dupnames="targets" > ids="targets another-target" > names="another\ target"> >>> <title auto="1" refid="id51"> >>> <generated classes="sectnum"> >>> 2.13 >>> Targets > >>> You see the "another-target" as both, refid of a <target> and id of the >>> following node. > > But is it really needed/sensible to have both? > This is why I asked if this is a doubling already in the doctree. > >> "refid" is a reference to an ID. If you look at the doctree before the >> transforms are applied (use tools/quicktest.py), you'll see that >> initially it's <target id="another-target" ...>, and the ID is >> transferred to the following element, the section. There is only one >> "another-target" ID. The <target refid="..."> node is left behind by >> the transform and should be ignored by the writer. > > But why is it left behind, if it should be ignored? The transform that handles this is the docutils.transforms.references.PropagateTargets. See its docstring & code. I can't recall exactly why <target refid="..."> nodes are left behind (perhaps simply to keep track for debugging purposes), but I don't have time to audit the entire codebase to see if these nodes can be removed without ill-effects. >> There should be no doubling. Take a look at the logic in >> docutils/writers/html4css1/__init__.py::HTMLTranslator.visit_target. > > Wouldn't it be easier to have the logic just once in the tranlator? Every writer needs to process targets anyway (for non-ref attributes), so no. It seems to me that it would be easier to fix the LaTeX writer. Everything else works, and if it works, don't fix it. -- David Goodger <http://python.net/~goodger> |