Keep comments and leading templates together

Prevent spliting up existing comments and templates as often those are
documenting archiv templates behaviour

Related Task: [FS#141](https://fs.golderweb.de/index.php?do=details&task_id=141)
This commit is contained in:
2017-08-21 13:49:34 +02:00
parent ed78501821
commit 8422d08cb6

View File

@@ -218,7 +218,28 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
# If there is one, add notice after this # If there is one, add notice after this
if ltemplates: if ltemplates:
self.current_wikicode.insert_after( ltemplates[-1],
# Make sure not separate template and maybe following comment
insert_after_index = self.current_wikicode.index(
ltemplates[-1] )
# Filter one linebreak
if isinstance( self.current_wikicode.get(
insert_after_index + 1), mwparser.nodes.text.Text ) and \
self.current_wikicode.get(
insert_after_index + 1 ).value is "\n":
insert_after_index += 1
while isinstance(
self.current_wikicode.get(insert_after_index + 1),
mwparser.nodes.comment.Comment ):
insert_after_index += 1
else:
self.current_wikicode.insert_after(
self.current_wikicode.get(insert_after_index),
self.disc_notice ) self.disc_notice )
# To have it in its own line we need to add a linbreak before # To have it in its own line we need to add a linbreak before