diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 876a98b..c634676 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,17 +1,13 @@ --- name: CI - on: push: branches: [main] - tags: - - v* + tags: [v*] pull_request: - jobs: pre-commit: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Set up Python @@ -19,29 +15,24 @@ jobs: with: python-version: '3.10' - uses: pre-commit/action@v2.0.0 - tests: runs-on: ${{ matrix.os }} strategy: matrix: python-version: [3.7, '3.10'] os: [ubuntu-latest, windows-latest] - steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Installation (deps and package) # we install with flit --pth-file, # so that coverage will be recorded for the module run: | pip install flit flit install --deps=production --extras=test --pth-file - - name: Run pytest run: | pytest --cov=mdformat_admon --cov-report=xml --cov-report=term-missing @@ -54,26 +45,21 @@ jobs: # flags: pytests # file: ./coverage.xml # fail_ci_if_error: false - pre-commit-hook: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.10' - - name: Installation (deps and package) run: | pip install pre-commit pip install . - - name: run pre-commit with plugin run: | pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure - publish: name: Publish to PyPi needs: [pre-commit, tests, pre-commit-hook] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 940ffa1..c979e30 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,15 +27,15 @@ repos: - id: trailing-whitespace exclude: tests/fixtures.*\.md - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: python-check-blanket-noqa - repo: https://github.com/timothycrosley/isort - rev: 5.11.4 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 @@ -51,12 +51,11 @@ repos: rev: 0.7.16 hooks: - id: mdformat - additional_dependencies: - - mdformat-mkdocs[recommended] + additional_dependencies: ['mdformat-mkdocs[recommended]'] exclude: tests/.+\.md args: [--wrap=no] - repo: https://github.com/lyz-code/yamlfix/ - rev: 1.1.1 + rev: 1.9.0 hooks: - id: yamlfix types_or: [] diff --git a/mdformat_mkdocs/plugin.py b/mdformat_mkdocs/plugin.py index 88e5ca6..92dc0a5 100644 --- a/mdformat_mkdocs/plugin.py +++ b/mdformat_mkdocs/plugin.py @@ -14,7 +14,7 @@ def update_mdit(mdit: MarkdownIt) -> None: ... -_RE_INDENT = re.compile(r"(?P\s*)(?P.*)") +_RE_INDENT = re.compile(r"(?P\s*)(?P[^\s]?.*)") """Match `indent` and `content` against line`.""" _RE_LIST_ITEM = re.compile(r"(?P[\-\*\d\.]+)\s+(?P.+)") @@ -23,7 +23,7 @@ def update_mdit(mdit: MarkdownIt) -> None: def _normalize_list(text: str, node: RenderTreeNode, context: RenderContext) -> str: """Post-processor to normalize lists.""" - eol = "\n" # PLANNED: Does this need to support carriage returns? + eol = "\n" indent = " " * _MKDOCS_INDENT_COUNT rendered = "" @@ -53,7 +53,7 @@ def _normalize_list(text: str, node: RenderTreeNode, context: RenderContext) -> raise NotImplementedError(f"Error in indentation of: `{line}`") else: indent_counter = 0 - last_indent = match["indent"] + last_indent = this_indent new_indent = indent * indent_counter rendered += f"{new_indent}{new_line.strip()}{eol}" return rendered.rstrip()