feat: Make the `start` parameter to a semiliterate pattern optional
continuous-integration/drone/push Build is failing Details

Resolves #4.
This commit is contained in:
Glen Whitney 2021-01-09 08:42:00 -08:00
parent 2235af160c
commit 981384c6f7
3 changed files with 25 additions and 2 deletions

View File

@ -12,7 +12,6 @@ plugins:
include_extensions: [LICENSE]
semiliterate:
- pattern: '(\.md)$'
start: '^(.*\s*)'
replace: [['^(.*)<!-- repo: -->.*<!-- site:(.*?) -->(.*\s*)$', '\1\2\3']]
- pattern: '(\.py)$'
start: '"""\smd'

View File

@ -49,6 +49,30 @@ it's the text **after** the application of any semiliterate `replace`ments that
is checked for `{! ... !}`.
"""
def __init__(self, input_stream, output_stream, **kwargs):
""" md
### Adjusted semiliterate options
The `start` regular-expression parameter to a `semiliterate` file-inclusion
pattern is now optional. If omitted, it means that extraction begins immediately
with the first line of a file; in this case, `pause` and `terminate` retain
their usual meanings, although there is not currently any way to resume from a
`pause` when `start` is not specified. This adjustment to `semiliterate`
parameters makes it easier to extract "front-matter" style documentation from
files.
"""
self.start_hot = False
if 'start' not in kwargs:
kwargs['start'] = 'dummy'
self.start_hot = True
super().__init__(input_stream, output_stream, **kwargs)
def extract(self):
if self.start_hot:
self.extracting = True
self.start = False
super().extract()
include_open = re.compile(r'''(?<![`\\])(\{\!\s*)([\s'"])''')
include_quoted_file = re.compile(
r'''(['"])(?P<fn>.*?)\1\s+(?P<yml>[\s\S]*?)\s\!\}''')

View File

@ -1,6 +1,6 @@
[metadata]
name = mkdocs-semiliterate
version = 0.0.5
version = 0.0.7
[options]
packages = mkdocs_semiliterate