Skip to content

Commit

Permalink
Speed up inclusion regex (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Jun 21, 2024
1 parent 3a2d7e1 commit 0fd1119
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
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.4.6
rev: v0.4.10
hooks:
- id: ruff
args:
Expand Down
12 changes: 12 additions & 0 deletions examples/long-line/docs/index.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions examples/long-line/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
site_name: Foo
plugins:
- include-markdown
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mkdocs-include-markdown-plugin"
version = "6.2.0"
version = "6.2.1"
description = "Mkdocs Markdown includer plugin."
readme = "README.md"
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions src/mkdocs_include_markdown_plugin/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DirectiveBoolArgument: # noqa: D101
# and "$CLOSING_TAG" will be replaced by the effective opening and
# closing tags in the `on_config` plugin event.
INCLUDE_TAG_RE = rf'''
(?P<_includer_indent>[ \t\f\v\w{re.escape(string.punctuation)}]*?)$OPENING_TAG
(?P<_includer_indent>[ \t\w\\.]*?)$OPENING_TAG
\s*
include
\s+
Expand Down Expand Up @@ -171,7 +171,7 @@ def create_include_tag(
"""Create a regex pattern to match an inclusion tag directive.
Replaces the substrings '$OPENING_TAG' and '$CLOSING_TAG' from
INCLUDE_TAG_REGEX by the effective tag.
INCLUDE_TAG_RE by the effective tag.
"""
return re.compile(
INCLUDE_TAG_RE.replace(' include', f' {tag}').replace(
Expand Down

0 comments on commit 0fd1119

Please sign in to comment.