From a842f12d1ee77784d084b401f04c20a0aef3110e Mon Sep 17 00:00:00 2001 From: Timur Osmanov <54434686+TOsmanov@users.noreply.github.com> Date: Wed, 13 Dec 2023 12:12:28 +0300 Subject: [PATCH] fix: frontmatter_pattern and tests (#5) --- foliant/preprocessors/escapecode.py | 2 +- tests/data/expected/frontmatter_yaml.md | 6 ++++++ tests/data/input/frontmatter_yaml.md | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/foliant/preprocessors/escapecode.py b/foliant/preprocessors/escapecode.py index e5e6875..088882b 100644 --- a/foliant/preprocessors/escapecode.py +++ b/foliant/preprocessors/escapecode.py @@ -39,7 +39,7 @@ def __init__(self, *args, **kwargs): self.content = None self.pre_blocks_pattern = None self._cache_dir_path = (self.project_path / self.options['cache_dir']).resolve() - self.frontmatter_pattern = re.compile(r'^((-|\+){3})\n([\s\S]*)\n((-|\+){3})([\s\S]*)') + self.frontmatter_pattern = re.compile(r'^((-|\+){3})\n([\s\S]+?)\n((-|\+){3})([\s\S]*)') self.logger = self.logger.getChild('escapecode') diff --git a/tests/data/expected/frontmatter_yaml.md b/tests/data/expected/frontmatter_yaml.md index 4cf3169..29586ce 100644 --- a/tests/data/expected/frontmatter_yaml.md +++ b/tests/data/expected/frontmatter_yaml.md @@ -4,6 +4,12 @@ # Test + + +--- + + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo diff --git a/tests/data/input/frontmatter_yaml.md b/tests/data/input/frontmatter_yaml.md index 1120396..e1d4385 100644 --- a/tests/data/input/frontmatter_yaml.md +++ b/tests/data/input/frontmatter_yaml.md @@ -6,6 +6,16 @@ tempor incididunt ut labore." # Test +```py +import re +``` + +--- + +```py +import os +``` + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo