INNER CODE UNIT · Python
reorder_tabs_and_fix_formatting
CodeSmile-0000011110110111/LunyScript-RFC · scripts/reorder-tabs.py:8
def reorder_tabs_and_fix_formatting(content):
"""
1. Reorder tabs: LunyScript, GDScript, Godot C#, Unity C#
2. Fix formatting: Lines of code first (with line break), then Concepts needed
"""
# Pattern to match entire tab groups
pattern = r'<div class="code-tabs" data-group="(\w+)">\s*<div class="tab-buttons">\s*<button class="tab-button active">LunyScript</button>\s*<button class="tab-button">Unity C#</button>\s*<button class="tab-button">Godot C#</button>\s*<button class="tab-button">GDScript</button>\s*</div>(.*?)</div>\s*\n'
def replace_tab_group(match):
group_name = match.group(1)
all_content = match.group(2)
# Extract all four tab contents
tab_pattern = r'<div class="tab-content(.*?)" markdown="1">\s*(.*?)\s*</div>'
tabs = list(re.finditer(tab_pattern, all_content, re.DOTALL))
if len(tabs) != 4: