Skip to content

Commit

Permalink
fix: frontmatter_pattern and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TOsmanov committed Dec 11, 2023
1 parent 7e68858 commit bd2da0c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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

0 comments on commit bd2da0c

Please sign in to comment.