INNER CODE UNIT · Python

convert_tabs_to_html

CodeSmile-0000011110110111/LunyScript-RFC · scripts/convert-tabs.py:9

def convert_tabs_to_html(content):
    """Convert {% tabs %} syntax to HTML tabs."""

    # Pattern to match entire tab groups
    pattern = r'{%\s*tabs\s+(\w+)\s*%}(.*?){%\s*endtabs\s*%}'

    def replace_tab_group(match):
        group_name = match.group(1)
        tab_content = match.group(2)

        # Extract individual tabs
        tab_pattern = r'{%\s*tab\s+\w+\s+(.*?)\s*%}(.*?){%\s*endtab\s*%}'
        tabs = list(re.finditer(tab_pattern, tab_content, re.DOTALL))

        if not tabs:
            return match.group(0)  # Return original if no tabs found

        # Build HTML with NO INDENTATION (Kramdown treats indented HTML as code)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…