Merge branch 'fs#141-place-notice-after-comment' into develop
This commit is contained in:
@@ -218,8 +218,29 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
||||
|
||||
# If there is one, add notice after this
|
||||
if ltemplates:
|
||||
self.current_wikicode.insert_after( ltemplates[-1],
|
||||
self.disc_notice )
|
||||
|
||||
# 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 )
|
||||
|
||||
# To have it in its own line we need to add a linbreak before
|
||||
self.current_wikicode.insert_before(self.disc_notice, "\n" )
|
||||
@@ -233,8 +254,8 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
||||
else:
|
||||
self.current_wikicode.insert( 0, self.disc_notice )
|
||||
|
||||
# To have it in its own line we need to add a linbreak after it
|
||||
self.current_wikicode.insert_after(self.disc_notice, "\n" )
|
||||
# To have it in its own line we need to add a linbreak after it
|
||||
self.current_wikicode.insert_after(self.disc_notice, "\n" )
|
||||
|
||||
# Notice was added
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user