Skip to content

Commit

Permalink
Fix default heading_offset setting not being applied (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Mar 25, 2024
1 parent d5fb0bf commit 801a18d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Expand Up @@ -33,7 +33,7 @@ repos:
- id: end-of-file-fixer
name: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.1
rev: v0.3.4
hooks:
- id: ruff
args:
Expand Down Expand Up @@ -79,7 +79,7 @@ repos:
name: editorconfig-checker
alias: ec
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.9.0
hooks:
- id: mypy
files: ^src
Expand All @@ -88,7 +88,7 @@ repos:
- platformdirs
- wcmatch
- repo: https://github.com/tcort/markdown-link-check
rev: v3.11.2
rev: v3.12.1
hooks:
- id: markdown-link-check
name: markdown-link-check
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "mkdocs-include-markdown-plugin"
version = "6.0.4"
version = "6.0.5"
description = "Mkdocs Markdown includer plugin."
readme = "README.md"
license = "Apache-2.0"
Expand Down
12 changes: 6 additions & 6 deletions src/mkdocs_include_markdown_plugin/event.py
Expand Up @@ -444,8 +444,8 @@ def found_include_markdown_tag( # noqa: PLR0912, PLR0915
arguments_string,
)
if offset_match:
offset = offset_match[1]
if offset == '':
offset_raw_value = offset_match[1]
if offset_raw_value == '':
lineno = lineno_from_content_start(
markdown,
directive_match_start,
Expand All @@ -456,15 +456,15 @@ def found_include_markdown_tag( # noqa: PLR0912, PLR0915
f' {os.path.relpath(page_src_path, docs_dir)}:{lineno}',
)
try:
offset = int(offset)
offset = int(offset_raw_value)
except ValueError:
lineno = lineno_from_content_start(
markdown,
directive_match_start,
)
raise PluginError(
f"Invalid 'heading-offset' argument \"{offset}\" in"
" 'include-markdown' directive at "
f"Invalid 'heading-offset' argument \"{offset_raw_value}\""
" in 'include-markdown' directive at "
f'{os.path.relpath(page_src_path, docs_dir)}:{lineno}',
) from None
else:
Expand Down Expand Up @@ -556,7 +556,7 @@ def found_include_markdown_tag( # noqa: PLR0912, PLR0915
)
)

if offset_match:
if offset:
new_text_to_include = process.increase_headings_offset(
new_text_to_include,
offset=offset + cumulative_heading_offset,
Expand Down

0 comments on commit 801a18d

Please sign in to comment.