Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: frontmatter_pattern and tests #5

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion foliant/preprocessors/escapecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
6 changes: 6 additions & 0 deletions tests/data/expected/frontmatter_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

# Test

<escaped hash="d0dddce3714967d15e245995f15172ef"></escaped>

---

<escaped hash="bdc835608eb1fd397997a841ad7ceb68"></escaped>

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
Expand Down
10 changes: 10 additions & 0 deletions tests/data/input/frontmatter_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down