From 99d1e7324fb2df19fdd011734191359e49c0fa43 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 7 Jul 2016 22:33:46 +0100 Subject: Use overall comment count for comment numbering This matches the behaviour in Word more closely. --- mammoth/conversion.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mammoth/conversion.py b/mammoth/conversion.py index d58fe6a..85d8ec5 100644 --- a/mammoth/conversion.py +++ b/mammoth/conversion.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals -import collections from functools import partial import base64 @@ -68,7 +67,6 @@ class _DocumentConverter(documents.ElementVisitor): self._ignore_empty_paragraphs = ignore_empty_paragraphs self._note_references = note_references self._referenced_comments = [] - self._comment_count_by_initials = collections.defaultdict(lambda: 0) self._convert_image = convert_image self._comments = comments @@ -212,8 +210,7 @@ class _DocumentConverter(documents.ElementVisitor): def visit_comment_reference(self, reference): def nodes(): comment = self._comments[reference.comment_id] - self._comment_count_by_initials[comment.author_initials] += 1 - count = self._comment_count_by_initials[comment.author_initials] + count = len(self._referenced_comments) + 1 label = "[{0}{1}]".format(_comment_author_label(comment), count) self._referenced_comments.append((label, comment)) return [ -- cgit v1.2.3