INNER CODE UNIT · Python

fix_tab

CodeSmile-0000011110110111/LunyScript-RFC · scripts/reorder-tab-content.py:17

    def fix_tab(match):
        opening = match.group(1)
        body = match.group(2)
        closing = match.group(3)

        # Extract components
        # Lines of code pattern
        loc_match = re.search(r'\*\*Lines of code:\*\* (.+?)(?=\n|$)', body)
        # Concepts needed pattern
        concepts_match = re.search(r'\*\*Concepts needed:\*\* (.+?)(?=\n|$)', body, re.DOTALL)
        # Code block (everything from ``` to ```)
        code_match = re.search(r'(```[\s\S]+?```)', body)

        if not (loc_match and concepts_match and code_match):
            return match.group(0)  # Return original if can't parse

        # Rebuild in correct order
        new_body = f"\n**Lines of code:** {loc_match.group(1)}\n\n"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…