From 31469d79ad65bada6af245fcb0ded1d0bff1ae6c Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 23 Apr 2004 13:48:24 +0000 Subject: Updated for ToC changes (topic now inserted by directive, so follow suit here). Fixes SF bug 928482. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk/docutils@1986 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/transforms/peps.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'docutils/transforms') diff --git a/docutils/transforms/peps.py b/docutils/transforms/peps.py index 9ae7fa80b..fdd750d0c 100644 --- a/docutils/transforms/peps.py +++ b/docutils/transforms/peps.py @@ -19,7 +19,7 @@ import sys import os import re import time -from docutils import nodes, utils +from docutils import nodes, utils, languages from docutils import ApplicationError, DataError from docutils.transforms import Transform, TransformError from docutils.transforms import parts, references, misc @@ -137,15 +137,24 @@ class Headers(Transform): class Contents(Transform): """ - Insert a table of contents transform placeholder into the document after - the RFC 2822 header. + Insert an empty table of contents topic and a transform placeholder into + the document after the RFC 2822 header. """ default_priority = 380 def apply(self): - pending = nodes.pending(parts.Contents, {'title': None}) - self.document.insert(1, pending) + language = languages.get_language(self.document.settings.language_code) + name = language.labels['contents'] + title = nodes.title('', name) + topic = nodes.topic('', title, CLASS='contents') + name = nodes.fully_normalize_name(name) + if not self.document.has_name(name): + topic['name'] = name + self.document.note_implicit_target(topic) + pending = nodes.pending(parts.Contents) + topic += pending + self.document.insert(1, topic) self.document.note_pending(pending) -- cgit v1.2.1