Browse Source

Merge branch 'fs#141-place-notice-after-comment' into develop

develop
Jonathan Golder 7 years ago
parent
commit
49a8230d76
  1. 41
      bots/markpages.py

41
bots/markpages.py

@ -237,25 +237,28 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
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 \
re.search( r"^\n\s+$", self.current_wikicode.get(
insert_after_index + 1 ).value ):
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 )
# If there is more content
if len(self.current_wikicode.nodes) > (insert_after_index + 1):
# Filter one linebreak
if isinstance( self.current_wikicode.get(
insert_after_index + 1),
mwparser.nodes.text.Text) and \
re.search( r"^\n[^\n\S]+$", self.current_wikicode.get(
insert_after_index + 1 ).value ):
insert_after_index += 1
while len(self.current_wikicode.nodes) > \
(insert_after_index + 1) and \
isinstance(
self.current_wikicode.get(insert_after_index + 1),
mwparser.nodes.comment.Comment ):
insert_after_index += 1
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" )

Loading…
Cancel
Save