diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2009-06-17 21:16:27 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2009-06-17 21:16:27 +0000 |
| commit | 453c646d468074e1a394a044ab59ea4f15e38660 (patch) | |
| tree | 805853dc900b8e092f3541f3d09b0af2d4e0f03c /docutils/transforms | |
| parent | 6f985d51be67bc9f0823102271b22ab78ccf62fc (diff) | |
| download | docutils-453c646d468074e1a394a044ab59ea4f15e38660.tar.gz | |
Support "depth" argument of "contents" directive also with "use-latex-toc"
The docutils.transforms.parts.Contents transform is made aware of
use_latex_toc, and does the right thing for LaTeX.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5989 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/transforms')
| -rw-r--r-- | docutils/transforms/parts.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/docutils/transforms/parts.py b/docutils/transforms/parts.py index 56d20c8ab..64de5b5da 100644 --- a/docutils/transforms/parts.py +++ b/docutils/transforms/parts.py @@ -79,6 +79,14 @@ class Contents(Transform): default_priority = 720 def apply(self): + # build a contents list from the section headings? + # if False, the writer (or output software) builds the contents list + # Example: the LaTeX writer with option "use-latex-toc". + try: + build = not(self.document.settings.use_latex_toc) + except AttributeError: + build = True + details = self.startnode.details if 'local' in details: startnode = self.startnode.parent.parent @@ -93,11 +101,16 @@ class Contents(Transform): self.backlinks = details['backlinks'] else: self.backlinks = self.document.settings.toc_backlinks - contents = self.build_contents(startnode) - if len(contents): - self.startnode.replace_self(contents) + if build: + contents = self.build_contents(startnode) + if len(contents): + self.startnode.replace_self(contents) + else: + self.startnode.parent.parent.remove(self.startnode.parent) else: - self.startnode.parent.parent.remove(self.startnode.parent) + # pass customization settings to the parent node + self.startnode.parent.attributes.update(details) + self.startnode.parent.remove(self.startnode) def build_contents(self, node, level=0): level += 1 |
