INNER CODE UNIT · Python

fix_formatting

CodeSmile-0000011110110111/LunyScript-RFC · scripts/reorder-tabs.py:33

        def fix_formatting(tab_content):
            # Pattern: **Concepts needed:** ... **Lines of code:** ...
            # Replace with: **Lines of code:** ...\n**Concepts needed:** ...
            pattern = r'\*\*Concepts needed:\*\* (.*?)\s*\*\*Lines of code:\*\* (\d+\+?)'
            replacement = r'**Lines of code:** \2\n\n**Concepts needed:** \1'
            return re.sub(pattern, replacement, tab_content, flags=re.DOTALL)

        # Build new HTML
        html = f'<div class="code-tabs" data-group="{group_name}">\n'
        html += '<div class="tab-buttons">\n'
        html += '<button class="tab-button active">LunyScript</button>\n'
        html += '<button class="tab-button">GDScript</button>\n'
        html += '<button class="tab-button">Godot C#</button>\n'
        html += '<button class="tab-button">Unity C#</button>\n'
        html += '</div>\n'

        for i, tab in enumerate(reordered):
            active_class = tab.group(1)  # Will be ' active' for first tab or ''

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…