Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

馃敡 Update config with new pymdown extensions - #712

#712
Merged
tiangolo merged 3 commits into
mainfastapi/sqlmodel:mainfrom
upgrade-pymdownx-syntaxfastapi/sqlmodel:upgrade-pymdownx-syntaxCopy head branch name to clipboard
Nov 28, 2023
Merged

馃敡 Update config with new pymdown extensions#712
tiangolo merged 3 commits into
mainfastapi/sqlmodel:mainfrom
upgrade-pymdownx-syntaxfastapi/sqlmodel:upgrade-pymdownx-syntaxCopy head branch name to clipboard

Conversation

@tiangolo

@tiangolo tiangolo commented Nov 28, 2023

Copy link
Copy Markdown
Member

馃敡 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()

@github-actions

Copy link
Copy Markdown
Contributor

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

@tiangolo
tiangolo merged commit a95bd38 into main Nov 28, 2023
@tiangolo
tiangolo deleted the upgrade-pymdownx-syntax branch November 28, 2023 20:50
@tiangolo tiangolo added the internal Internal changes label Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Internal changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.