INNER CODE UNIT · Python
reorder_tab_content
CodeSmile-0000011110110111/LunyScript-RFC · scripts/reorder-tab-content.py:11
def reorder_tab_content(content):
"""Reorder content within each tab-content div"""
# Pattern to match tab-content divs with their content
pattern = r'(<div class="tab-content[^"]*" markdown="1">)\s*(.*?)\s*(</div>)'
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)