Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃敡 Update config with new pymdown extensions #712

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

tiangolo
Copy link
Owner

@tiangolo tiangolo commented Nov 28, 2023

馃敡 Update config with new pymdown extensions

I updated the admonition syntax automatically with this script:

import os
import re
import subprocess
from pathlib import Path

base_dir = Path(__file__).parent.parent

def update_admonition():
    os.chdir(base_dir)
    md_files = list(Path("docs").glob("**/*.md"))
    # md_files = [Path("docs/db-to-code.md")]
    re_str = r"!!! (?P<type>[^\n\"]*)\s?(\"(?P<title>[^\n\"]*)\")?\n(?P<content>(\n|    .*)*)\n*"
    # md_file = md_files[25]
    for md_file in md_files:
        content = md_file.read_text()

        def replace(match: re.Match):
            type_ = match.group("type")
            title = match.group("title")
            block = match.group("content")
            deindented_block = block.replace("    ", "")
            result = f"/// {type_}"
            if title:
                result += f" | {title}"
            result += f"\n\n{deindented_block.strip()}\n\n"
            result += "///\n\n"
            return result

        new_content = re.sub(re_str, replace, content)
        md_file.write_text(new_content)


if __name__ == "__main__":
    update_admonition()

Copy link

馃摑 Docs preview for commit 6a10132 at: https://0be9f547.sqlmodel.pages.dev

@tiangolo tiangolo merged commit a95bd38 into main Nov 28, 2023
13 checks passed
@tiangolo tiangolo deleted the upgrade-pymdownx-syntax branch November 28, 2023 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant