@@ -512,6 +512,21 @@ def process_template(text):
512512
513513 return str (code )
514514
515+
516+ # --- Section Heading Handler ---
517+ def process_section_heading (text ):
518+ """
519+ Processes section headings like ==Title== and wraps the heading text in <translate> tags.
520+ """
521+ # Match ==Title==, ===Subsection===, etc.
522+ match = re .match (r'^(=+)([^=]+)(=+)$' , text .strip ())
523+ if not match :
524+ return text
525+ level = match .group (1 )
526+ heading_text = match .group (2 ).strip ()
527+ # Reconstruct with same number of = on both sides
528+ return f'{ level } <translate>{ heading_text } </translate>{ level } '
529+
515530def process_raw_url (text ):
516531 """
517532 Processes raw URLs in the wikitext.
@@ -546,6 +561,19 @@ def convert_to_translatable_wikitext(wikitext):
546561
547562 while curr < text_length :
548563 found = None
564+ if wikitext [curr ] == '=' :
565+ # Find the end of the line
566+ end_line = wikitext .find ('\n ' , curr )
567+ if end_line == - 1 :
568+ end_line = text_length
569+ line = wikitext [curr :end_line ]
570+ if re .match (r'^(=+)[^=]+(=+)$' , line .strip ()):
571+ if last < curr :
572+ parts .append ((wikitext [last :curr ], _wrap_in_translate ))
573+ parts .append ((line , process_section_heading ))
574+ curr = end_line
575+ last = curr
576+ continue
549577 # Syntax highlight block
550578 pattern = '<syntaxhighlight'
551579 if wikitext .startswith (pattern , curr ):
0 commit comments