Use callback to detect redfam.section

Detecting redfam-Sections via RegExp caused some false positives due to
wrong formated things in wikisyntax. See Task

Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=78 FS#78]
This commit is contained in:
2016-08-24 20:02:48 +02:00
parent 1e4c8646bf
commit ac54aea698
2 changed files with 19 additions and 2 deletions

View File

@@ -341,6 +341,22 @@ class RedFamParser( RedFam ):
else:
return False
@classmethod
def is_section_redfam_cb( cls, heading ):
"""
Used as callback for wikicode.get_sections in redpage.parse to
select sections which are redfams
"""
# Because of strange behavior in some cases, parse heading again
# (Task FS#77)
heading = mwparser.parse( str( heading ) )
# Make sure we have min. two wikilinks in heading to assume a redfam
if len( heading.filter_wikilinks() ) >= 2:
return True
else:
return False
@classmethod
def parser( cls, text, page, isarchive=False ):
"""